9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-28 11:19:08 +00:00
Files
SakuraMC/patches/server/0031-Falling-Block-Stacking-Restrictions.patch
2025-03-07 17:37:50 +00:00

42 lines
2.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 16 Nov 2023 20:53:51 +0000
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 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
@@ -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 && 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);
}