mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed spells not syncing
This commit is contained in:
parent
58c342442d
commit
e9728ec0f7
2 changed files with 4 additions and 3 deletions
|
@ -20,6 +20,7 @@ import com.minelittlepony.unicopia.util.serialization.NbtSerialisable;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
import net.minecraft.network.PacketByteBuf;
|
||||||
import net.minecraft.network.RegistryByteBuf;
|
import net.minecraft.network.RegistryByteBuf;
|
||||||
import net.minecraft.network.codec.PacketCodecs;
|
import net.minecraft.network.codec.PacketCodecs;
|
||||||
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
|
||||||
|
@ -165,7 +166,7 @@ class MultiSpellSlot implements SpellSlots, NbtSerialisable {
|
||||||
@Override
|
@Override
|
||||||
public Optional<? extends ByteBuf> write(Status status, WrapperLookup lookup) {
|
public Optional<? extends ByteBuf> write(Status status, WrapperLookup lookup) {
|
||||||
if (status != Status.DEFAULT) {
|
if (status != Status.DEFAULT) {
|
||||||
ByteBuf buffer = Unpooled.buffer();
|
ByteBuf buffer = new PacketByteBuf(Unpooled.buffer());
|
||||||
buffer.writeByte(1);
|
buffer.writeByte(1);
|
||||||
PacketCodecs.NBT_COMPOUND.encode(buffer, spell.toNBT(lookup));
|
PacketCodecs.NBT_COMPOUND.encode(buffer, spell.toNBT(lookup));
|
||||||
return Optional.of(buffer);
|
return Optional.of(buffer);
|
||||||
|
|
|
@ -20,13 +20,13 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public interface PacketCodecUtils {
|
public interface PacketCodecUtils {
|
||||||
PacketCodec<PacketByteBuf, PacketByteBuf> BUFFER = PacketCodec.of((buffer, bytes) -> {
|
PacketCodec<PacketByteBuf, PacketByteBuf> BUFFER = PacketCodec.of((bytes, buffer) -> {
|
||||||
buffer.writeInt(bytes.writerIndex());
|
buffer.writeInt(bytes.writerIndex());
|
||||||
buffer.writeBytes(bytes);
|
buffer.writeBytes(bytes);
|
||||||
}, buffer -> new PacketByteBuf(buffer.readBytes(buffer.readInt())));
|
}, buffer -> new PacketByteBuf(buffer.readBytes(buffer.readInt())));
|
||||||
PacketCodec<PacketByteBuf, Optional<PacketByteBuf>> OPTIONAL_BUFFER = PacketCodecs.optional(BUFFER);
|
PacketCodec<PacketByteBuf, Optional<PacketByteBuf>> OPTIONAL_BUFFER = PacketCodecs.optional(BUFFER);
|
||||||
|
|
||||||
PacketCodec<RegistryByteBuf, ByteBuf> REGISTRY_BUFFER = PacketCodec.of((buffer, bytes) -> {
|
PacketCodec<RegistryByteBuf, ByteBuf> REGISTRY_BUFFER = PacketCodec.of((bytes, buffer) -> {
|
||||||
buffer.writeInt(bytes.writerIndex());
|
buffer.writeInt(bytes.writerIndex());
|
||||||
buffer.writeBytes(bytes);
|
buffer.writeBytes(bytes);
|
||||||
}, buffer -> new RegistryByteBuf(buffer.readBytes(buffer.readInt()), buffer.getRegistryManager()));
|
}, buffer -> new RegistryByteBuf(buffer.readBytes(buffer.readInt()), buffer.getRegistryManager()));
|
||||||
|
|
Loading…
Reference in a new issue