9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2026-01-06 15:41:49 +00:00

Configure falling blocks dropping items

This commit is contained in:
Samsuik
2025-05-03 19:04:33 +01:00
parent a6e391d6a7
commit 9bc7feb4c4
8 changed files with 28 additions and 25 deletions

View File

@@ -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<? extends FallingBlockEntity> 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
}

View File

@@ -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

View File

@@ -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) {

View File

@@ -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<? extends FallingBlockEntity> 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

View File

@@ -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<? extends FallingBlockEntity> 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
}
}

View File

@@ -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();

View File

@@ -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<BlockPos> 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<? extends FallingBlockEntity> 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
}

View File

@@ -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();