From 4f96c9c25ac56eff4da3e5cf397e08e6c967c7ae Mon Sep 17 00:00:00 2001 From: iqtester <1835ww@gmail.com> Date: Mon, 22 Sep 2025 06:39:52 -0400 Subject: [PATCH] feat(BushBlockBehavior): max-height --- .../block/behavior/BushBlockBehavior.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BushBlockBehavior.java b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BushBlockBehavior.java index 7cb60c452..bace95fe2 100644 --- a/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BushBlockBehavior.java +++ b/bukkit/src/main/java/net/momirealms/craftengine/bukkit/block/behavior/BushBlockBehavior.java @@ -26,13 +26,13 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior { protected final Set customBlocksCansSurviveOn; protected final boolean blacklistMode; protected final boolean stackable; - protected final int stackableAmount; + protected final int maxHeight; - public BushBlockBehavior(CustomBlock block, int delay, boolean blacklist, boolean stackable, int stackableAmount, List tagsCanSurviveOn, Set blockStatesCanSurviveOn, Set customBlocksCansSurviveOn) { + public BushBlockBehavior(CustomBlock block, int delay, boolean blacklist, boolean stackable, int maxHeight, List tagsCanSurviveOn, Set blockStatesCanSurviveOn, Set customBlocksCansSurviveOn) { super(block, delay); this.blacklistMode = blacklist; this.stackable = stackable; - this.stackableAmount = stackableAmount; + this.maxHeight = maxHeight; this.tagsCanSurviveOn = tagsCanSurviveOn; this.blockStatesCanSurviveOn = blockStatesCanSurviveOn; this.customBlocksCansSurviveOn = customBlocksCansSurviveOn; @@ -44,10 +44,10 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior { public BlockBehavior create(CustomBlock block, Map arguments) { Tuple, Set, Set> tuple = readTagsAndState(arguments, false); boolean stackable = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("stackable", false), "stackable"); - int stackableAmount = ResourceConfigUtils.getAsInt(arguments.getOrDefault("stackable-amount", 0), "stackable-amount"); + int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 0), "max-height"); int delay = ResourceConfigUtils.getAsInt(arguments.getOrDefault("delay", 0), "delay"); boolean blacklistMode = ResourceConfigUtils.getAsBoolean(arguments.getOrDefault("blacklist", false), "blacklist"); - return new BushBlockBehavior(block, delay, blacklistMode, stackable, stackableAmount,tuple.left(), tuple.mid(), tuple.right()); + return new BushBlockBehavior(block, delay, blacklistMode, stackable, maxHeight,tuple.left(), tuple.mid(), tuple.right()); } } @@ -99,8 +99,8 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior { } else { ImmutableBlockState belowCustomState = optionalCustomState.get(); if (belowCustomState.owner().value() == super.customBlock) { - if (!stackable) return false; - if (this.stackableAmount > 0) { + if (!this.stackable || this.maxHeight == 1) return false; + if (this.maxHeight > 1) { return mayStackOn(world, belowPos); } return true; @@ -116,10 +116,10 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior { } protected boolean mayStackOn(Object world, Object belowPos) { - int count = 0; - Object cursorPos = belowPos; + int count = 1; + Object cursorPos = LocationUtils.below(belowPos); - while (count <= this.stackableAmount) { + while (count < this.maxHeight) { Object belowState = FastNMS.INSTANCE.method$BlockGetter$getBlockState(world, cursorPos); Optional belowCustomState = BlockStateUtils.getOptionalCustomBlockState(belowState); if (belowCustomState.isPresent() && belowCustomState.get().owner().value() == super.customBlock) { @@ -129,6 +129,6 @@ public class BushBlockBehavior extends AbstractCanSurviveBlockBehavior { break; } } - return count <= this.stackableAmount; + return count < this.maxHeight; } }