Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow megas that usually need mufflers to not if it gets too laggy #78

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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