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

Simplified Multiblock Lathe #3724

Merged
merged 10 commits into from
Jan 4, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_LATHE_GLOW;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static gregtech.api.util.GTStructureUtility.chainAllGlasses;
import static net.minecraft.util.EnumChatFormatting.BLUE;
import static net.minecraft.util.EnumChatFormatting.DARK_AQUA;

import java.text.DecimalFormat;
import java.util.List;
Expand All @@ -33,7 +31,6 @@
import net.minecraftforge.common.util.ForgeDirection;

import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;

import com.google.common.collect.ImmutableList;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
Expand All @@ -54,7 +51,6 @@
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.recipe.check.CheckRecipeResult;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.GTUtility;
import gregtech.api.util.MultiblockTooltipBuilder;
Expand All @@ -78,40 +74,6 @@ public MTEMultiLathe(String aName) {

protected int pipeTier = 0;

public enum PipeTiers {

Tin(1, 0.75F),
Brass(1, 0.8F),
Electrum(2, 0.9F),
Platinum(4, 1F),
Osmium(8, 1.5F),
Quantium(12, 2F),
FluxedElectrum(16, 3F),
BlackPlutonium(32, 4F);

final int maxParallel;
final float speedBoost;

PipeTiers(int maxParallel, float speedBoost) {
this.maxParallel = maxParallel;
this.speedBoost = speedBoost;
}
}

private PipeTiers getPipeData() {
pipeTier = getPipeTier();
return switch (pipeTier) {
case 2 -> PipeTiers.Brass;
case 3 -> PipeTiers.Electrum;
case 4 -> PipeTiers.Platinum;
case 5 -> PipeTiers.Osmium;
case 6 -> PipeTiers.Quantium;
case 7 -> PipeTiers.FluxedElectrum;
case 8 -> PipeTiers.BlackPlutonium;
default -> PipeTiers.Tin;
};
}

// get tier from block meta
private static Integer getTierFromMeta(Block block, Integer metaID) {
if (block != GregTechAPI.sBlockCasings11) return -1;
Expand Down Expand Up @@ -228,16 +190,9 @@ public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirect
protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Lathe")
.addInfo(BLUE + "Allows more parallel recipes based on item pipe casing parallel and voltage.")
.addInfo("Max Parallel Recipes = Item Pipe Casing Parallel + (Voltage Tier * 2).")
.addInfo(BLUE + "Increases processing speed based on item pipe casing speed and voltage.")
.addInfo("Time Reduction = 1 / (Item Pipe Casing Speed Boost + Voltage Tier / 4).")
.addInfo("Speed Increase = (100 / Time Reduction).")
.addInfo(
DARK_AQUA
+ "For example, using Black Plutonium item pipe casings (boost of 4) and Tier 3 voltage (HV) ")
.addInfo(DARK_AQUA + "reduces processing time to 57% of the recipe time, making the machine 175% faster.")
.addInfo(BLUE + "Only uses 80% of the EU/T normally required.")
.addInfo("300% faster than using single block machines of the same voltage")
.addInfo("Gains 8 parallel per Pipe Casing Tier")
.addInfo("Only uses 80% of the EU/t normally required.")
.beginStructureBlock(7, 5, 5, true)
.addController("Front Center")
.addCasingInfoMin("Solid Steel Machine Casing", 42, false)
Expand Down Expand Up @@ -293,36 +248,24 @@ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack a
return this.mMaintenanceHatches.size() == 1 && pipeTier > 0 && !mEnergyHatches.isEmpty() && mCasingAmount >= 42;
}

public float speedBoost(float speedBoost, byte voltageTier) {
return 1F / ((speedBoost + voltageTier) / 4F);
}

@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic() {

@NotNull
@Override
public CheckRecipeResult process() {
speedBoost = (speedBoost(getPipeData().speedBoost, GTUtility.getTier(getMaxInputVoltage())));
return super.process();
}
}.setEuModifier(0.8F)
return new ProcessingLogic().setSpeedBonus(1F / 4F)
.setEuModifier(0.8F)
.setMaxParallelSupplier(this::getMaxParallelRecipes);
}

public int getMaxParallelRecipes() {
return getPipeData().maxParallel + (GTUtility.getTier(this.getMaxInputVoltage()) * 2);
return (getPipeTier() * 8);
}

@Override
public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y,
int z) {
super.getWailaNBTData(player, tile, tag, world, x, y, z);
tag.setInteger("itemPipeTier", Math.max(0, pipeTier));
tag.setFloat("speedBonus", getPipeData().speedBoost);
tag.setInteger("itemPipeTier", Math.max(0, getPipeTier()));
tag.setFloat("speedBonus", 400);
tag.setFloat("getMaxParallelRecipes", Math.max(0, getMaxParallelRecipes()));
tag.setByte("voltageTier", GTUtility.getTier(this.getMaxInputVoltage()));
}

private static final DecimalFormat dfNone = new DecimalFormat("#");
Expand All @@ -343,7 +286,7 @@ public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDat
currenttip.add(
StatCollector.translateToLocal("GT5U.multiblock.speed") + ": "
+ EnumChatFormatting.WHITE
+ dfNone.format(Math.max(0, 100 / speedBoost(tag.getFloat("speedBonus"), tag.getByte("voltageTier"))))
+ dfNone.format((Math.max(0, tag.getInteger("speedBonus"))))
+ "%");
}

Expand Down
Loading