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

Make different amp diodes easier to add #2724

Merged
merged 6 commits into from
Feb 13, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public static void init() {
endPos = GregTechAPI.isHighTier() ? DIODES.length - 1 : Math.min(DIODES.length - 1, GTValues.UV + 2);
for (int i = 0; i < endPos; i++) {
String diodeId = "diode." + GTValues.VN[i].toLowerCase();
MetaTileEntityDiode diode = new MetaTileEntityDiode(gregtechId(diodeId), i);
MetaTileEntityDiode diode = new MetaTileEntityDiode(gregtechId(diodeId), i, 16);
DIODES[i] = registerMetaTileEntity(1300 + i, diode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,22 @@ public class MetaTileEntityDiode extends MetaTileEntityMultiblockPart
private static final String AMP_NBT_KEY = "amp_mode";
private int amps;
private boolean isWorkingEnabled;
private final int maxAmps;

public MetaTileEntityDiode(ResourceLocation metaTileEntityId, int tier) {
/**
* @param maxAmps Must be power of 2
*/
public MetaTileEntityDiode(ResourceLocation metaTileEntityId, int tier, int maxAmps) {
super(metaTileEntityId, tier);
amps = 1;
reinitializeEnergyContainer();
isWorkingEnabled = true;
this.maxAmps = maxAmps;
}

@Override
public MetaTileEntity createMetaTileEntity(IGregTechTileEntity tileEntity) {
return new MetaTileEntityDiode(metaTileEntityId, getTier());
return new MetaTileEntityDiode(metaTileEntityId, getTier(), getMaxAmperage());
}

@Override
Expand Down Expand Up @@ -115,14 +120,14 @@ private void setAmpMode() {
}
}

/** Change this value (or override) to make the Diode able to handle more amps. Must be a power of 2 */
protected int getMaxAmperage() {
return 16;
return maxAmps;
}

protected void reinitializeEnergyContainer() {
long tierVoltage = GTValues.V[getTier()];
this.energyContainer = new EnergyContainerHandler(this, tierVoltage * 16, tierVoltage, amps, tierVoltage, amps);
this.energyContainer = new EnergyContainerHandler(this, tierVoltage * getMaxAmperage(), tierVoltage, amps,
tierVoltage, amps);
((EnergyContainerHandler) this.energyContainer).setSideInputCondition(s -> s != getFrontFacing());
((EnergyContainerHandler) this.energyContainer).setSideOutputCondition(s -> s == getFrontFacing());
}
Expand Down
Loading