Add global direction and relative side codecs, so less data is duplicated when something need these codecs
This commit is contained in:
parent
578d86410b
commit
afb6cd5907
@ -1,6 +1,7 @@
|
||||
package ru.dbotthepony.mc.otm.network
|
||||
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.core.Direction
|
||||
import net.minecraft.core.UUIDUtil
|
||||
import net.minecraft.network.FriendlyByteBuf
|
||||
import net.minecraft.network.codec.ByteBufCodecs
|
||||
@ -10,6 +11,7 @@ import net.minecraft.world.level.block.Block
|
||||
import net.minecraft.world.level.block.state.BlockState
|
||||
import ru.dbotthepony.kommons.math.RGBAColor
|
||||
import ru.dbotthepony.mc.otm.container.ItemFilter
|
||||
import ru.dbotthepony.mc.otm.util.math.RelativeSide
|
||||
import ru.dbotthepony.mc.otm.util.readDecimal
|
||||
import ru.dbotthepony.mc.otm.util.writeDecimal
|
||||
import ru.dbotthepony.mc.otm.util.readBlockType
|
||||
@ -35,6 +37,8 @@ object StreamCodecs {
|
||||
val RESOURCE_LOCATION = ResourceLocation.STREAM_CODEC.wrap()
|
||||
val BLOCK_STATE: MatteryStreamCodec<ByteBuf, BlockState> = ByteBufCodecs.idMapper(Block.BLOCK_STATE_REGISTRY).wrap()
|
||||
val BLOCK_TYPE = MatteryStreamCodec.Of(FriendlyByteBuf::writeBlockType, FriendlyByteBuf::readBlockType)
|
||||
val RELATIVE_SIDE = MatteryStreamCodec.Enum<FriendlyByteBuf, RelativeSide>(RelativeSide::class.java)
|
||||
val DIRECTION = MatteryStreamCodec.Enum<FriendlyByteBuf, Direction>(Direction::class.java)
|
||||
|
||||
val RGBA: MatteryStreamCodec<ByteBuf, RGBAColor> = StreamCodec.of<ByteBuf, RGBAColor>(
|
||||
{ s, v -> s.writeFloat(v.red); s.writeFloat(v.green); s.writeFloat(v.blue); s.writeFloat(v.alpha) },
|
||||
|
Loading…
Reference in New Issue
Block a user