diff --git a/src/main/java/com/moulberry/axiom/VersionHelper.java b/src/main/java/com/moulberry/axiom/VersionHelper.java index 1fa4dcb..f3c22b3 100644 --- a/src/main/java/com/moulberry/axiom/VersionHelper.java +++ b/src/main/java/com/moulberry/axiom/VersionHelper.java @@ -1,6 +1,7 @@ package com.moulberry.axiom; import com.moulberry.axiom.packet.CustomByteArrayPayload; +import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; @@ -11,6 +12,12 @@ public class VersionHelper { serverPlayer.connection.send(new ClientboundCustomPayloadPacket(new CustomByteArrayPayload(id, data))); } + public static void sendCustomPayload(ServerPlayer serverPlayer, ResourceLocation id, FriendlyByteBuf friendlyByteBuf) { + byte[] data = new byte[friendlyByteBuf.writerIndex()]; + friendlyByteBuf.getBytes(friendlyByteBuf.readerIndex(), data); + sendCustomPayload(serverPlayer, id, data); + } + public static ResourceLocation createResourceLocation(String composed) { return new ResourceLocation(composed); } diff --git a/src/main/java/com/moulberry/axiom/packet/impl/HelloPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/HelloPacketListener.java index da769dd..7e2f937 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/HelloPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/HelloPacketListener.java @@ -17,7 +17,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.world.level.block.state.BlockState; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.List; diff --git a/src/main/java/com/moulberry/axiom/packet/impl/RequestEntityDataPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/RequestEntityDataPacketListener.java index 989a425..f0d5b83 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/RequestEntityDataPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/RequestEntityDataPacketListener.java @@ -7,14 +7,13 @@ import com.moulberry.axiom.packet.PacketHandler; import io.netty.buffer.Unpooled; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import java.util.*; @@ -102,7 +101,7 @@ public class RequestEntityDataPacketListener implements PacketHandler { friendlyByteBuf.writeBoolean(finished); friendlyByteBuf.writeMap(map, (buf, uuid) -> buf.writeUUID(uuid), (buf, nbt) -> buf.writeNbt(nbt)); - player.connection.send(new ClientboundCustomPayloadPacket(RESPONSE_ID, friendlyByteBuf)); + VersionHelper.sendCustomPayload(player, RESPONSE_ID, friendlyByteBuf); } } diff --git a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java index 7a0ddb5..57c6ed7 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java @@ -42,7 +42,7 @@ import net.minecraft.world.level.chunk.PalettedContainer; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.lighting.LightEngine; import org.bukkit.Location; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import xyz.jpenilla.reflectionremapper.ReflectionRemapper; diff --git a/src/main/java/com/moulberry/axiom/packet/impl/UpdateAnnotationPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/UpdateAnnotationPacketListener.java index 3c12f56..1b9aadc 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/UpdateAnnotationPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/UpdateAnnotationPacketListener.java @@ -6,7 +6,7 @@ import com.moulberry.axiom.annotations.ServerAnnotations; import com.moulberry.axiom.packet.PacketHandler; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.ArrayList; diff --git a/src/main/java/com/moulberry/axiom/packet/impl/UploadBlueprintPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/UploadBlueprintPacketListener.java index e667ab2..280320b 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/UploadBlueprintPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/UploadBlueprintPacketListener.java @@ -10,7 +10,7 @@ import net.minecraft.SharedConstants; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; -import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; import java.io.BufferedOutputStream;