3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-08 09:30:04 +01:00

Update to 1.20.6

Dieser Commit ist enthalten in:
Moulberry 2024-05-04 23:13:31 +08:00
Ursprung cdee54d807
Commit 6e55a9016c
29 geänderte Dateien mit 111 neuen und 113 gelöschten Zeilen

Datei anzeigen

@ -1,10 +1,10 @@
plugins {
`java-library`
id("io.papermc.paperweight.userdev") version "1.5.11"
id("xyz.jpenilla.run-paper") version "2.2.2" // Adds runServer and runMojangMappedServer tasks for testing
id("io.papermc.paperweight.userdev") version "1.6.3"
id("xyz.jpenilla.run-paper") version "2.2.4" // Adds runServer and runMojangMappedServer tasks for testing
// Shades and relocates dependencies into our plugin jar. See https://imperceptiblethoughts.com/shadow/introduction/
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.github.goooler.shadow") version "8.1.7"
}
group = "com.moulberry.axiom"
@ -12,8 +12,8 @@ version = "1.5.9"
description = "Serverside component for Axiom on Paper"
java {
// Configure the java toolchain. This allows gradle to auto-provision JDK 17 on systems that only have JDK 8 installed for example.
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
// Configure the java toolchain. This allows gradle to auto-provision JDK 21 on systems that only have JDK 11 installed for example.
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
repositories {
@ -26,9 +26,9 @@ repositories {
}
dependencies {
paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
implementation("xyz.jpenilla:reflection-remapper:0.1.0-SNAPSHOT")
implementation("org.incendo:cloud-paper:2.0.0-beta.2")
implementation("org.incendo:cloud-paper:2.0.0-SNAPSHOT")
// Zstd Compression Library
implementation("com.github.luben:zstd-jni:1.5.5-4")
@ -56,7 +56,7 @@ tasks {
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(17)
options.release.set(21)
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything

Datei anzeigen

@ -9,6 +9,7 @@ import com.moulberry.axiom.event.AxiomModifyWorldEvent;
import com.moulberry.axiom.integration.plotsquared.PlotSquaredIntegration;
import com.moulberry.axiom.packet.*;
import com.moulberry.axiom.world_properties.server.ServerWorldPropertiesRegistry;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.papermc.paper.event.player.PlayerFailMoveEvent;
@ -18,12 +19,15 @@ import io.papermc.paper.network.ChannelInitializeListenerHolder;
import net.kyori.adventure.key.Key;
import net.minecraft.core.BlockPos;
import net.minecraft.core.IdMapper;
import net.minecraft.network.Connection;
import net.minecraft.network.ConnectionProtocol;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.*;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
import net.minecraft.network.protocol.game.GameProtocols;
import net.minecraft.network.protocol.game.ServerGamePacketListener;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.*;
@ -159,21 +163,16 @@ public class AxiomPaper extends JavaPlugin implements Listener {
RequestChunkDataPacketListener requestChunkDataPacketListener = allowLargeChunkDataRequest ?
new RequestChunkDataPacketListener(this) : null;
// Hack to figure out the id of the CustomPayload packet
ProtocolInfo<ServerGamePacketListener> protocol = GameProtocols.SERVERBOUND.bind(k -> new RegistryFriendlyByteBuf(k,
MinecraftServer.getServer().registryAccess()));
RegistryFriendlyByteBuf friendlyByteBuf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
protocol.codec().encode(friendlyByteBuf, new ServerboundCustomPayloadPacket(new DiscardedPayload(new ResourceLocation("dummy"), Unpooled.buffer())));
int payloadId = friendlyByteBuf.readVarInt();
ChannelInitializeListenerHolder.addListener(Key.key("axiom:handle_big_payload"), new ChannelInitializeListener() {
@Override
public void afterInitChannel(@NonNull Channel channel) {
var packets = ConnectionProtocol.PLAY.getPacketsByIds(PacketFlow.SERVERBOUND);
int payloadId = -1;
for (Map.Entry<Integer, Class<? extends Packet<?>>> entry : packets.entrySet()) {
if (entry.getValue() == ServerboundCustomPayloadPacket.class) {
payloadId = entry.getKey();
break;
}
}
if (payloadId < 0) {
throw new RuntimeException("Failed to find ServerboundCustomPayloadPacket id");
}
Connection connection = (Connection) channel.pipeline().get("packet_handler");
channel.pipeline().addBefore("decoder", "axiom-big-payload-handler",
new AxiomBigPayloadHandler(payloadId, connection, setBlockBufferPacketListener,
@ -285,16 +284,20 @@ public class AxiomPaper extends JavaPlugin implements Listener {
WorldExtension.tick(MinecraftServer.getServer(), sendMarkers, maxChunkRelightsPerTick, maxChunkSendsPerTick);
}, 1, 1);
PaperCommandManager<CommandSender> manager = PaperCommandManager.createNative(
this,
ExecutionCoordinator.simpleCoordinator()
);
try {
PaperCommandManager<CommandSender> manager = PaperCommandManager.createNative(
this,
ExecutionCoordinator.simpleCoordinator()
);
if (manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
manager.registerBrigadier();
if (manager.hasCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
manager.registerBrigadier();
}
AxiomDebugCommand.register(this, manager);
} catch (Exception e) {
e.printStackTrace();
}
AxiomDebugCommand.register(this, manager);
}
public boolean logLargeBlockBufferChanges() {

Datei anzeigen

@ -1,14 +1,15 @@
package com.moulberry.axiom;
import com.moulberry.axiom.packet.CustomByteArrayPayload;
import io.netty.buffer.Unpooled;
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
import net.minecraft.network.protocol.common.custom.DiscardedPayload;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
public class VersionHelper {
public static void sendCustomPayload(ServerPlayer serverPlayer, ResourceLocation id, byte[] data) {
serverPlayer.connection.send(new ClientboundCustomPayloadPacket(new CustomByteArrayPayload(id, data)));
serverPlayer.connection.send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, Unpooled.wrappedBuffer(data))));
}
}

Datei anzeigen

@ -16,8 +16,8 @@ import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.*;
@ -65,7 +65,7 @@ public class WorldExtension {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
buf.writeCollection(markerData, MarkerData::write);
buf.writeCollection(Set.of(), FriendlyByteBuf::writeUUID);
buf.writeCollection(Set.<UUID>of(), (buffer, uuid) -> buffer.writeUUID(uuid));
byte[] bytes = new byte[buf.writerIndex()];
buf.getBytes(0, bytes);
@ -106,7 +106,7 @@ public class WorldExtension {
if (!changedData.isEmpty() || !oldUuids.isEmpty()) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
buf.writeCollection(changedData, MarkerData::write);
buf.writeCollection(oldUuids, FriendlyByteBuf::writeUUID);
buf.writeCollection(oldUuids, (buffer, uuid) -> buffer.writeUUID(uuid));
byte[] bytes = new byte[buf.writerIndex()];
buf.getBytes(0, bytes);

Datei anzeigen

@ -128,7 +128,7 @@ public class BlueprintIo {
CompoundTag blockStates = compoundTag.getCompound("BlockStates");
blockStates = DFUHelper.updatePalettedContainer(blockStates, dataVersion);
PalettedContainer<BlockState> container = BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, blockStates)
.getOrThrow(false, err -> {});
.getOrThrow();
map.put(BlockPos.asLong(cx, cy, cz), container);
}
}
@ -205,8 +205,7 @@ public class BlueprintIo {
tag.putInt("X", cx);
tag.putInt("Y", cy);
tag.putInt("Z", cz);
Tag encoded = BlueprintIo.BLOCK_STATE_CODEC.encodeStart(NbtOps.INSTANCE, container)
.getOrThrow(false, err -> {});
Tag encoded = BlueprintIo.BLOCK_STATE_CODEC.encodeStart(NbtOps.INSTANCE, container).getOrThrow();
tag.put("BlockStates", encoded);
savedBlockRegions.add(tag);
}

Datei anzeigen

@ -6,7 +6,7 @@ import io.netty.buffer.Unpooled;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import java.io.BufferedInputStream;
import java.io.IOException;

Datei anzeigen

@ -220,12 +220,12 @@ public class PlotSquaredIntegrationImpl {
BlockVector3 minPoint = region.getMinimumPoint();
BlockVector3 maxPoint = region.getMaximumPoint();
int minPlotX = Math.max(minPoint.getX(), minX);
int minPlotY = Math.max(minPoint.getY(), minY);
int minPlotZ = Math.max(minPoint.getZ(), minZ);
int maxPlotX = Math.min(maxPoint.getX(), maxX);
int maxPlotY = Math.min(maxPoint.getY(), maxY);
int maxPlotZ = Math.min(maxPoint.getZ(), maxZ);
int minPlotX = Math.max(minPoint.x(), minX);
int minPlotY = Math.max(minPoint.y(), minY);
int minPlotZ = Math.max(minPoint.z(), minZ);
int maxPlotX = Math.min(maxPoint.x(), maxX);
int maxPlotY = Math.min(maxPoint.y(), maxY);
int maxPlotZ = Math.min(maxPoint.z(), maxZ);
if (minPlotX > maxPlotX) continue;
if (minPlotY > maxPlotY) continue;

Datei anzeigen

@ -122,12 +122,12 @@ public class WorldGuardIntegrationImpl {
BlockVector3 regionMin = region.getMinimumPoint();
BlockVector3 regionMax = region.getMaximumPoint();
int regionMinX = Math.max(regionMin.getX(), cx*16) - minX;
int regionMinY = Math.max(regionMin.getY(), cy*16) - minY;
int regionMinZ = Math.max(regionMin.getZ(), cz*16) - minZ;
int regionMaxX = Math.min(regionMax.getX(), cx*16+15) - minX;
int regionMaxY = Math.min(regionMax.getY(), cy*16+15) - minY;
int regionMaxZ = Math.min(regionMax.getZ(), cz*16+15) - minZ;
int regionMinX = Math.max(regionMin.x(), cx*16) - minX;
int regionMinY = Math.max(regionMin.y(), cy*16) - minY;
int regionMinZ = Math.max(regionMin.z(), cz*16) - minZ;
int regionMaxX = Math.min(regionMax.x(), cx*16+15) - minX;
int regionMaxY = Math.min(regionMax.y(), cy*16+15) - minY;
int regionMaxZ = Math.min(regionMax.z(), cz*16+15) - minZ;
Box box = new Box(regionMinX, regionMinY, regionMinZ, regionMaxX, regionMaxY, regionMaxZ);
if (value == StateFlag.State.DENY) {

Datei anzeigen

@ -10,7 +10,7 @@ import net.kyori.adventure.text.Component;
import net.minecraft.SharedConstants;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -1,12 +0,0 @@
package com.moulberry.axiom.packet;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
import net.minecraft.resources.ResourceLocation;
public record CustomByteArrayPayload(ResourceLocation id, byte[] bytes) implements CustomPacketPayload {
@Override
public void write(FriendlyByteBuf buf) {
buf.writeBytes(bytes);
}
}

Datei anzeigen

@ -9,7 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
@ -49,7 +49,7 @@ public class DeleteEntityPacketListener implements PluginMessageListener {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
List<UUID> delete = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
FriendlyByteBuf::readUUID);
buf -> buf.readUUID());
ServerLevel serverLevel = ((CraftWorld)player.getWorld()).getHandle();

Datei anzeigen

@ -22,12 +22,14 @@ import net.minecraft.SharedConstants;
import net.minecraft.core.IdMapper;
import net.minecraft.nbt.NbtIo;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
@ -155,7 +157,7 @@ public class HelloPacketListener implements PluginMessageListener {
}
// Enable
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
buf.writeBoolean(true);
buf.writeInt(handshakeEvent.getMaxBufferSize()); // Max Buffer Size
buf.writeBoolean(false); // No source info
@ -174,15 +176,15 @@ public class HelloPacketListener implements PluginMessageListener {
int activeHotbarIndex = container.getOrDefault(AxiomConstants.ACTIVE_HOTBAR_INDEX, PersistentDataType.BYTE, (byte) 0);
PersistentDataContainer hotbarItems = container.get(AxiomConstants.HOTBAR_DATA, PersistentDataType.TAG_CONTAINER);
if (hotbarItems != null) {
buf = new FriendlyByteBuf(Unpooled.buffer());
buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
buf.writeByte((byte) activeHotbarIndex);
for (int i=0; i<9*9; i++) {
// Ignore selected hotbar
if (i / 9 == activeHotbarIndex) {
buf.writeItem(net.minecraft.world.item.ItemStack.EMPTY);
net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.encode(buf, net.minecraft.world.item.ItemStack.EMPTY);
} else {
ItemStack stack = hotbarItems.get(new NamespacedKey("axiom", "slot_"+i), ItemStackDataType.INSTANCE);
buf.writeItem(CraftItemStack.asNMSCopy(stack));
net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.encode(buf, CraftItemStack.asNMSCopy(stack));
}
}
@ -195,7 +197,7 @@ public class HelloPacketListener implements PluginMessageListener {
// Initialize Views
UUID activeView = container.get(AxiomConstants.ACTIVE_VIEW, UUIDDataType.INSTANCE);
if (activeView != null) {
buf = new FriendlyByteBuf(Unpooled.buffer());
buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess());
buf.writeUUID(activeView);
PersistentDataContainer[] views = container.get(AxiomConstants.VIEWS, PersistentDataType.TAG_CONTAINER_ARRAY);

Datei anzeigen

@ -21,7 +21,7 @@ import net.minecraft.world.entity.decoration.ItemFrame;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
@ -69,7 +69,7 @@ public class ManipulateEntityPacketListener implements PluginMessageListener {
List<UUID> passengers = List.of();
if (passengerManipulation == PassengerManipulation.ADD_LIST || passengerManipulation == PassengerManipulation.REMOVE_LIST) {
passengers = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
FriendlyByteBuf::readUUID);
buffer -> buffer.readUUID());
}
return new ManipulateEntry(uuid, relativeMovementSet, position, yaw, pitch, nbt,

Datei anzeigen

@ -9,7 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Marker;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -22,11 +22,11 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
@ -115,7 +115,7 @@ public class RequestChunkDataPacketListener implements PluginMessageListener {
BlockEntity blockEntity = chunk.getBlockEntity(mutableBlockPos, LevelChunk.EntityCreationType.IMMEDIATE);
if (blockEntity != null) {
CompoundTag tag = blockEntity.saveWithoutMetadata();
CompoundTag tag = blockEntity.saveWithoutMetadata(player.registryAccess());
blockEntityMap.put(pos, CompressedBlockEntity.compress(tag, baos));
}
}
@ -154,7 +154,7 @@ public class RequestChunkDataPacketListener implements PluginMessageListener {
mutableBlockPos.set(sx*16 + x, sy*16 + y, sz*16 + z);
BlockEntity blockEntity = chunk.getBlockEntity(mutableBlockPos, LevelChunk.EntityCreationType.CHECK);
if (blockEntity != null) {
CompoundTag tag = blockEntity.saveWithoutMetadata();
CompoundTag tag = blockEntity.saveWithoutMetadata(player.registryAccess());
blockEntityMap.put(mutableBlockPos.asLong(), CompressedBlockEntity.compress(tag, baos));
}
}

Datei anzeigen

@ -34,7 +34,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.chunk.PalettedContainer;
@ -282,7 +282,7 @@ public class SetBlockBufferPacketListener {
int key = x | (y << 4) | (z << 8);
CompressedBlockEntity savedBlockEntity = blockEntityChunkMap.get((short) key);
if (savedBlockEntity != null) {
blockEntity.load(savedBlockEntity.decompress());
blockEntity.loadWithComponents(savedBlockEntity.decompress(), player.registryAccess());
}
}
} else if (old.hasBlockEntity()) {

Datei anzeigen

@ -31,9 +31,9 @@ import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
@ -91,7 +91,7 @@ public class SetBlockPacketListener implements PluginMessageListener {
IntFunction<Map<BlockPos, BlockState>> mapFunction = FriendlyByteBuf.limitValue(Maps::newLinkedHashMapWithExpectedSize, 512);
IdMapper<BlockState> registry = this.plugin.getBlockRegistry(bukkitPlayer.getUniqueId());
Map<BlockPos, BlockState> blocks = friendlyByteBuf.readMap(mapFunction,
FriendlyByteBuf::readBlockPos, buf -> buf.readById(registry));
buf -> buf.readBlockPos(), buf -> buf.readById(registry::byIdOrThrow));
boolean updateNeighbors = friendlyByteBuf.readBoolean();
int reason = friendlyByteBuf.readVarInt();

Datei anzeigen

@ -6,7 +6,7 @@ import io.netty.buffer.Unpooled;
import net.kyori.adventure.text.Component;
import net.minecraft.network.FriendlyByteBuf;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -8,7 +8,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.GameType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -7,8 +7,11 @@ import com.viaversion.viaversion.api.Via;
import io.netty.buffer.Unpooled;
import net.kyori.adventure.text.Component;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.world.item.ItemStack;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
@ -36,10 +39,10 @@ public class SetHotbarSlotPacketListener implements PluginMessageListener {
return;
}
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
RegistryFriendlyByteBuf friendlyByteBuf = new RegistryFriendlyByteBuf(Unpooled.wrappedBuffer(message), ((CraftPlayer)player).getHandle().registryAccess());
int index = friendlyByteBuf.readByte();
if (index < 0 || index >= 9*9) return;
net.minecraft.world.item.ItemStack nmsStack = friendlyByteBuf.readItem();
net.minecraft.world.item.ItemStack nmsStack = ItemStack.OPTIONAL_STREAM_CODEC.decode(friendlyByteBuf);
PersistentDataContainer container = player.getPersistentDataContainer();
PersistentDataContainer hotbarItems = container.get(AxiomConstants.HOTBAR_DATA, PersistentDataType.TAG_CONTAINER);

Datei anzeigen

@ -12,7 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -20,7 +20,7 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Rotation;
import net.minecraft.world.phys.Vec3;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
@ -70,7 +70,7 @@ public class SpawnEntityPacketListener implements PluginMessageListener {
List<SpawnEntry> entries = friendlyByteBuf.readCollection(FriendlyByteBuf.limitValue(ArrayList::new, 1000),
buf -> new SpawnEntry(buf.readUUID(), buf.readDouble(), buf.readDouble(),
buf.readDouble(), buf.readFloat(), buf.readFloat(),
buf.readNullable(FriendlyByteBuf::readUUID), ViaVersionHelper.readTagUnknown(buf, player)));
buf.readNullable(buffer -> buffer.readUUID()), ViaVersionHelper.readTagUnknown(buf, player)));
ServerLevel serverLevel = ((CraftWorld)player.getWorld()).getHandle();

Datei anzeigen

@ -6,10 +6,12 @@ import com.moulberry.axiom.persistence.ItemStackDataType;
import io.netty.buffer.Unpooled;
import net.kyori.adventure.text.Component;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.RegistryFriendlyByteBuf;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
@ -38,13 +40,13 @@ public class SwitchActiveHotbarPacketListener implements PluginMessageListener {
return;
}
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
RegistryFriendlyByteBuf friendlyByteBuf = new RegistryFriendlyByteBuf(Unpooled.wrappedBuffer(message), ((CraftPlayer)player).getHandle().registryAccess());
int oldHotbarIndex = friendlyByteBuf.readByte();
int activeHotbarIndex = friendlyByteBuf.readByte();
ItemStack[] hotbarItems = new ItemStack[9];
for (int i=0; i<9; i++) {
hotbarItems[i] = CraftItemStack.asCraftMirror(friendlyByteBuf.readItem());
hotbarItems[i] = CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.decode(friendlyByteBuf));
}
PersistentDataContainer container = player.getPersistentDataContainer();

Datei anzeigen

@ -10,8 +10,8 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.Level;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_20_R3.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;

Datei anzeigen

@ -1,8 +1,9 @@
package com.moulberry.axiom.persistence;
import net.minecraft.nbt.CompoundTag;
import org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_20_R3.persistence.CraftPersistentDataContainer;
import net.minecraft.server.MinecraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataAdapterContext;
import org.bukkit.persistence.PersistentDataContainer;
@ -28,8 +29,7 @@ public class ItemStackDataType implements PersistentDataType<PersistentDataConta
public @NotNull PersistentDataContainer toPrimitive(@NotNull ItemStack complex, @NotNull PersistentDataAdapterContext context) {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(complex);
if (nmsStack == null) nmsStack = net.minecraft.world.item.ItemStack.EMPTY;
CompoundTag tag = new CompoundTag();
nmsStack.save(tag);
CompoundTag tag = (CompoundTag) nmsStack.save(MinecraftServer.getServer().registryAccess());
PersistentDataContainer container = context.newPersistentDataContainer();
((CraftPersistentDataContainer)container).putAll(tag);
@ -39,7 +39,7 @@ public class ItemStackDataType implements PersistentDataType<PersistentDataConta
@Override
public @NotNull ItemStack fromPrimitive(@NotNull PersistentDataContainer primitive, @NotNull PersistentDataAdapterContext context) {
CompoundTag tag = ((CraftPersistentDataContainer)primitive).toTagCompound();
net.minecraft.world.item.ItemStack nmsStack = net.minecraft.world.item.ItemStack.of(tag);
net.minecraft.world.item.ItemStack nmsStack = net.minecraft.world.item.ItemStack.parseOptional(MinecraftServer.getServer().registryAccess(), tag);
return CraftItemStack.asCraftMirror(nmsStack);
}

Datei anzeigen

@ -87,7 +87,7 @@ public abstract class WorldPropertyDataType<T> {
if (value == null) value = Items.AIR;
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer(8));
buf.writeId(BuiltInRegistries.ITEM, value);
buf.writeById(BuiltInRegistries.ITEM::getIdOrThrow, value);
byte[] bytes = new byte[buf.writerIndex()];
buf.getBytes(0, bytes);
@ -97,7 +97,7 @@ public abstract class WorldPropertyDataType<T> {
@Override
public Item deserialize(byte[] bytes) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
return buf.readById(BuiltInRegistries.ITEM);
return buf.readById(BuiltInRegistries.ITEM::byIdOrThrow);
}
};
@ -112,7 +112,7 @@ public abstract class WorldPropertyDataType<T> {
if (value == null) value = Blocks.AIR;
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer(8));
buf.writeId(BuiltInRegistries.BLOCK, value);
buf.writeById(BuiltInRegistries.BLOCK::getIdOrThrow, value);
byte[] bytes = new byte[buf.writerIndex()];
buf.getBytes(0, bytes);
@ -122,7 +122,7 @@ public abstract class WorldPropertyDataType<T> {
@Override
public Block deserialize(byte[] bytes) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.wrappedBuffer(bytes));
return buf.readById(BuiltInRegistries.BLOCK);
return buf.readById(BuiltInRegistries.BLOCK::byIdOrThrow);
}
};

Datei anzeigen

@ -9,7 +9,7 @@ import net.minecraft.server.level.ServerLevel;
import org.bukkit.GameRule;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

Datei anzeigen

@ -6,7 +6,7 @@ import com.moulberry.axiom.world_properties.WorldPropertyWidgetType;
import net.minecraft.resources.ResourceLocation;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.Player;
public abstract class ServerWorldPropertyBase<T> {

Datei anzeigen

@ -9,7 +9,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_20_R3.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.Player;
import java.util.Objects;