Add a config option for wire transfer rates, closes #40

Fix connectors blowing up when they shouldn't in some cases
This commit is contained in:
malte0811 2018-09-03 20:39:04 +02:00
parent 69c8713853
commit 39ebc86029
6 changed files with 25 additions and 21 deletions

View file

@ -33,6 +33,8 @@ public class IWConfig {
@Comment({"The factor between the IF transfer rate of the wires and the IF transfer rate corresponding to the EU transfer rate.", @Comment({"The factor between the IF transfer rate of the wires and the IF transfer rate corresponding to the EU transfer rate.",
"The default value results in the same transfer rates as the standard IE wires"}) "The default value results in the same transfer rates as the standard IE wires"})
public static double wireRatio = .5; public static double wireRatio = .5;
@Comment({"The EU IO rates of the wires. Order is Tin, Copper, Gold, HV, Glass Fiber"})
public static double[] ioRatesEU = {32, 128, 512, 2048, 8192};
@Comment({"Set this to false to completely disable any conversion between IF and EU (default: true)"}) @Comment({"Set this to false to completely disable any conversion between IF and EU (default: true)"})
@RequiresMcRestart @RequiresMcRestart

View file

@ -149,7 +149,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
if (bufferToMachine < maxToMachine) { if (bufferToMachine < maxToMachine) {
maxToMachine = bufferToMachine; maxToMachine = bufferToMachine;
} }
potentialIEInputInTick = Math.max(Math.max(potentialIEInputInTick, actualIEInputInTick), getMaxIO()); potentialIEInputInTick = Math.min(Math.max(potentialIEInputInTick, actualIEInputInTick), getMaxIO());
if (potentialIEInputInTick > maxToMachine) { if (potentialIEInputInTick > maxToMachine) {
maxToMachine = potentialIEInputInTick; maxToMachine = potentialIEInputInTick;
} }

View file

@ -122,6 +122,21 @@ public class Compat {
} }
public static class CompatIC2 extends CompatModule { public static class CompatIC2 extends CompatModule {
@Override
public void preInit() {
loadIC2Tile = (te) -> {
if (!te.getWorld().isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) te));
}
};
unloadIC2Tile = (te) -> {
if (!te.getWorld().isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) te));
}
};
getIC2Item = (type, variant) -> ImmutableList.of(IC2Items.getItem(type, variant));
}
public void init() { public void init() {
Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem(); Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem();
ItemStack emptyMug = IC2Items.getItem("mug", "empty"); ItemStack emptyMug = IC2Items.getItem("mug", "empty");
@ -136,17 +151,6 @@ public class Compat {
return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s); return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s);
}); });
MechPartCommutator.originalStack = IC2Items.getItem("te", "kinetic_generator"); MechPartCommutator.originalStack = IC2Items.getItem("te", "kinetic_generator");
loadIC2Tile = (te) -> {
if (!te.getWorld().isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) te));
}
};
unloadIC2Tile = (te) ->{
if (!te.getWorld().isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) te));
}
};
getIC2Item = (type, variant)->ImmutableList.of(IC2Items.getItem(type, variant));
try { try {
Class<?> teb = Class.forName("ic2.core.block.TileEntityBlock"); Class<?> teb = Class.forName("ic2.core.block.TileEntityBlock");
Method getPickBlock = teb.getDeclaredMethod("getPickBlock", EntityPlayer.class, RayTraceResult.class); Method getPickBlock = teb.getDeclaredMethod("getPickBlock", EntityPlayer.class, RayTraceResult.class);

View file

@ -29,13 +29,12 @@ import java.util.Set;
public final class IC2TRHelper { public final class IC2TRHelper {
public static Ingredient getStack(String type, String variant) { public static Ingredient getStack(String type, String variant) {
Set<ItemStack> stacks = new HashSet<>();
if (type.equals("crafting")&&variant.equals("rubber")) { if (type.equals("crafting")&&variant.equals("rubber")) {
if (ApiUtils.isExistingOreName("itemRubber")) { if (ApiUtils.isExistingOreName("itemRubber")) {
return new OreIngredient("itemRubber"); return new OreIngredient("itemRubber");
} }
} }
stacks.addAll(Compat.getIC2Item.apply(type, variant)); Set<ItemStack> stacks = new HashSet<>(Compat.getIC2Item.apply(type, variant));
if (IndustrialWires.hasTechReborn) { if (IndustrialWires.hasTechReborn) {
switch (type) { switch (type) {
case "cable": case "cable":

View file

@ -36,7 +36,6 @@ public class MixedWireType extends WireType {
public static final String IC2_HV_CAT = "IC_HV"; public static final String IC2_HV_CAT = "IC_HV";
public static final String IC2_GLASS_CAT = "IC_GLASS"; public static final String IC2_GLASS_CAT = "IC_GLASS";
private final int type; private final int type;
private final int[] ratesEU = {32, 128, 512, 2048, 8192};
private final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1}; private final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
private final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass", private final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass",
"ic2TinIns", "ic2CopperIns", "ic2GoldIns"}; "ic2TinIns", "ic2CopperIns", "ic2GoldIns"};
@ -84,7 +83,7 @@ public class MixedWireType extends WireType {
} }
public double getIORate() { public double getIORate() {
return ratesEU[type%5] * ConversionUtil.joulesPerEu(); return IWConfig.ioRatesEU[type % 5] * ConversionUtil.joulesPerEu();
} }
@Override @Override

View file

@ -1,13 +1,13 @@
{ {
"conditions" : { "conditions" : {
"conversion": "malte0811.industrialWires.crafting.factories.IsConversionEnabled", "conversion": "malte0811.industrialwires.crafting.factories.IsConversionEnabled",
"other_bundled_redstone": "malte0811.industrialWires.crafting.factories.OtherBundledRedstone" "other_bundled_redstone": "malte0811.industrialwires.crafting.factories.OtherBundledRedstone"
}, },
"recipes": { "recipes": {
"component_init": "malte0811.industrialWires.crafting.factories.InitPCFactory", "component_init": "malte0811.industrialwires.crafting.factories.InitPCFactory",
"wire_coil": "malte0811.industrialWires.crafting.factories.WireCoilFactory" "wire_coil": "malte0811.industrialwires.crafting.factories.WireCoilFactory"
}, },
"ingredients": { "ingredients": {
"ic2_item": "malte0811.industrialWires.crafting.factories.IC2ItemFactory" "ic2_item": "malte0811.industrialwires.crafting.factories.IC2ItemFactory"
} }
} }