From 1bc38d75744bc3b706578c09e4aa029bd444e2a0 Mon Sep 17 00:00:00 2001 From: RecursivePineapple Date: Thu, 29 Aug 2024 11:24:01 -0400 Subject: 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 Co-authored-by: boubou19 Co-authored-by: Martin Robertz --- .../gregtech/api/util/GT_StructureUtility.java | 107 +++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'src/main/java/gregtech/api/util') 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 IStructureElement ofSolenoidCoil(BiConsumer aSolenoidTierSetter, + Function 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 IStructureElement ofSolenoidCoil(BiPredicate aSolenoidTierSetter, + Function 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 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 filterByMTEClass(List> list) { return is -> { -- cgit