From 9a86585f3e472424581b4f747ec4b5f25536a6b7 Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sun, 17 Nov 2024 00:13:04 +0800 Subject: [PATCH] Update to 1.21.3 --- gradle/libs.versions.toml | 2 +- .../com/moulberry/axiom/DisallowedBlocks.java | 2 +- .../axiom/blueprint/BlueprintIo.java | 8 ++++++-- .../impl/ManipulateEntityPacketListener.java | 20 +++++++++---------- .../impl/SetBlockBufferPacketListener.java | 19 +++++++++--------- .../packet/impl/SetBlockPacketListener.java | 5 +++-- .../impl/SpawnEntityPacketListener.java | 3 ++- 7 files changed, 33 insertions(+), 26 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a3cbbf1..72c311f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ bom-newest = "1.37" cloud-paper = "2.0.0-20240516.054251-69" coreprotect = "22.4" -paper = "1.21.1-R0.1-SNAPSHOT" +paper = "1.21.3-R0.1-SNAPSHOT" plotsquared = "7.3.8" reflection-remapper = "0.1.2-20240315.033304-2" viaversion-api = "5.0.1" diff --git a/src/main/java/com/moulberry/axiom/DisallowedBlocks.java b/src/main/java/com/moulberry/axiom/DisallowedBlocks.java index ef4ab3a..a83a9db 100644 --- a/src/main/java/com/moulberry/axiom/DisallowedBlocks.java +++ b/src/main/java/com/moulberry/axiom/DisallowedBlocks.java @@ -27,7 +27,7 @@ public class DisallowedBlocks { for (String disallowedBlock : disallowedBlocks) { try { - var parsed = BlockStateParser.parseForTesting(BuiltInRegistries.BLOCK.asLookup(), new StringReader(disallowedBlock), false); + var parsed = BlockStateParser.parseForTesting(BuiltInRegistries.BLOCK, new StringReader(disallowedBlock), false); parsed.left().ifPresent(result -> { disallowedPredicates.add(blockState -> { diff --git a/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java b/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java index 6c37c34..8792b29 100644 --- a/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java +++ b/src/main/java/com/moulberry/axiom/blueprint/BlueprintIo.java @@ -8,6 +8,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.*; import net.minecraft.resources.ResourceLocation; @@ -25,6 +26,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import java.util.Optional; public class BlueprintIo { @@ -91,9 +93,11 @@ public class BlueprintIo { long pos = blockPos.asLong(); String id = blockEntityCompound.getString("id"); - BlockEntityType type = BuiltInRegistries.BLOCK_ENTITY_TYPE.get(VersionHelper.createResourceLocation(id)); + Optional>> typeOptional = BuiltInRegistries.BLOCK_ENTITY_TYPE.get(VersionHelper.createResourceLocation(id)); - if (type != null) { + if (typeOptional.isPresent()) { + BlockEntityType type = typeOptional.get().value(); + PalettedContainer container = blockMap.get(BlockPos.asLong( blockPos.getX() >> 4, blockPos.getY() >> 4, diff --git a/src/main/java/com/moulberry/axiom/packet/impl/ManipulateEntityPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/ManipulateEntityPacketListener.java index 1fc650a..13db5b7 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/ManipulateEntityPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/ManipulateEntityPacketListener.java @@ -17,7 +17,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.RelativeMovement; +import net.minecraft.world.entity.Relative; import net.minecraft.world.entity.decoration.HangingEntity; import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.level.block.Rotation; @@ -48,18 +48,18 @@ public class ManipulateEntityPacketListener implements PacketHandler { REMOVE_LIST } - public record ManipulateEntry(UUID uuid, @Nullable Set relativeMovementSet, @Nullable Vec3 position, + public record ManipulateEntry(UUID uuid, @Nullable Set relativeMovementSet, @Nullable Vec3 position, float yaw, float pitch, CompoundTag merge, PassengerManipulation passengerManipulation, List passengers) { public static ManipulateEntry read(FriendlyByteBuf friendlyByteBuf, Player player, AxiomPaper plugin) { UUID uuid = friendlyByteBuf.readUUID(); int flags = friendlyByteBuf.readByte(); - Set relativeMovementSet = null; + Set relativeMovementSet = null; Vec3 position = null; float yaw = 0; float pitch = 0; if (flags >= 0) { - relativeMovementSet = RelativeMovement.unpack(flags); + relativeMovementSet = Relative.unpack(flags); position = new Vec3(friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble(), friendlyByteBuf.readDouble()); yaw = friendlyByteBuf.readFloat(); pitch = friendlyByteBuf.readFloat(); @@ -128,11 +128,11 @@ public class ManipulateEntityPacketListener implements PacketHandler { Vec3 entryPos = entry.position(); if (entryPos != null && entry.relativeMovementSet != null) { - double newX = entry.relativeMovementSet.contains(RelativeMovement.X) ? entity.position().x + entryPos.x : entryPos.x; - double newY = entry.relativeMovementSet.contains(RelativeMovement.Y) ? entity.position().y + entryPos.y : entryPos.y; - double newZ = entry.relativeMovementSet.contains(RelativeMovement.Z) ? entity.position().z + entryPos.z : entryPos.z; - float newYaw = entry.relativeMovementSet.contains(RelativeMovement.Y_ROT) ? entity.getYRot() + entry.yaw : entry.yaw; - float newPitch = entry.relativeMovementSet.contains(RelativeMovement.X_ROT) ? entity.getXRot() + entry.pitch : entry.pitch; + double newX = entry.relativeMovementSet.contains(Relative.X) ? entity.position().x + entryPos.x : entryPos.x; + double newY = entry.relativeMovementSet.contains(Relative.Y) ? entity.position().y + entryPos.y : entryPos.y; + double newZ = entry.relativeMovementSet.contains(Relative.Z) ? entity.position().z + entryPos.z : entryPos.z; + float newYaw = entry.relativeMovementSet.contains(Relative.Y_ROT) ? entity.getYRot() + entry.yaw : entry.yaw; + float newPitch = entry.relativeMovementSet.contains(Relative.X_ROT) ? entity.getXRot() + entry.pitch : entry.pitch; if (entity instanceof HangingEntity hangingEntity) { float changedYaw = newYaw - entity.getYRot(); @@ -148,7 +148,7 @@ public class ManipulateEntityPacketListener implements PacketHandler { if (Integration.canPlaceBlock(player, new Location(player.getWorld(), containing.getX(), containing.getY(), containing.getZ()))) { - entity.teleportTo(serverLevel, newX, newY, newZ, Set.of(), newYaw, newPitch); + entity.teleportTo(serverLevel, newX, newY, newZ, Set.of(), newYaw, newPitch, true); } entity.setYHeadRot(newYaw); 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 f668942..2a0376a 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockBufferPacketListener.java @@ -154,7 +154,7 @@ public class SetBlockBufferPacketListener implements PacketHandler { int cz = BlockPos.getZ(entry.getLongKey()); PalettedContainer container = entry.getValue(); - if (cy < world.getMinSection() || cy >= world.getMaxSection()) { + if (cy < world.getMinSectionY() || cy > world.getMaxSectionY()) { continue; } @@ -247,7 +247,7 @@ public class SetBlockBufferPacketListener implements PacketHandler { } // Update Light - sectionLightChanged |= LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState); + sectionLightChanged |= LightEngine.hasDifferentLightProperties(old, blockState); // Update Poi Optional> newPoi = containerMaybeHasPoi ? PoiTypes.forState(blockState) : Optional.empty(); @@ -312,11 +312,12 @@ public class SetBlockBufferPacketListener implements PacketHandler { boolean nowHasOnlyAir = section.hasOnlyAir(); if (hasOnlyAir != nowHasOnlyAir) { world.getChunkSource().getLightEngine().updateSectionStatus(SectionPos.of(cx, cy, cz), nowHasOnlyAir); + world.getChunkSource().onSectionEmptinessChanged(cx, cy, cz, nowHasOnlyAir); } if (sectionChanged) { extension.sendChunk(cx, cz); - chunk.setUnsaved(true); + chunk.markUnsaved(); } if (sectionLightChanged) { extension.lightChunk(cx, cz); @@ -344,21 +345,21 @@ public class SetBlockBufferPacketListener implements PacketHandler { Set changedChunks = new HashSet<>(); - int minSection = world.getMinSection(); - int maxSection = world.getMaxSection(); + int minSection = world.getMinSectionY(); + int maxSection = world.getMaxSectionY(); - Optional> registryOptional = world.registryAccess().registry(Registries.BIOME); + Optional> registryOptional = world.registryAccess().lookup(Registries.BIOME); if (registryOptional.isEmpty()) return; Registry registry = registryOptional.get(); biomeBuffer.forEachEntry((x, y, z, biome) -> { int cy = y >> 2; - if (cy < minSection || cy >= maxSection) { + if (cy < minSection || cy > maxSection) { return; } - var holder = registry.getHolder(biome); + var holder = registry.get(biome); if (holder.isPresent()) { var chunk = (LevelChunk) world.getChunk(x >> 2, z >> 2, ChunkStatus.FULL, false); if (chunk == null) return; @@ -377,7 +378,7 @@ public class SetBlockBufferPacketListener implements PacketHandler { var chunkMap = world.getChunkSource().chunkMap; HashMap> map = new HashMap<>(); for (LevelChunk chunk : changedChunks) { - chunk.setUnsaved(true); + chunk.markUnsaved(); ChunkPos chunkPos = chunk.getPos(); for (ServerPlayer serverPlayer2 : chunkMap.getPlayers(chunkPos, false)) { map.computeIfAbsent(serverPlayer2, serverPlayer -> new ArrayList<>()).add(chunk); diff --git a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java index 972b7e3..3141ea6 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/SetBlockPacketListener.java @@ -232,7 +232,7 @@ public class SetBlockPacketListener implements PacketHandler { ServerLevel level = player.serverLevel(); LevelChunk chunk = level.getChunk(cx, cz); - chunk.setUnsaved(true); + chunk.markUnsaved(); LevelChunkSection section = chunk.getSection(level.getSectionIndexFromSectionY(cy)); boolean hasOnlyAir = section.hasOnlyAir(); @@ -295,7 +295,7 @@ public class SetBlockPacketListener implements PacketHandler { level.getChunkSource().blockChanged(blockPos); // Update Light - if (LightEngine.hasDifferentLightProperties(chunk, blockPos, old, blockState)) { + if (LightEngine.hasDifferentLightProperties(old, blockState)) { // Note: Skylight Sources not currently needed on Paper due to Starlight // This might change in the future, so be careful! // chunk.getSkyLightSources().update(chunk, x, by, z); @@ -322,6 +322,7 @@ public class SetBlockPacketListener implements PacketHandler { boolean nowHasOnlyAir = section.hasOnlyAir(); if (hasOnlyAir != nowHasOnlyAir) { level.getChunkSource().getLightEngine().updateSectionStatus(SectionPos.of(cx, cy, cz), nowHasOnlyAir); + level.getChunkSource().onSectionEmptinessChanged(cx, cy, cz, nowHasOnlyAir); } } } diff --git a/src/main/java/com/moulberry/axiom/packet/impl/SpawnEntityPacketListener.java b/src/main/java/com/moulberry/axiom/packet/impl/SpawnEntityPacketListener.java index 38bd3f2..aefb1af 100644 --- a/src/main/java/com/moulberry/axiom/packet/impl/SpawnEntityPacketListener.java +++ b/src/main/java/com/moulberry/axiom/packet/impl/SpawnEntityPacketListener.java @@ -14,6 +14,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntitySpawnReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.decoration.HangingEntity; import net.minecraft.world.entity.decoration.ItemFrame; @@ -96,7 +97,7 @@ public class SpawnEntityPacketListener implements PacketHandler { AtomicBoolean useNewUuid = new AtomicBoolean(true); - Entity spawned = EntityType.loadEntityRecursive(tag, serverLevel, entity -> { + Entity spawned = EntityType.loadEntityRecursive(tag, serverLevel, EntitySpawnReason.COMMAND, entity -> { if (!this.plugin.canEntityBeManipulated(entity.getType())) { return null; }