Skip to content

Commit

Permalink
Fix multiblock behavior when B:enableMaintenance is false (#27)
Browse files Browse the repository at this point in the history
* Whoopsies

* Whoopsies pt2
  • Loading branch information
Zorbatron authored Sep 12, 2024
1 parent e0f61df commit 150a2d4
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 44 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/zorbatron/zbgt/ZBGTCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.zorbatron.zbgt.common.block.blocks.PreciseCasing;

import gregtech.GTInternalTags;
import gregtech.api.GTValues;
import gregtech.api.GregTechAPI;
import gregtech.common.blocks.BlockMachineCasing;
import gregtech.common.blocks.MetaBlocks;

Expand Down Expand Up @@ -60,6 +62,8 @@ public void preInit(FMLPreInitializationEvent event) {
}

for (BlockMachineCasing.MachineCasingType type : BlockMachineCasing.MachineCasingType.values()) {
if (type.ordinal() > (GregTechAPI.isHighTier() ? GTValues.MAX : GTValues.UHV)) continue;

MACHINE_CASINGS.put(MetaBlocks.MACHINE_CASING.getState(type), type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
import com.zorbatron.zbgt.common.block.blocks.CoALCasing;
import com.zorbatron.zbgt.common.block.blocks.PreciseCasing;

import gregicality.multiblocks.api.capability.IParallelMultiblock;
import gregicality.multiblocks.api.metatileentity.GCYMMultiblockAbility;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.metatileentity.multiblock.MultiblockControllerBase;
import gregtech.api.pattern.PatternStringError;
import gregtech.api.pattern.TraceabilityPredicate;
import gregtech.api.recipes.RecipeMap;
import gregtech.api.util.BlockInfo;
import gregtech.common.ConfigHolder;
import gregtech.common.blocks.BlockMachineCasing;
import gregtech.common.blocks.BlockMetalCasing;
import gregtech.common.blocks.MetaBlocks;
import gregtech.common.metatileentities.MetaTileEntities;

public class TraceabilityPredicates {
Expand Down Expand Up @@ -131,6 +126,7 @@ public static TraceabilityPredicate machineCasings() {
return false;
});

@SuppressWarnings("unused")
public static TraceabilityPredicate airBlockWithCount() {
return AIR_BLOCKS_COUNTED;
}
Expand Down Expand Up @@ -169,24 +165,12 @@ public static TraceabilityPredicate autoBusesAndHatches(RecipeMap<?>[] recipeMap
return predicate;
}

@SuppressWarnings("unused")
public static TraceabilityPredicate autoBusesAndHatches(RecipeMap<?> recipeMap) {
return autoBusesAndHatches(new RecipeMap<?>[] { recipeMap });
}

public static TraceabilityPredicate maintenanceOrParallel(MultiblockControllerBase controller) {
TraceabilityPredicate predicate = new TraceabilityPredicate(
abilities(MultiblockAbility.MAINTENANCE_HATCH).setExactLimit(1));

if (controller instanceof IParallelMultiblock) {
predicate = predicate
.or(abilities(GCYMMultiblockAbility.PARALLEL_HATCH).setMaxGlobalLimited(1).setPreviewCount(1));
}

return predicate;
}

public static Supplier<?> getMaintenanceHatchMTE() {
return () -> ConfigHolder.machines.enableMaintenance ? MetaTileEntities.MAINTENANCE_HATCH :
MetaBlocks.METAL_CASING.getState(BlockMetalCasing.MetalCasingType.INVAR_HEATPROOF);
public static Supplier<?> getMaintenanceHatchMTE(IBlockState defaultCasing) {
return () -> ConfigHolder.machines.enableMaintenance ? MetaTileEntities.MAINTENANCE_HATCH : defaultCasing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,8 @@ protected BlockPattern createStructurePattern() {
.where('B', states(getAssemblyControlState()))
.where('P', states(getPipeCasingState()))
.where('C', states(getCasingState()).setMinGlobalLimited(630)
.or(autoEnergyInputs())
.or(maintenanceOrParallel(this))
.or(autoBusesAndHatches(getRecipeMap()))
.or(abilities(MultiblockAbility.COMPUTATION_DATA_RECEPTION)
.setExactLimit(1)))
.or(abilities(MultiblockAbility.COMPUTATION_DATA_RECEPTION).setExactLimit(1))
.or(autoAbilities(true, true, true, true, true, true, false)))
.where('#', air())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
.where('M', abilities(MultiblockAbility.MUFFLER_HATCH))
.where('C', heatingCoils())
.where('W', states(getCasingState())
.or(TraceabilityPredicates.maintenanceOrParallel(this)))
.or(autoAbilities(false, true, false, false, false, false, false)))
.where('#', air())
.build();
}
Expand Down Expand Up @@ -195,7 +195,7 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
"###########", "###########", "###########", "###########", "###########", "###########",
"###########", "###########")
.where('S', ZBGTMetaTileEntities.MEGA_ABS, EnumFacing.SOUTH)
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(), EnumFacing.SOUTH)
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(getCasingState()), EnumFacing.SOUTH)
.where('P', GCYMMetaTileEntities.PARALLEL_HATCH[0], EnumFacing.SOUTH)
.where('X', getCasingState())
.where('V', getVentState())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('X', getCasingState())
.where('G', getGlassState())
.where('M', MetaTileEntities.MUFFLER_HATCH[1], EnumFacing.UP)
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(), EnumFacing.SOUTH)
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(getCasingState()), EnumFacing.SOUTH)
.where('E', MetaTileEntities.ENERGY_INPUT_HATCH[1], EnumFacing.NORTH)
.where('I', MetaTileEntities.ITEM_IMPORT_BUS[1], EnumFacing.SOUTH)
.where('O', MetaTileEntities.ITEM_EXPORT_BUS[1], EnumFacing.SOUTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.metatileentity.multiblock.IMultiblockPart;
import gregtech.api.metatileentity.multiblock.MultiblockAbility;
import gregtech.api.pattern.BlockPattern;
import gregtech.api.pattern.FactoryBlockPattern;
import gregtech.api.recipes.RecipeMaps;
Expand Down Expand Up @@ -59,7 +58,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
.where('#', air())
.where('G', states(getGlassState()))
.where('F', states(getCoilState()))
.where('M', abilities(MultiblockAbility.MAINTENANCE_HATCH))
.where('M', maintenancePredicate())
.where('E', states(getCasingState())
.or(autoEnergyInputs(1, 8)))
.where('H', states(getCasingState())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('S', ZBGTMetaTileEntities.MEGA_OCU, EnumFacing.SOUTH)
.where('G', getGlassState())
.where('X', getCasingState())
.where('M', TraceabilityPredicates.getMaintenanceHatchMTE(), EnumFacing.SOUTH)
.where('M', TraceabilityPredicates.getMaintenanceHatchMTE(getCasingState()), EnumFacing.SOUTH)
.where('P', GCYMMetaTileEntities.PARALLEL_HATCH[0], EnumFacing.SOUTH)
.where('E', MetaTileEntities.ENERGY_INPUT_HATCH[1], EnumFacing.NORTH)
.where('I', MetaTileEntities.FLUID_IMPORT_HATCH[1], EnumFacing.WEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,20 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('G', MetaBlocks.TRANSPARENT_CASING.getState(BlockGlassCasing.CasingType.TEMPERED_GLASS))
.where('F', MetaBlocks.FRAMES.get(Materials.TungstenSteel).getBlock(Materials.TungstenSteel))
.where('E', MetaTileEntities.ENERGY_INPUT_HATCH[GTValues.LV], EnumFacing.SOUTH)
.where('M', TraceabilityPredicates.getMaintenanceHatchMTE(),
EnumFacing.SOUTH)
.where('#', Blocks.AIR.getDefaultState());

ZBGTAPI.MACHINE_CASINGS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().ordinal()))
.forEach(entry -> shapeInfo.add(builder
.where('H', entry.getKey())
.where('X',
ZBGTMetaBlocks.PRECISE_CASING.getState(
PreciseCasing.CasingType.getCasingByTier(entry.getValue().ordinal())))
.build()));
.forEach(entry -> {
IBlockState preciseCasingState = ZBGTMetaBlocks.PRECISE_CASING
.getState(PreciseCasing.CasingType.getCasingByTier(entry.getValue().ordinal()));
shapeInfo.add(builder
.where('H', entry.getKey())
.where('X', preciseCasingState)
.where('M', TraceabilityPredicates.getMaintenanceHatchMTE(preciseCasingState),
EnumFacing.SOUTH)
.build());
});

return shapeInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.aisle("XISOX", "CCCCC", "CCCCC", "XXZXX")
.where('S', ZBGTMetaTileEntities.QUAD_EBF, EnumFacing.SOUTH)
.where('X', getCasingState())
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(), EnumFacing.SOUTH)
.where('Z', TraceabilityPredicates.getMaintenanceHatchMTE(getCasingState()), EnumFacing.SOUTH)
.where('M', MetaTileEntities.MUFFLER_HATCH[GTValues.LV], EnumFacing.UP)
.where('I', MetaTileEntities.ITEM_IMPORT_BUS[1], EnumFacing.SOUTH)
.where('O', MetaTileEntities.ITEM_EXPORT_BUS[1], EnumFacing.SOUTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.jetbrains.annotations.NotNull;

import com.zorbatron.zbgt.api.pattern.TraceabilityPredicates;

import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.interfaces.IGregTechTileEntity;
import gregtech.api.metatileentity.multiblock.IMultiblockPart;
Expand Down Expand Up @@ -46,8 +44,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
.aisle("XXXXX", "XXXXX", "XXXXX", "XXXXX", "XXXXX")
.where('S', selfPredicate())
.where('X', states(getCasingState())
.or(TraceabilityPredicates.autoBusesAndHatches(getRecipeMap()))
.or(TraceabilityPredicates.maintenanceOrParallel(this))
.or(autoAbilities(false, true, true, true, true, true, false))
.or(abilities(MultiblockAbility.INPUT_ENERGY)
.setMinGlobalLimited(1)
.setMaxGlobalLimited(8)
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/zbgt/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ zbgt.multiblock.pattern.coal_tier=§cAll casings must be the same tier§r

zbgt.multiblock.pattern.error.casings=§cAll casings must be the same tier§r

zbgt.multiblock.pattern.error.machine_casings=§cAll machine casings must be the same tier§r

# Random
zbgt.laser_enabled.1=Can use
zbgt.laser_enabled.2= Laser Hatches
Expand Down

0 comments on commit 150a2d4

Please sign in to comment.