Skip to content

Commit

Permalink
Update to 1.20.5-rc2
Browse files Browse the repository at this point in the history
  • Loading branch information
andantet committed Apr 20, 2024
1 parent 9552dac commit 4356c54
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 33 deletions.
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=23w51b
yarn_build=4
loader_version=0.15.7
minecraft_version=1.20.5-rc2
yarn_build=1
loader_version=0.15.10

# Mod Properties
mod_version=1.1.2
mod_version=1.2.0
maven_group=net.mcbrawls
mod_id=blueprint

# Dependencies
fabric_version=0.94.0+1.20.5
fabric_version=0.97.4+1.20.5

kotlin_version=1.9.23
fabric_kotlin_version=1.10.19+kotlin.1.9.23

devlogin_version=3.4.1
devlogin_version=3.5

bubble_version=1.0.7
bubble_version=1.0.8
audience_version=2.5.0
codex_version=1.4.0
codex_version=1.5.0
brawls_sgui_version=1.0.0

sgui_version=1.4.2+1.20.4
sgui_version=1.5.0+1.20.5
6 changes: 5 additions & 1 deletion src/main/kotlin/net/mcbrawls/blueprint/BlueprintMod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.mcbrawls.blueprint

import net.fabricmc.api.ModInitializer
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
import net.fabricmc.fabric.api.resource.ResourceManagerHelper
import net.mcbrawls.blueprint.command.BlueprintCommand
Expand Down Expand Up @@ -30,7 +31,10 @@ object BlueprintMod : ModInitializer {
BlueprintEditors

// register config packet receiver
ServerPlayNetworking.registerGlobalReceiver(BlueprintConfigC2SPacket.TYPE) { packet, player, _ ->
PayloadTypeRegistry.playC2S().register(BlueprintConfigC2SPacket.PACKET_ID, BlueprintConfigC2SPacket.PACKET_CODEC)

ServerPlayNetworking.registerGlobalReceiver(BlueprintConfigC2SPacket.PACKET_ID) { packet, context ->
val player = context.player()
player.blueprintData = packet.createBlueprintPlayerData()

val playerName = player.gameProfile.name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package net.mcbrawls.blueprint.network

import net.fabricmc.fabric.api.networking.v1.FabricPacket
import net.fabricmc.fabric.api.networking.v1.PacketType
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import io.netty.buffer.ByteBuf
import net.mcbrawls.blueprint.BlueprintMod
import net.mcbrawls.blueprint.player.BlueprintPlayerData
import net.minecraft.network.PacketByteBuf
import net.minecraft.network.codec.PacketCodec
import net.minecraft.network.codec.PacketCodecs
import net.minecraft.network.packet.CustomPayload
import net.minecraft.network.packet.CustomPayload.Id
import net.minecraft.util.Identifier

/**
Expand All @@ -15,17 +20,13 @@ data class BlueprintConfigC2SPacket(
* Whether the server should render blueprint particles.
*/
val renderParticles: Boolean,
) : FabricPacket {
) : CustomPayload {
constructor(buf: PacketByteBuf) : this(
buf.readBoolean()
)

override fun write(buf: PacketByteBuf) {
buf.writeBoolean(renderParticles)
}

override fun getType(): PacketType<*> {
return TYPE
override fun getId(): Id<out CustomPayload> {
return PACKET_ID
}

/**
Expand All @@ -36,12 +37,14 @@ data class BlueprintConfigC2SPacket(
}

companion object {
/**
* The type of the config packet.
*/
val TYPE: PacketType<BlueprintConfigC2SPacket> = PacketType.create(
Identifier(BlueprintMod.MOD_ID, "config"),
::BlueprintConfigC2SPacket
)
val PACKET_ID: Id<BlueprintConfigC2SPacket> = Id(Identifier(BlueprintMod.MOD_ID, "config"))

val CODEC: Codec<BlueprintConfigC2SPacket> = RecordCodecBuilder.create { instance ->
instance.group(
Codec.BOOL.fieldOf("render_particles").forGetter(BlueprintConfigC2SPacket::renderParticles)
).apply(instance, ::BlueprintConfigC2SPacket)
}

val PACKET_CODEC: PacketCodec<ByteBuf, BlueprintConfigC2SPacket> = PacketCodecs.codec(CODEC)
}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/net/mcbrawls/blueprint/region/CuboidRegion.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.mcbrawls.blueprint.region

import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.mcbrawls.blueprint.region.Region.Companion.iterateBoxBlockPositions
import net.mcbrawls.blueprint.region.serialization.SerializableRegion
Expand Down Expand Up @@ -58,7 +58,7 @@ data class CuboidRegion(
/**
* The codec of a cuboid region.
*/
val CODEC: Codec<CuboidRegion> = RecordCodecBuilder.create { instance ->
val CODEC: MapCodec<CuboidRegion> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
Vec3d.CODEC.fieldOf("root_position").forGetter(CuboidRegion::rootPosition),
Vec3d.CODEC.fieldOf("size").forGetter(CuboidRegion::size)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/net/mcbrawls/blueprint/region/PointRegion.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.mcbrawls.blueprint.region

import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.mcbrawls.blueprint.region.serialization.SerializableRegion
import net.mcbrawls.blueprint.region.serialization.SerializableRegionTypes
Expand Down Expand Up @@ -33,7 +33,7 @@ data class PointRegion(
/**
* The codec of a cuboid region.
*/
val CODEC: Codec<PointRegion> = RecordCodecBuilder.create { instance ->
val CODEC: MapCodec<PointRegion> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
Vec3d.CODEC.fieldOf("position").forGetter(PointRegion::pointPosition),
).apply(instance, ::PointRegion)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mcbrawls.blueprint.region

import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.mcbrawls.blueprint.region.Region.Companion.iterateBoxBlockPositions
import net.mcbrawls.blueprint.region.serialization.SerializableRegion
Expand Down Expand Up @@ -53,7 +54,7 @@ data class SphericalRegion(
/**
* The codec of a spherical region.
*/
val CODEC: Codec<SphericalRegion> = RecordCodecBuilder.create { instance ->
val CODEC: MapCodec<SphericalRegion> = RecordCodecBuilder.mapCodec { instance ->
instance.group(
Vec3d.CODEC.fieldOf("root_position").forGetter(SphericalRegion::rootPosition),
Codec.DOUBLE.fieldOf("radius").forGetter(SphericalRegion::radius)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mcbrawls.blueprint.region.serialization

import com.mojang.serialization.Codec
import com.mojang.serialization.MapCodec
import net.mcbrawls.blueprint.region.CompoundRegion
import net.mcbrawls.blueprint.region.Region
import net.minecraft.util.math.Vec3d
Expand Down Expand Up @@ -29,14 +30,14 @@ abstract class SerializableRegion(
/**
* The codec of this serializable region type.
*/
val codec: Codec<out SerializableRegion>
val codec: MapCodec<out SerializableRegion>
)

companion object {
/**
* The codec for a serializable region, defined by its type.
*/
val CODEC: Codec<SerializableRegion> = SerializableRegionTypes.REGISTRY.getCodec()
val CODEC: Codec<SerializableRegion> = SerializableRegionTypes.REGISTRY.codec
.dispatch(SerializableRegion::type, Type::codec)
}
}

0 comments on commit 4356c54

Please sign in to comment.