9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-28 19:29:07 +00:00

Fix falling block stacking restrictions when using legacy physics

This commit is contained in:
Samsuik
2025-01-26 11:26:13 +00:00
parent 504fba13ab
commit db70cd2d02
6 changed files with 41 additions and 24 deletions

View File

@@ -595,10 +595,10 @@ index 0000000000000000000000000000000000000000..94dd734ca4049354f925af1736bda57c
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c4e4ac7f85e7fca6ecf7606cf8304736bd51d3b
index 0000000000000000000000000000000000000000..b61e1581b3de1bae39492598afb196e3f00c386e
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -0,0 +1,243 @@
@@ -0,0 +1,238 @@
+package me.samsuik.sakura.configuration;
+
+import com.mojang.logging.LogUtils;
@@ -680,11 +680,6 @@ index 0000000000000000000000000000000000000000..6c4e4ac7f85e7fca6ecf7606cf830473
+ public boolean preventAgainstBorder = false;
+ @NestedSetting({"prevent-stacking", "world-height"})
+ public boolean preventAtWorldHeight = false;
+
+ public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
+ return (!this.preventAgainstBorder || !ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01)))
+ && (!this.preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxBuildHeight() - 1);
+ }
+ }
+
+ public Explosion explosion = new Explosion();

View File

@@ -5,15 +5,37 @@ Subject: [PATCH] Falling Block Stacking Restrictions
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index e7c6074a83be4d93367c7465b74d79b4c00d1afd..b5ce3bbce3cc71bab5ec5e9c1c42e7b7a2cdefa3 100644
index 46275a3c459739152c4e2e0b852ae3627aa59f9a..449ab2332875ea652a5ba52ddb18098a7405a1e4 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -258,7 +258,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -149,6 +149,21 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
this.setStartPos(this.blockPosition());
}
+ // Sakura start - falling block stacking restrictions
+ private static boolean isFallingBlockInBounds(Level level, BlockPos blockPosition) {
+ if (level.sakuraConfig().cannons.sand.preventAtWorldHeight && blockPosition.getY() >= level.getMaxBuildHeight() - 1) {
+ return false;
+ }
+
+ Vec3 center = blockPosition.getBottomCenter();
+ if (level.sakuraConfig().cannons.sand.preventAgainstBorder && !level.getWorldBorder().isWithinBounds(center.x(), center.z(), -1.0)) {
+ return false;
+ }
+
+ return true;
+ }
+ // Sakura end - falling block stacking restrictions
+
public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) {
// CraftBukkit start
return FallingBlockEntity.fall(world, pos, state, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
@@ -258,7 +273,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1);
boolean flag4 = this.blockState.canSurvive(this.level(), blockposition) && !flag3;
- if (flag2 && flag4) {
+ if (flag2 && flag4 && level().sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura
+ if (flag2 && flag4 && isFallingBlockInBounds(this.level(), blockposition)) { // Sakura - falling block stacking restrictions
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level().getFluidState(blockposition).getType() == Fluids.WATER) {
this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
}

View File

@@ -253,7 +253,7 @@ index c1c1737bc7f57b7112567fe22a31c964cf4d10f7..ba94f23803adc9b83e46a7ed936e1780
if (this.level().hasChunksAt(blockposition, blockposition1)) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b59979f673ac4 100644
index 449ab2332875ea652a5ba52ddb18098a7405a1e4..224791310044b90f8436862a406d0521e6d15b34 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -147,6 +147,8 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -264,8 +264,8 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
+ this.eyeHeight = this.physics.isLegacy() ? 0.49f : this.eyeHeight; // Sakura - physics version api
}
public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) {
@@ -159,7 +161,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
// Sakura start - falling block stacking restrictions
@@ -174,7 +176,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) iblockdata.setValue(BlockStateProperties.WATERLOGGED, false) : iblockdata);
if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
@@ -278,7 +278,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
return entityfallingblock;
}
@@ -198,10 +204,47 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -213,10 +219,47 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return this.heightParity ? this.getY() : super.getEyeY();
}
// Sakura end - configure cannon mechanics
@@ -327,7 +327,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
}
@Override
@@ -211,6 +254,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -226,6 +269,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} else {
Block block = this.blockState.getBlock();
@@ -339,7 +339,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
++this.time;
this.applyGravity();
this.moveStripped(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise cannon entity movement
@@ -225,8 +273,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -240,8 +288,15 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
}
// Paper end - Configurable falling blocks height nerf
this.handlePortal();
@@ -356,7 +356,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();
@@ -251,8 +306,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -266,8 +321,11 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} else {
BlockState iblockdata = this.level().getBlockState(blockposition);
@@ -370,7 +370,7 @@ index 92d8b64f18cf7ac854a021e06102dad9932bfba0..a08123d67a43f9de5706dda22f3b5997
if (!this.cancelDrop) {
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1);
@@ -319,7 +377,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -334,7 +392,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
}
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configure concrete solidifying in water
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index bb6bd75645d18933f6d1b5c68a33f28e30b5ac2d..89bdc1db40227ead1675645ec7711874a75ca9ca 100644
index 224791310044b90f8436862a406d0521e6d15b34..da09c5a3c80e580e15ff8a98445c8329616629bb 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -282,7 +282,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -297,7 +297,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
// However, it makes sense for legacy versions pre-1.17 before the world height change.
BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition();
// Sakura end - physics version api

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] Fix doEntityDrops gamerule preventing falling blocks from
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 89bdc1db40227ead1675645ec7711874a75ca9ca..00f35010f927cfbe7e41131b1404b7ca92ebf6bd 100644
index da09c5a3c80e580e15ff8a98445c8329616629bb..eeca55d482787ff4f032db46a6934e98865f14aa 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -357,10 +357,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -372,10 +372,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
tileentity.setChanged();
}
}

View File

@@ -76,10 +76,10 @@ index 11c91e62ad71fbe8b22e417c6d942c8d0849a863..2201bd3639482ec0e6f01b4f991bb4ab
if (x != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 87a5e151895c7fac32afc3b44088e5e75856dcd7..d722542fd1295669208946daa839c12cdf6886a9 100644
index eeca55d482787ff4f032db46a6934e98865f14aa..6d13b037a4e2c0d677c1cb4b39cf6d50c659c87e 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -261,6 +261,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -276,6 +276,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
// Sakura end - physics version api
++this.time;
this.applyGravity();