Skip to content

Commit

Permalink
Re-rebalance mega steam engine & fix friction
Browse files Browse the repository at this point in the history
  • Loading branch information
M-W-K committed Jul 4, 2024
1 parent 8a07a78 commit 4869f69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
import com.m_w_k.gtcefucontent.common.block.GTCEFuCMetaBlocks;
import com.m_w_k.gtcefucontent.common.block.blocks.GTCEFuCBlockStandardCasing;

import gregicality.multiblocks.api.metatileentity.GCYMMultiblockAbility;
import gregicality.multiblocks.api.render.GCYMTextures;
import gregicality.multiblocks.common.block.GCYMMetaBlocks;
import gregicality.multiblocks.common.block.blocks.BlockLargeMultiblockCasing;
import gregicality.multiblocks.common.block.blocks.BlockUniqueCasing;
import gregtech.api.GTValues;
import gregtech.api.capability.IEnergyContainer;
import gregtech.api.capability.IMufflerHatch;
import gregtech.api.capability.IMultipleTankHandler;
import gregtech.api.capability.IRotorHolder;
import gregtech.api.capability.impl.MultiblockFuelRecipeLogic;
Expand Down Expand Up @@ -60,8 +59,7 @@

public class MetaTileEntityMegaSteamEngine extends FuelMultiblockController implements IProgressBarMultiblock {

protected boolean validVCU;
protected float vcuBonus;
protected float mufflerBonus;
protected long kineticEnergy;
// the larger the shaft mass, the slower the engine will ramp up
protected final int shaftMass;
Expand All @@ -76,7 +74,6 @@ public MetaTileEntityMegaSteamEngine(ResourceLocation metaTileEntityId, int shaf
super(metaTileEntityId, RecipeMaps.STEAM_TURBINE_FUELS, tier);
this.recipeMapWorkable = new MSEMultiblockWorkableHandler(this);
this.recipeMapWorkable.setMaximumOverclockVoltage(GTValues.V[tier]);
this.validVCU = false;
this.shaftMass = shaftMass;
this.friction = friction;
this.generatorStrength = generatorStrength;
Expand Down Expand Up @@ -132,10 +129,8 @@ public MetaTileEntity createMetaTileEntity(IGregTechTileEntity metaTileEntityHol
.where('Y', stateIndex(3).or(abilities(MultiblockAbility.OUTPUT_ENERGY).setPreviewCount(16)))
.where('A', stateIndex(5))
.where('C', stateIndex(4))
.where('S', stateIndex(0).setMinGlobalLimited(90)
.or(autoAbilities(false, true, false, false, true, true, false))
.or(abilities(GCYMMultiblockAbility.TIERED_HATCH).setMinGlobalLimited(1, 1)
.setMaxLayerLimited(1)))
.where('S', stateIndex(0).setMinGlobalLimited(100)
.or(autoAbilities(false, true, false, false, true, true, false)))
.where('P', stateIndex(2))
.where('M', abilities(MultiblockAbility.MUFFLER_HATCH))
.where('X', selfPredicate())
Expand All @@ -161,26 +156,18 @@ protected TraceabilityPredicate stateIndex(int id) {
@Override
protected void formStructure(PatternMatchContext context) {
super.formStructure(context);
List<IEnergyContainer> dynamoHatches = getAbilities(MultiblockAbility.OUTPUT_ENERGY);
List<ITieredMetaTileEntity> vcus = getAbilities(GCYMMultiblockAbility.TIERED_HATCH);
if (dynamoHatches.isEmpty() || vcus.isEmpty()) {
this.validVCU = true;
return;
}
long dynamoVoltage = dynamoHatches.stream().map(IEnergyContainer::getOutputVoltage).reduce(Math::max).get();
int vcuTier = vcus.stream().map(ITieredMetaTileEntity::getTier).reduce(Math::min).orElse(1);
this.validVCU = GTValues.V[vcuTier] >= dynamoVoltage;
// efficiency bonus approaching +200% as more VCUs are installed
this.vcuBonus = 3 - 6f / (2 + vcus.size());
List<IMufflerHatch> mufflerHatches = getAbilities(MultiblockAbility.MUFFLER_HATCH);
this.mufflerBonus = mufflerHatches.stream().filter(hatch -> hatch instanceof ITieredMetaTileEntity)
.map(hatch -> ((ITieredMetaTileEntity) hatch).getTier() * 0.1d + 1).map(Math::log10)
.map(Double::floatValue).reduce(Float::sum).orElse(0f);
}

@Override
protected void updateFormedValid() {
if (!hasMufflerMechanics() || isMufflerFaceFree()) {
this.recipeMapWorkable.updateWorkable();
// remove half of our friction value from the maximum output
long generated = this.energyContainer.addEnergy(getEnergyOut() - this.friction / 2);
this.kineticEnergy -= generated + friction;
long generated = this.energyContainer.addEnergy(this.getEnergyOut());
this.kineticEnergy -= generated + this.friction;
if (this.kineticEnergy < 0) this.kineticEnergy = 0;
}
}
Expand All @@ -189,7 +176,7 @@ protected void updateFormedValid() {
public void invalidateStructure() {
super.invalidateStructure();
this.outputFluidInventory = new LongFluidTankList(true);
this.validVCU = false;
this.mufflerBonus = 0;
}

public int getNumProgressBars() {
Expand Down Expand Up @@ -276,14 +263,14 @@ public void addBarHoverText(List<ITextComponent> hoverList, int index) {
@Override
protected void addDisplayText(List<ITextComponent> textList) {
super.addDisplayText(textList);
if (this.validVCU && this.vcuBonus > 1) {
if (this.mufflerBonus > 0) {
ITextComponent bonus = TextComponentUtil.stringWithColor(
TextFormatting.AQUA,
'+' + TextFormattingUtil.formatNumbers(Math.floor((this.vcuBonus - 1) * 100)) + '%');
'+' + TextFormattingUtil.formatNumbers(Math.floor(this.mufflerBonus * 100)) + '%');
textList.add(
TextComponentUtil.translationWithColor(
TextFormatting.GRAY,
"gtcefucontent.multiblock.mega_steam_engine.display.vcu_bonus",
"gtcefucontent.multiblock.mega_steam_engine.display.muffler_bonus",
bonus));
}
}
Expand All @@ -294,19 +281,11 @@ public void addInformation(ItemStack stack, @Nullable World player, @NotNull Lis
super.addInformation(stack, player, tooltip, advanced);
tooltip.add(I18n.format("gcym.machine.steam_engine.tooltip.1", GTValues.VNF[GTValues.OpV]));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.1"));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.2"));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.3", this.generatorStrength));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.4", this.friction));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.2", this.generatorStrength));
tooltip.add(I18n.format("gtcefucontent.machine.mega_steam_engine.tooltip.3", this.friction));
tooltip.add(I18n.format("gtcefucontent.universal.tooltip.uses_per_hour_vapor_seed", 20000));
}

@Override
protected void addErrorText(List<ITextComponent> textList) {
if (!validVCU)
textList.add(TextComponentUtil.translationWithColor(TextFormatting.GRAY,
"gtcefucontent.machine.mega_steam_engine.error.vcu"));
}

@SideOnly(Side.CLIENT)
@Override
public ICubeRenderer getBaseTexture(IMultiblockPart iMultiblockPart) {
Expand All @@ -332,13 +311,8 @@ public boolean hasMufflerMechanics() {
return EnumParticleTypes.CLOUD;
}

public boolean hasValidVCU() {
return validVCU;
}

@Override
public boolean isActive() {
return super.isActive() && validVCU;
public float getMufflerBonus() {
return this.mufflerBonus;
}

@Override
Expand Down Expand Up @@ -501,12 +475,12 @@ protected void drainLubricant() {

@Override
protected boolean canProgressRecipe() {
return this.engine.hasValidVCU() && checkLubricant() && super.canProgressRecipe();
return checkLubricant() && super.canProgressRecipe();
}

@Override
protected long boostProduction(long production) {
return (long) (production * this.engine.vcuBonus);
return (long) (production * (1 + this.engine.getMufflerBonus()));
}

@Override
Expand Down
10 changes: 4 additions & 6 deletions src/main/resources/assets/gtcefucontent/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,12 @@ gtcefucontent.machine.electrode_blast_smelter.tooltip=Thicc Rotary Hearth Furnac
gregtech.multiblock.electrode_blast_smelter.description=Performs both Blast Furnace and Alloy Blast Smelting recipes.

gtcefucontent.machine.mega_steam_engine.name=Large-Scale Industrial Steam Engine
gtcefucontent.machine.mega_steam_engine.tooltip.1=Dynamo hatch tier limited by Voltage Control Unit tier.
gtcefucontent.machine.mega_steam_engine.tooltip.2=Every additional Voltage Control Unit installed increases efficiency bonus, approaching +200%% efficiency.
gtcefucontent.machine.mega_steam_engine.tooltip.3=Generates §f%s EU/t§7 per RPM.
gtcefucontent.machine.mega_steam_engine.tooltip.4=Loses §f%s§7 kinetic energy per tick.
gtcefucontent.machine.mega_steam_engine.error.vcu=Dynamo hatch tier exceeds Voltage Control Unit tier!
gtcefucontent.machine.mega_steam_engine.tooltip.1=Installed Muffler Hatches cumulatively determine an efficiency bonus based on a logarithmic function of their recovery.
gtcefucontent.machine.mega_steam_engine.tooltip.2=Generates §b%s EU/t§7 per RPM.
gtcefucontent.machine.mega_steam_engine.tooltip.3=Loses §c%s§7 kinetic energy per tick.
gtcefucontent.multiblock.mega_steam_engine.display.shaft_speed=Engine Speed: %s
gtcefucontent.multiblock.mega_steam_engine.display.lubricant_amount=Vaporous Seed: %s
gtcefucontent.multiblock.mega_steam_engine.display.vcu_bonus=Efficiency bonus from installed VCUs: %s
gtcefucontent.multiblock.mega_steam_engine.display.muffler_bonus=Efficiency bonus from installed Muffler Hatches: %s

gtcefucontent.machine.fusion_stack.perfect=Allows for %s perfect overclocks
gtcefucontent.machine.fusion_stack.coolant=DOES NOT REQUIRE COOLANT
Expand Down

0 comments on commit 4869f69

Please sign in to comment.