Skip to content

Commit

Permalink
finish Supercon value on WireProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
serenibyss committed Aug 19, 2021
1 parent 5018bbe commit b59f0dc
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/main/java/gregtech/api/pipenet/block/BlockPipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public BlockPipe() {

protected abstract NodeDataType getFallbackType();

// TODO this has no reason to need an ItemStack parameter
public abstract PipeType getItemPipeType(ItemStack itemStack);

public abstract void setTileEntityData(TileEntityPipeBase<PipeType, NodeDataType> pipeTile, ItemStack itemStack);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,11 @@ public Builder cableProperties(long voltage, int amperage, int loss) {
return this;
}

public Builder cableProperties(long voltage, int amperage, int loss, boolean isSuperCon) {
properties.setProperty(PropertyKey.WIRE, new WireProperties((int) voltage, amperage, loss, isSuperCon));
return this;
}

public Builder fluidPipeProperties(int maxTemp, int throughput, boolean gasProof) {
properties.setProperty(PropertyKey.FLUID_PIPE, new FluidPipeProperties(maxTemp, throughput, gasProof));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ public class WireProperties implements IMaterialProperty<WireProperties> {
public final int voltage;
public final int amperage;
public final int lossPerBlock;
public final boolean isSuperconductor = false; // todo implement
public final boolean isSuperconductor;

public WireProperties(int voltage, int baseAmperage, int lossPerBlock) {
this(voltage, baseAmperage, lossPerBlock, false);
}

public WireProperties(int voltage, int baseAmperage, int lossPerBlock, boolean isSuperCon) {
this.voltage = voltage;
this.amperage = baseAmperage;
this.lossPerBlock = lossPerBlock;
this.lossPerBlock = isSuperCon ? 0 : lossPerBlock;
this.isSuperconductor = isSuperCon;
}

/**
* Default values constructor
*/
public WireProperties() {
this(8, 1, 1);
this(8, 1, 1, false);
}

@Override
Expand All @@ -34,7 +39,8 @@ public boolean equals(Object o) {
WireProperties that = (WireProperties) o;
return voltage == that.voltage &&
amperage == that.amperage &&
lossPerBlock == that.lossPerBlock;
lossPerBlock == that.lossPerBlock &&
isSuperconductor == that.isSuperconductor;
}

@Override
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/gregtech/common/blocks/MetaBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ public static void init() {
}

if (material.hasProperty(PropertyKey.WIRE)) {
for (BlockCable cable : CABLES)
cable.addCableMaterial(material, material.getProperty(PropertyKey.WIRE));
for (BlockCable cable : CABLES) {
if (!cable.getItemPipeType(null).isCable() || !material.getProperty(PropertyKey.WIRE).isSuperconductor)
cable.addCableMaterial(material, material.getProperty(PropertyKey.WIRE));
}
}
if (material.hasProperty(PropertyKey.FLUID_PIPE)) {
for (BlockFluidPipe pipe : FLUID_PIPES)
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/gregtech/common/pipelike/cable/Insulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public OrePrefix getOrePrefix() {
return orePrefix;
}

public boolean isCable() {
return ordinal() > 4;
}

@Override
public WireProperties modifyProperties(WireProperties baseProperties) {
Expand All @@ -62,7 +65,7 @@ public WireProperties modifyProperties(WireProperties baseProperties) {
lossPerBlock = (int) (0.75 * lossMultiplier);
else lossPerBlock = baseProperties.lossPerBlock * lossMultiplier;

return new WireProperties(baseProperties.voltage, baseProperties.amperage * amperage, lossPerBlock);
return new WireProperties(baseProperties.voltage, baseProperties.amperage * amperage, lossPerBlock, baseProperties.isSuperconductor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ public ItemBlockCable(BlockCable block) {

@Override
@SideOnly(Side.CLIENT)
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
public void addInformation(@Nonnull ItemStack stack, @Nullable World worldIn, @Nonnull List<String> tooltip, @Nonnull ITooltipFlag flagIn) {
WireProperties wireProperties = blockPipe.createItemProperties(stack);
String voltageName = GTValues.VN[GTUtility.getTierByVoltage(wireProperties.voltage)];
if (wireProperties.isSuperconductor) tooltip.add(I18n.format("gregtech.cable.superconductor", voltageName));
tooltip.add(I18n.format("gregtech.cable.voltage", wireProperties.voltage, voltageName));
tooltip.add(I18n.format("gregtech.cable.amperage", wireProperties.amperage));
tooltip.add(I18n.format("gregtech.cable.loss_per_block", wireProperties.lossPerBlock));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public static void processWireSingle(OrePrefix wirePrefix, Material material, Wi
}

public static void generateWireRecipe(OrePrefix wirePrefix, Material material, WireProperties property) {
if (property.isSuperconductor) return;
int cableAmount = (int) (wirePrefix.materialAmount * 2 / M);
OrePrefix cablePrefix = OrePrefix.getPrefix("cable" + wirePrefix.name().substring(4));
ItemStack cableStack = OreDictUnifier.get(cablePrefix, material);
Expand Down Expand Up @@ -154,6 +155,7 @@ public static void generateWireCombiningRecipe(OrePrefix wirePrefix, Material ma
}

public static void generateCableCombiningRecipe(OrePrefix cablePrefix, Material material, WireProperties property) {
if (property.isSuperconductor) return;
int cableIndex = ArrayUtils.indexOf(CABLE_DOUBLING_ORDER, cablePrefix);

if (cableIndex < CABLE_DOUBLING_ORDER.length - 1) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/gregtech/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,7 @@ gregtech.item_filter.footer=§eClick with item to override
gregtech.cable.voltage=Max Voltage: §a%,d §a(%s)
gregtech.cable.amperage=Max Amperage: §e%,d
gregtech.cable.loss_per_block=Loss/Meter/Ampere: §c%,d§7 EU-Volt
gregtech.cable.superconductor=§d%s Superconductor

gregtech.fluid_pipe.throughput=§9Transfer Rate: %,d L/s
gregtech.fluid_pipe.max_temperature=§cTemperature Limit: %,dK
Expand Down

0 comments on commit b59f0dc

Please sign in to comment.