aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorRecursivePineapple <recursive_pineapple@proton.me>2024-08-29 11:24:01 -0400
committerGitHub <noreply@github.com>2024-08-29 15:24:01 +0000
commit1bc38d75744bc3b706578c09e4aa029bd444e2a0 (patch)
tree16132194916022296105b7ce995cf004baee80ff /src/main/java/gregtech/api/util
parent03f8ac57b99f8fa26975151ad39cb1a78667db73 (diff)
downloadGT5-Unofficial-1bc38d75744bc3b706578c09e4aa029bd444e2a0.tar.gz
GT5-Unofficial-1bc38d75744bc3b706578c09e4aa029bd444e2a0.tar.bz2
GT5-Unofficial-1bc38d75744bc3b706578c09e4aa029bd444e2a0.zip
Added large fluid extractor multi (#2819)
* Added large fluid extractor multi * ran spotless * Prevent multi from requesting more than 1A with 1 energy hatch * Moved boro. glass registration to bartworks In GT5u dev environments, borosilicate glass wasn't registered properly. The block was registered, but it wasn't added to allLevelsReverse since registerGlass() was never called. This led to getTier() not working properly (it always returned tier=3). * Changed speed bonuses and added some QoL changes Added a multiplication EU/t cost to solenoid tiers and buffed solenoid parallels. Added an additive EU/t reduction to heating coil tiers. Fixed the glass structure check. Updated the multi's tooltip and sensor info data. * applied spotless * large fluid extractor code cleanup * changed mechanics & improved structure messages * spotless apply --------- Co-authored-by: Mary Hopson <doyoumined@gmail.com> Co-authored-by: boubou19 <miisterunknown@gmail.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_StructureUtility.java107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java
index ad3e4e9876..6bbb3e1223 100644
--- a/src/main/java/gregtech/api/util/GT_StructureUtility.java
+++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java
@@ -47,6 +47,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock;
import gregtech.common.blocks.GT_Block_Casings5;
import gregtech.common.blocks.GT_Block_FrameBox;
+import gregtech.common.blocks.GT_Cyclotron_Coils;
import gregtech.common.blocks.GT_Item_Machines;
public class GT_StructureUtility {
@@ -490,6 +491,112 @@ public class GT_StructureUtility {
};
}
+ /**
+ * Assumes all solenoids are accepted.
+ *
+ * @see #ofSolenoidCoil(BiPredicate, Function)
+ */
+ public static <T> IStructureElement<T> ofSolenoidCoil(BiConsumer<T, Byte> aSolenoidTierSetter,
+ Function<T, Byte> aSolenoidTierGetter) {
+ return ofSolenoidCoil((t, l) -> {
+ aSolenoidTierSetter.accept(t, l);
+ return true;
+ }, aSolenoidTierGetter);
+ }
+
+ /**
+ * Solenoid coil structure element.
+ *
+ * @param aSolenoidTierSetter Notify the controller of this new solenoid. Got called exactly once per solenoid.
+ * Might be
+ * called less times if structure test fails. If the setter returns false then it assumes
+ * the solenoid is rejected.
+ * @param aSolenoidTierGetter Get the solenoid voltage tier. Null means no tier recorded yet.
+ */
+ public static <T> IStructureElement<T> ofSolenoidCoil(BiPredicate<T, Byte> aSolenoidTierSetter,
+ Function<T, Byte> aSolenoidTierGetter) {
+ if (aSolenoidTierSetter == null || aSolenoidTierGetter == null) {
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElement<>() {
+
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ Block block = world.getBlock(x, y, z);
+
+ if (block != GregTech_API.sSolenoidCoilCasings) return false;
+
+ var coils = ((GT_Cyclotron_Coils) GregTech_API.sSolenoidCoilCasings);
+
+ Byte existingLevel = aSolenoidTierGetter.apply(t);
+ byte newLevel = (byte) (coils.getVoltageTier(world.getBlockMetadata(x, y, z)));
+
+ if (existingLevel == null) {
+ return aSolenoidTierSetter.test(t, newLevel);
+ } else {
+ return newLevel == existingLevel;
+ }
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI
+ .hintParticle(world, x, y, z, GregTech_API.sSolenoidCoilCasings, getMetaFromHint(trigger));
+ return true;
+ }
+
+ private int getMetaFromHint(ItemStack trigger) {
+ return Math.min(Math.max(trigger.stackSize - 1, 0), 10);
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ return world.setBlock(x, y, z, GregTech_API.sSolenoidCoilCasings, getMetaFromHint(trigger), 3);
+ }
+
+ @Override
+ public BlocksToPlace getBlocksToPlace(T t, World world, int x, int y, int z, ItemStack trigger,
+ AutoPlaceEnvironment env) {
+ return BlocksToPlace.create(GregTech_API.sSolenoidCoilCasings, getMetaFromHint(trigger));
+ }
+
+ @Override
+ public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
+ IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
+ return survivalPlaceBlock(
+ t,
+ world,
+ x,
+ y,
+ z,
+ trigger,
+ AutoPlaceEnvironment.fromLegacy(s, actor, chatter));
+ }
+
+ @Override
+ public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
+ AutoPlaceEnvironment env) {
+ Block block = world.getBlock(x, y, z);
+
+ boolean isCoil = block == GregTech_API.sSolenoidCoilCasings
+ && world.getBlockMetadata(x, y, z) == getMetaFromHint(trigger);
+
+ if (isCoil) return SKIP;
+
+ return StructureUtility.survivalPlaceBlock(
+ GregTech_API.sSolenoidCoilCasings,
+ getMetaFromHint(trigger),
+ world,
+ x,
+ y,
+ z,
+ env.getSource(),
+ env.getActor(),
+ env.getChatter());
+ }
+ };
+ }
+
@Nonnull
public static Predicate<ItemStack> filterByMTEClass(List<? extends Class<? extends IMetaTileEntity>> list) {
return is -> {