Skip to content

Commit

Permalink
Allow megas that usually need mufflers to not
Browse files Browse the repository at this point in the history
  • Loading branch information
Zorbatron committed Oct 29, 2024
1 parent c078dee commit 83643dc
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 16 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/zorbatron/zbgt/common/ZBGTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ public static class MultiblockSettings {
@Config.RangeInt(min = 1, max = 255)
@Config.Name("Overridden PSS Height")
public int overriddenPSSHeight = 18;

@Config.RequiresMcRestart
@Config.Comment({
"Require mega multiblocks to have muffler hatches.",
"Due to how muffler hatches are implemented, it rolls the byproduct chance per parallel.",
"So if you have 1 million parallels, its going to loop a randomizer function 1 million times which is quite bad for TPS.",
"Default: true" })
@Config.Name("Megas Need Mufflers")
public boolean megasNeedMufflers = true;
}

@Config.Name("Recipe Settings")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.zorbatron.zbgt.api.metatileentity.LaserCapableGCYMRecipeMapMultiblockController;
import com.zorbatron.zbgt.api.pattern.TraceabilityPredicates;
import com.zorbatron.zbgt.api.render.ZBGTTextures;
import com.zorbatron.zbgt.common.ZBGTConfig;
import com.zorbatron.zbgt.common.metatileentities.ZBGTMetaTileEntities;

import gregicality.multiblocks.api.recipes.GCYMRecipeMaps;
Expand Down Expand Up @@ -71,7 +72,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {

@Override
protected @NotNull BlockPattern createStructurePattern() {
return FactoryBlockPattern.start()
FactoryBlockPattern pattern = FactoryBlockPattern.start()
.aisle("###BBBBB###", "###VVVVV###", "###GGGGG###", "###GGGGG###", "###GGGGG###", "###VVVVV###",
"###XXXXX###", "###########", "###########", "###########", "###########", "###########",
"###########", "###########", "###########", "###########", "###########", "###########",
Expand Down Expand Up @@ -117,19 +118,24 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
"###########", "###########", "###########", "###########", "###########", "###########",
"###########", "###########")
.where('S', selfPredicate())
.where('B',
states(getCasingState())
.or(TraceabilityPredicates.autoBusesAndHatches(getAvailableRecipeMaps()))
.or(autoEnergyInputsMega()))
.where('B', states(getCasingState())
.or(TraceabilityPredicates.autoBusesAndHatches(getAvailableRecipeMaps()))
.or(autoEnergyInputsMega()))
.where('X', states(getCasingState()))
.where('V', states(getVentState()))
.where('G', states(getGlassState()))
.where('M', abilities(MultiblockAbility.MUFFLER_HATCH))
.where('C', heatingCoils())
.where('W', states(getCasingState())
.or(autoAbilities(false, true, false, false, false, false, false)))
.where('#', air())
.build();
.where('#', air());

if (ZBGTConfig.multiblockSettings.megasNeedMufflers) {
pattern.where('M', abilities(MultiblockAbility.MUFFLER_HATCH));
} else {
pattern.where('M', states(getCasingState()));
}

return pattern.build();
}

protected IBlockState getCasingState() {
Expand Down Expand Up @@ -200,7 +206,6 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('X', getCasingState())
.where('V', getVentState())
.where('G', getGlassState())
.where('M', MetaTileEntities.MUFFLER_HATCH[1], EnumFacing.UP)
.where('W', getCasingState())
.where('X', getCasingState())
.where('I', MetaTileEntities.ITEM_IMPORT_BUS[1], EnumFacing.SOUTH)
Expand All @@ -210,6 +215,12 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('D', MetaTileEntities.ENERGY_INPUT_HATCH[1], EnumFacing.WEST)
.where('#', Blocks.AIR.getDefaultState());

if (ZBGTConfig.multiblockSettings.megasNeedMufflers) {
builder.where('M', MetaTileEntities.MUFFLER_HATCH[1], EnumFacing.UP);
} else {
builder.where('M', getCasingState());
}

GregTechAPI.HEATING_COILS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().getTier()))
.forEach(entry -> shapeInfo.add(builder.where('C', entry.getKey()).build()));
Expand Down Expand Up @@ -284,7 +295,7 @@ public boolean checkRecipe(@NotNull Recipe recipe, boolean consumeIfSuccess) {

@Override
public boolean hasMufflerMechanics() {
return true;
return ZBGTConfig.multiblockSettings.megasNeedMufflers;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.zorbatron.zbgt.api.metatileentity.LaserCapableGCYMRecipeMapMultiblockController;
import com.zorbatron.zbgt.api.pattern.TraceabilityPredicates;
import com.zorbatron.zbgt.api.render.ZBGTTextures;
import com.zorbatron.zbgt.common.ZBGTConfig;
import com.zorbatron.zbgt.common.metatileentities.ZBGTMetaTileEntities;

import gregicality.multiblocks.common.metatileentities.GCYMMetaTileEntities;
Expand Down Expand Up @@ -72,7 +73,7 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {

@Override
protected @NotNull BlockPattern createStructurePattern() {
return FactoryBlockPattern.start()
FactoryBlockPattern pattern = FactoryBlockPattern.start()
.aisle("XXXXXXXXXXXXXXX", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG",
"GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG",
"GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG", "GGGGGGGGGGGGGGG",
Expand Down Expand Up @@ -138,10 +139,16 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
.or(autoAbilities(false, true, true, true, true, true, false))
.or(autoEnergyInputsMega()))
.where('G', states(getGlassState()))
.where('M', abilities(MultiblockAbility.MUFFLER_HATCH))
.where('C', heatingCoils())
.where('#', air())
.build();
.where('#', air());

if (ZBGTConfig.multiblockSettings.megasNeedMufflers) {
pattern.where('M', abilities(MultiblockAbility.MUFFLER_HATCH));
} else {
pattern.where('M', states(getCasingState()));
}

return pattern.build();
}

protected IBlockState getCasingState() {
Expand Down Expand Up @@ -220,13 +227,18 @@ public List<MultiblockShapeInfo> getMatchingShapes() {
.where('S', ZBGTMetaTileEntities.MEGA_EBF, EnumFacing.SOUTH)
.where('X', getCasingState())
.where('G', getGlassState())
.where('M', MetaTileEntities.MUFFLER_HATCH[1], EnumFacing.UP)
.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)
.where('P', GCYMMetaTileEntities.PARALLEL_HATCH[0], EnumFacing.SOUTH);

if (ZBGTConfig.multiblockSettings.megasNeedMufflers) {
builder.where('M', MetaTileEntities.MUFFLER_HATCH[1], EnumFacing.UP);
} else {
builder.where('M', getCasingState());
}

GregTechAPI.HEATING_COILS.entrySet().stream()
.sorted(Comparator.comparingInt(entry -> entry.getValue().getTier()))
.forEach(entry -> shapeInfo.add(builder.where('C', entry.getKey()).build()));
Expand Down Expand Up @@ -290,7 +302,7 @@ public boolean canBeDistinct() {

@Override
public boolean hasMufflerMechanics() {
return true;
return ZBGTConfig.multiblockSettings.megasNeedMufflers;
}

@Override
Expand Down

0 comments on commit 83643dc

Please sign in to comment.