diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2024-08-16 09:14:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-16 01:14:09 +0000 |
commit | 54f98cd732f1ce1dc5a8a6ed69490a25d676c8b1 (patch) | |
tree | ad7048b0a0e4acf5eacb3a37b75b9b0b43f60618 /src/main/java/gregtech/api/util | |
parent | 5decfda1dd1b3bbfdb1098f409aa50162ea32dc2 (diff) | |
download | GT5-Unofficial-54f98cd732f1ce1dc5a8a6ed69490a25d676c8b1.tar.gz GT5-Unofficial-54f98cd732f1ce1dc5a8a6ed69490a25d676c8b1.tar.bz2 GT5-Unofficial-54f98cd732f1ce1dc5a8a6ed69490a25d676c8b1.zip |
makeshift solution of skipping gt hatches (#2881)
* makeshift solution of telling structurelib to not place gt hatches
* Spotless apply for branch feature/gt-no-hatch for #2881 (#2882)
spotlessApply
Co-authored-by: GitHub GTNH Actions <>
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_HatchElementBuilder.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java index 2087ad755c..416edc9c11 100644 --- a/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java +++ b/src/main/java/gregtech/api/util/GT_HatchElementBuilder.java @@ -27,6 +27,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.constructable.ChannelDataAccessor; import com.gtnewhorizon.structurelib.structure.AutoPlaceEnvironment; import com.gtnewhorizon.structurelib.structure.IItemSource; import com.gtnewhorizon.structurelib.structure.IStructureElement; @@ -57,6 +58,7 @@ public class GT_HatchElementBuilder<T> { private Predicate<? super T> mReject; private boolean mCacheHint; private boolean mNoStop; + private boolean mExclusive; private EnumSet<ForgeDirection> mDisallowedDirection = EnumSet.noneOf(ForgeDirection.class); private GT_HatchElementBuilder() {} @@ -173,6 +175,19 @@ public class GT_HatchElementBuilder<T> { // region primitives + /** + * Mark this hatch element as the only candidate of given structure element. (e.g. muffler hatch on top of EBF) + * Currently, this will make the built IStructureElement to ignore gt_no_hatch directive from player + * + * Do note that {@link #buildAndChain(IStructureElement[])} and its overloads will force the resulting structure + * element + * to be non-exclusive. + */ + public GT_HatchElementBuilder<T> exclusive() { + mExclusive = true; + return this; + } + public GT_HatchElementBuilder<T> adder(IGT_HatchAdder<? super T> aAdder) { if (aAdder == null) throw new IllegalArgumentException(); mAdder = aAdder; @@ -360,6 +375,8 @@ public class GT_HatchElementBuilder<T> { @SuppressWarnings("unchecked") @SafeVarargs public final IStructureElementChain<T> buildAndChain(IStructureElement<T>... elements) { + // just in case + mExclusive = false; List<IStructureElement<T>> l = new ArrayList<>(); l.add(build()); l.addAll(Arrays.asList(elements)); @@ -462,6 +479,12 @@ public class GT_HatchElementBuilder<T> { if (!StructureLibAPI.isBlockTriviallyReplaceable(world, x, y, z, env.getActor())) return PlaceResult.REJECT; if (mReject != null && mReject.test(t)) return PlaceResult.REJECT; + if (ChannelDataAccessor.hasSubChannel(trigger, "gt_no_hatch") && !mExclusive) { + String type = getHint(); + env.getChatter() + .accept(new ChatComponentTranslation("GT5U.autoplace.error.no_hatch", type)); + return PlaceResult.REJECT; + } ItemStack taken = env.getSource() .takeOne(mHatchItemFilter.apply(t, trigger), true); if (GT_Utility.isStackInvalid(taken)) { |