From 9bc7feb4c48fb4f07d4b9aa39985266d07ece396 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Sat, 3 May 2025 19:04:33 +0100 Subject: [PATCH] Configure falling blocks dropping items --- .../0002-Client-Visibility-Settings.patch | 6 +++--- .../features/0003-Load-Chunks-on-Movement.patch | 6 +++--- ...-Slice-Packet-obfuscation-and-reduction.patch | 4 ++-- .../features/0008-Merge-Cannon-Entities.patch | 13 +++++++------ .../features/0017-Configure-cannon-physics.patch | 16 ++++++++-------- ...able-left-shooting-and-adjusting-limits.patch | 4 ++-- .../entity/item/FallingBlockEntity.java.patch | 3 ++- .../sakura/configuration/WorldConfiguration.java | 1 + 8 files changed, 28 insertions(+), 25 deletions(-) diff --git a/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch b/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch index f14e882..3a79bd4 100644 --- a/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch +++ b/sakura-server/minecraft-patches/features/0002-Client-Visibility-Settings.patch @@ -222,12 +222,12 @@ index 607a3243074d1a67c413d33493fa7b8d9d3055d8..ec7687616eb0bc0f1149d990051a5d67 public Entity(EntityType entityType, Level level) { this.type = entityType; diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index a6922dd8a319511538e9e4dbe92e484d728e445f..6fdcb636e7c4455cec20ebd303da86a71a461afb 100644 +index 5b036edf61c53596528bf722c46673b47c01f51d..6660e6c78303db5585a06d6836b035d0e8582922 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -75,6 +75,7 @@ public class FallingBlockEntity extends Entity { - public FallingBlockEntity(EntityType entityType, Level level) { +@@ -76,6 +76,7 @@ public class FallingBlockEntity extends Entity { super(entityType, level); + this.dropItem = level.sakuraConfig().cannons.sand.dropItems; // Sakura - configure falling blocks dropping items this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics + this.isFallingBlock = true; // Sakura - client visibility settings } diff --git a/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch b/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch index 9032717..fdfaa00 100644 --- a/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch +++ b/sakura-server/minecraft-patches/features/0003-Load-Chunks-on-Movement.patch @@ -101,11 +101,11 @@ index ec7687616eb0bc0f1149d990051a5d67b04edc19..7031f59d7b2b07bffc44d09b9685dc3d public boolean mayInteract(ServerLevel level, BlockPos pos) { diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 6fdcb636e7c4455cec20ebd303da86a71a461afb..53fce919a6e221aa98cfb0e5a3bb9f673221535e 100644 +index 6660e6c78303db5585a06d6836b035d0e8582922..b6a2da9d6db99f107fa8d9703b77515cf112a604 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -76,6 +76,7 @@ public class FallingBlockEntity extends Entity { - super(entityType, level); +@@ -77,6 +77,7 @@ public class FallingBlockEntity extends Entity { + this.dropItem = level.sakuraConfig().cannons.sand.dropItems; // Sakura - configure falling blocks dropping items this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics this.isFallingBlock = true; // Sakura - client visibility settings + this.loadChunks = level.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement diff --git a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch index b79d053..4284abf 100644 --- a/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch +++ b/sakura-server/minecraft-patches/features/0004-Slice-Packet-obfuscation-and-reduction.patch @@ -166,10 +166,10 @@ index 7031f59d7b2b07bffc44d09b9685dc3d779e3afc..b94c17c87628f2ff3aae700f731e7fa5 } diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 53fce919a6e221aa98cfb0e5a3bb9f673221535e..5cc110d0ce9b63d036e569890acc8a752f5bc477 100644 +index b6a2da9d6db99f107fa8d9703b77515cf112a604..45f08a65d8b423fbf69f66d695bb9d67cf0f2f23 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -141,7 +141,7 @@ public class FallingBlockEntity extends Entity { +@@ -142,7 +142,7 @@ public class FallingBlockEntity extends Entity { } public void setStartPos(BlockPos startPos) { diff --git a/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch b/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch index daafde9..2535b72 100644 --- a/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch +++ b/sakura-server/minecraft-patches/features/0008-Merge-Cannon-Entities.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Merge Cannon Entities diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 59a9632d8fcfacf4828ba4228c813bca730a4c17..fc70f238f551e819a610c5cf61e3fe4e6a547196 100644 +index 2ed1d5d504a69c03f4860f05e146c320cdb48a60..a4428a3c23db6f795b5ff0ead634e2e21468e3a6 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java @@ -687,6 +687,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -85,7 +85,7 @@ index 437d10c650f5aea171f2ea0d075f140d7f3cb058..4c4a662306b698112242775f9701902b if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) { // Players need to be special cased, because they are regularly removed from the world diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07efcb5c18 100644 +index 45f08a65d8b423fbf69f66d695bb9d67cf0f2f23..6f0b77e77186dd394b5949977e3e1a66610bc354 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -50,7 +50,7 @@ import net.minecraft.world.phys.HitResult; @@ -97,7 +97,7 @@ index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07 private static final Logger LOGGER = LogUtils.getLogger(); private static final BlockState DEFAULT_BLOCK_STATE = Blocks.SAND.defaultBlockState(); private static final int DEFAULT_TIME = 0; -@@ -72,11 +72,62 @@ public class FallingBlockEntity extends Entity { +@@ -72,12 +72,63 @@ public class FallingBlockEntity extends Entity { public boolean autoExpire = true; // Paper - Expand FallingBlock API public boolean heightParity; // Sakura - falling block height parity api @@ -153,6 +153,7 @@ index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07 + public FallingBlockEntity(EntityType entityType, Level level) { super(entityType, level); + this.dropItem = level.sakuraConfig().cannons.sand.dropItems; // Sakura - configure falling blocks dropping items this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics this.isFallingBlock = true; // Sakura - client visibility settings this.loadChunks = level.sakuraConfig().cannons.loadChunks; // Sakura - load chunks on movement @@ -160,7 +161,7 @@ index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07 } public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) { -@@ -236,6 +287,7 @@ public class FallingBlockEntity extends Entity { +@@ -237,6 +288,7 @@ public class FallingBlockEntity extends Entity { return; } // CraftBukkit end @@ -168,7 +169,7 @@ index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07 if (this.level().setBlock(blockPos, this.blockState, 3)) { ((ServerLevel)this.level()) .getChunkSource() -@@ -340,6 +392,7 @@ public class FallingBlockEntity extends Entity { +@@ -341,6 +393,7 @@ public class FallingBlockEntity extends Entity { compound.putBoolean("CancelDrop", this.cancelDrop); if (!this.autoExpire) compound.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API @@ -176,7 +177,7 @@ index 5cc110d0ce9b63d036e569890acc8a752f5bc477..eb2ce73058f9f95989a40ead9c215f07 } @Override -@@ -355,6 +408,7 @@ public class FallingBlockEntity extends Entity { +@@ -356,6 +409,7 @@ public class FallingBlockEntity extends Entity { this.blockData = compound.getCompound("TileEntityData").map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks this.cancelDrop = compound.getBooleanOr("CancelDrop", false); this.autoExpire = compound.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API diff --git a/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch b/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch index c2f2ad7..12b4142 100644 --- a/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch +++ b/sakura-server/minecraft-patches/features/0017-Configure-cannon-physics.patch @@ -179,7 +179,7 @@ index f7ba5db617582b16c5d101259dc60349fcdadd22..10c0bb5d1d88500e0002a726401a1831 if (this.isAlive()) { BlockState blockState = this.level().getBlockState(pos); diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f54d2fd55 100644 +index 0dc8c7a74df21e10d3eec66682d5efc61b335e61..16c22f243fcb6b5ae1b43ea112251a9b731f91c8 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -127,6 +127,43 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -226,7 +226,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f public FallingBlockEntity(EntityType entityType, Level level) { super(entityType, level); -@@ -146,6 +183,10 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -147,6 +184,10 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti this.yo = y; this.zo = z; this.setStartPos(this.blockPosition()); @@ -237,7 +237,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f } // Sakura start - falling block height parity api -@@ -178,7 +219,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -179,7 +220,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti blockState.hasProperty(BlockStateProperties.WATERLOGGED) ? blockState.setValue(BlockStateProperties.WATERLOGGED, false) : blockState ); if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit @@ -250,7 +250,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f level.addFreshEntity(fallingBlockEntity); return fallingBlockEntity; } -@@ -222,7 +267,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -223,7 +268,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @Override protected double getDefaultGravity() { @@ -259,7 +259,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f } @Override -@@ -231,6 +276,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -232,6 +277,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { Block block = this.blockState.getBlock(); @@ -272,7 +272,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f this.time++; this.applyGravity(); this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -245,8 +296,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -246,8 +297,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti } // Paper end - Configurable falling blocks height nerf this.handlePortal(); @@ -289,7 +289,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f boolean flag = this.level().sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura - configure concrete solidifying in water boolean flag1 = flag && this.level().getFluidState(blockPos).is(FluidTags.WATER); double d = this.getDeltaMovement().lengthSqr(); -@@ -273,8 +331,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -274,8 +332,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti } } else { BlockState blockState = this.level().getBlockState(blockPos); @@ -303,7 +303,7 @@ index 767bcc16b79d1a82fc9a73ab7b022c84aa66ede3..029ef84a62683fa75b4222a11d09925f if (!this.cancelDrop) { boolean canBeReplaced = blockState.canBeReplaced( new DirectionalPlaceContext(this.level(), blockPos, Direction.DOWN, ItemStack.EMPTY, Direction.UP) -@@ -343,7 +404,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -344,7 +405,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti } } diff --git a/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch b/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch index 887e8f5..2039ec1 100644 --- a/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch +++ b/sakura-server/minecraft-patches/features/0024-Configurable-left-shooting-and-adjusting-limits.patch @@ -76,10 +76,10 @@ index 06e919ddb07faa72721fd5660895abb3ad749dee..f02b6dbdfaadbbbe3d4328b77fbd29cf if (x != 0.0) { currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x); diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 029ef84a62683fa75b4222a11d09925f54d2fd55..c1884ba86be8da92c7f0168315c590eb6d7bf966 100644 +index 16c22f243fcb6b5ae1b43ea112251a9b731f91c8..cc57c4ea0ea4a39933ec6fe44c5d44bde3bc6dfb 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -284,6 +284,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti +@@ -285,6 +285,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti // Sakura end - configure cannon physics this.time++; this.applyGravity(); diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 4ddd763..e456bb0 100644 --- a/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -70,9 +_,11 @@ +@@ -70,9 +_,12 @@ public boolean forceTickAfterTeleportToDuplicate; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); public boolean autoExpire = true; // Paper - Expand FallingBlock API @@ -8,6 +8,7 @@ public FallingBlockEntity(EntityType entityType, Level level) { super(entityType, level); ++ this.dropItem = level.sakuraConfig().cannons.sand.dropItems; // Sakura - configure falling blocks dropping items + this.heightParity = level.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics } diff --git a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java index b423eea..e71f5ff 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java @@ -79,6 +79,7 @@ public final class WorldConfiguration extends ConfigurationPart { public boolean preventAgainstBorder = false; @NestedSetting({"prevent-stacking", "world-height"}) public boolean preventAtWorldHeight = false; + public boolean dropItems = true; } public Explosion explosion = new Explosion();