From c19ac860d4ab00c028a335cb977b046aab7ad50b Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 12 Aug 2022 19:57:24 +0800 Subject: [PATCH] fix too lenient should skip check in ofBlocksTiered --- .../alignment/constructable/ConstructableUtility.java | 8 +++----- .../structurelib/structure/StructureUtility.java | 9 ++++++++- src/main/resources/assets/structurelib/lang/en_US.lang | 1 + 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gtnewhorizon/structurelib/alignment/constructable/ConstructableUtility.java b/src/main/java/com/gtnewhorizon/structurelib/alignment/constructable/ConstructableUtility.java index 994b54c7..4422d01e 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/alignment/constructable/ConstructableUtility.java +++ b/src/main/java/com/gtnewhorizon/structurelib/alignment/constructable/ConstructableUtility.java @@ -76,11 +76,9 @@ public class ConstructableUtility { } else if (constructable instanceof ISurvivalConstructable) { int built = ((ISurvivalConstructable) constructable) .survivalConstruct(aStack, BUDGET, IItemSource.fromPlayer(playerMP), playerMP); - if (built > 0) - // TODO somehow notify extensions that their inventory might have been modified and need to be - // synced to client or saved - playerMP.inventory.markDirty(); - else if (built == -1) { + if (built > 0) { + playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.built_stat", built)); + } else if (built == -1) { playerMP.addChatMessage(new ChatComponentTranslation("structurelib.autoplace.complete")); } setLastUseTickToStackTag(aStack); diff --git a/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java b/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java index 1c99531d..cb1991b4 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java +++ b/src/main/java/com/gtnewhorizon/structurelib/structure/StructureUtility.java @@ -427,9 +427,16 @@ public class StructureUtility { IItemSource s, EntityPlayerMP actor, Consumer chatter) { - if (check(t, world, x, y, z)) return PlaceResult.SKIP; Pair hint = getHint(trigger); if (hint == null) return PlaceResult.REJECT; // TODO or SKIP? + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + TIER tier = tierExtractor.convert(block, meta); + if (!Objects.equals(tier, notSet)) { + return Objects.equals(tier, tierExtractor.convert(hint.getKey(), hint.getValue())) + ? PlaceResult.SKIP + : PlaceResult.REJECT; + } return StructureUtility.survivalPlaceBlock( hint.getKey(), hint.getValue(), world, x, y, z, s, actor, chatter); } diff --git a/src/main/resources/assets/structurelib/lang/en_US.lang b/src/main/resources/assets/structurelib/lang/en_US.lang index 435002da..450cbb76 100644 --- a/src/main/resources/assets/structurelib/lang/en_US.lang +++ b/src/main/resources/assets/structurelib/lang/en_US.lang @@ -28,6 +28,7 @@ item.structurelib.constructableTrigger.desc.3=(Sneak use on controller to build) item.structurelib.constructableTrigger.desc.4=Quantity of schematics in item stack affects tier/mode/type item.structurelib.constructableTrigger.too_fast=Please wait %d ticks before another autoplace... +structurelib.autoplace.built_stat=Built %s blocks structurelib.autoplace.complete=§aThis multiblock has completed! structurelib.autoplace.error.not_enabled=§cThis multiblock does not support autoplace in survival! structurelib.autoplace.error.no_simple_block=§cSuggested to place §r%s§c but none was found