Electrolyzer Improvements part 1

Changes:
Halfed recipe time for water/heavy water electrolysis
Added ore slop electrolysis recipe
Added electrolyzer overdrive support
Rebalanced the power savings upgrade
speed and overdrive upgrades now make the electrolyzer pour out faster
This commit is contained in:
70000hp 2024-07-07 19:21:42 -04:00
parent b31cb80fa3
commit 3120268a64
4 changed files with 161 additions and 103 deletions

View File

@ -10,8 +10,10 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import com.hbm.inventory.FluidStack; import com.hbm.inventory.FluidStack;
import com.hbm.inventory.RecipesCommon;
import com.hbm.inventory.fluid.FluidType; import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.material.Mats;
import com.hbm.inventory.recipes.loader.SerializableRecipe; import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.items.machine.ItemFluidIcon; import com.hbm.items.machine.ItemFluidIcon;
@ -24,9 +26,10 @@ public class ElectrolyserFluidRecipes extends SerializableRecipe {
@Override @Override
public void registerDefaults() { public void registerDefaults() {
recipes.put(Fluids.WATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.HYDROGEN, 200), new FluidStack(Fluids.OXYGEN, 200))); recipes.put(Fluids.WATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.HYDROGEN, 200), new FluidStack(Fluids.OXYGEN, 200),10));
recipes.put(Fluids.HEAVYWATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.DEUTERIUM, 200), new FluidStack(Fluids.OXYGEN, 200))); recipes.put(Fluids.HEAVYWATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.DEUTERIUM, 200), new FluidStack(Fluids.OXYGEN, 200), 10));
recipes.put(Fluids.VITRIOL, new ElectrolysisRecipe(1_000, new FluidStack(Fluids.SULFURIC_ACID, 500), new FluidStack(Fluids.CHLORINE, 500), new ItemStack(ModItems.powder_iron), new ItemStack(ModItems.ingot_mercury))); recipes.put(Fluids.VITRIOL, new ElectrolysisRecipe(1_000, new FluidStack(Fluids.SULFURIC_ACID, 500), new FluidStack(Fluids.CHLORINE, 500), new ItemStack(ModItems.powder_iron), new ItemStack(ModItems.ingot_mercury)));
recipes.put(Fluids.SLOP, new ElectrolysisRecipe(1_000, new FluidStack(Fluids.MERCURY, 250), new FluidStack(Fluids.NONE, 0), new ItemStack(ModItems.niter, 2), new ItemStack(ModItems.powder_limestone, 2), new ItemStack(ModItems.sulfur)));
recipes.put(Fluids.POTASSIUM_CHLORIDE, new ElectrolysisRecipe(250, new FluidStack(Fluids.CHLORINE, 125), new FluidStack(Fluids.NONE, 0), new ItemStack(ModItems.dust))); recipes.put(Fluids.POTASSIUM_CHLORIDE, new ElectrolysisRecipe(250, new FluidStack(Fluids.CHLORINE, 125), new FluidStack(Fluids.NONE, 0), new ItemStack(ModItems.dust)));
recipes.put(Fluids.CALCIUM_CHLORIDE, new ElectrolysisRecipe(250, new FluidStack(Fluids.CHLORINE, 125), new FluidStack(Fluids.CALCIUM_SOLUTION, 125))); recipes.put(Fluids.CALCIUM_CHLORIDE, new ElectrolysisRecipe(250, new FluidStack(Fluids.CHLORINE, 125), new FluidStack(Fluids.CALCIUM_SOLUTION, 125)));
@ -50,6 +53,11 @@ public class ElectrolyserFluidRecipes extends SerializableRecipe {
return recipes; return recipes;
} }
public static ElectrolysisRecipe getRecipe(FluidType type) {
if(type == null)
return null;
return recipes.get(type);
}
@Override @Override
public String getFileName() { public String getFileName() {
@ -100,12 +108,23 @@ public class ElectrolyserFluidRecipes extends SerializableRecipe {
public FluidStack output2; public FluidStack output2;
public int amount; public int amount;
public ItemStack[] byproduct; public ItemStack[] byproduct;
public int duration;
public ElectrolysisRecipe(int amount, FluidStack output1, FluidStack output2, ItemStack... byproduct) { public ElectrolysisRecipe(int amount, FluidStack output1, FluidStack output2, ItemStack... byproduct) {
this.output1 = output1; this.output1 = output1;
this.output2 = output2; this.output2 = output2;
this.amount = amount; this.amount = amount;
this.byproduct = byproduct; this.byproduct = byproduct;
duration = 20;
}
public ElectrolysisRecipe(int amount, FluidStack output1, FluidStack output2, int duration, ItemStack... byproduct) {
this.output1 = output1;
this.output2 = output2;
this.amount = amount;
this.byproduct = byproduct;
this.duration = duration;
} }
} }
} }

View File

@ -24,6 +24,7 @@ import com.hbm.items.machine.ItemScraps;
import com.hbm.items.special.ItemBedrockOreNew; import com.hbm.items.special.ItemBedrockOreNew;
import com.hbm.items.special.ItemBedrockOreNew.BedrockOreGrade; import com.hbm.items.special.ItemBedrockOreNew.BedrockOreGrade;
import com.hbm.items.special.ItemBedrockOreNew.BedrockOreType; import com.hbm.items.special.ItemBedrockOreNew.BedrockOreType;
import com.hbm.util.BobMathUtil;
import com.hbm.util.ItemStackUtil; import com.hbm.util.ItemStackUtil;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -134,22 +135,23 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
for(BedrockOreType type : BedrockOreType.values()) { for(BedrockOreType type : BedrockOreType.values()) {
MaterialStack f0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(12)); MaterialStack f0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(7));
MaterialStack f1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(6)); MaterialStack f1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(4));
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_FIRST, type)), new ElectrolysisMetalRecipe( recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_FIRST, type)), new ElectrolysisMetalRecipe(
f0 != null ? f0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), f0 != null ? f0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)),
f1 != null ? f1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), f1 != null ? f1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)),
f0 == null ? ItemBedrockOreNew.extract(type.primary1, 12) : new ItemStack(ModItems.dust), 20,
f1 == null ? ItemBedrockOreNew.extract(type.primary2, 6) : new ItemStack(ModItems.dust), f0 == null ? ItemBedrockOreNew.extract(type.primary1, 7) : new ItemStack(ModItems.dust),
f1 == null ? ItemBedrockOreNew.extract(type.primary2, 4) : new ItemStack(ModItems.dust),
ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type))); ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)));
MaterialStack s0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(4));
MaterialStack s0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(6)); MaterialStack s1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(7));
MaterialStack s1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(12));
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_SECOND, type)), new ElectrolysisMetalRecipe( recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_SECOND, type)), new ElectrolysisMetalRecipe(
s0 != null ? s0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), s0 != null ? s0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)),
s1 != null ? s1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)), s1 != null ? s1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1)),
s0 == null ? ItemBedrockOreNew.extract(type.primary1, 12) : new ItemStack(ModItems.dust), 20,
s1 == null ? ItemBedrockOreNew.extract(type.primary2, 6) : new ItemStack(ModItems.dust), s0 == null ? ItemBedrockOreNew.extract(type.primary1, 4) : new ItemStack(ModItems.dust),
s1 == null ? ItemBedrockOreNew.extract(type.primary2, 7) : new ItemStack(ModItems.dust),
ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type))); ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)));
MaterialStack c0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(2)); MaterialStack c0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(2));
@ -157,13 +159,16 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new ElectrolysisMetalRecipe( recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new ElectrolysisMetalRecipe(
c0 != null ? c0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)), c0 != null ? c0 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)),
c1 != null ? c1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)), c1 != null ? c1 : new MaterialStack(Mats.MAT_SLAG, MaterialShapes.INGOT.q(1, 2)),
20,
c0 == null ? ItemBedrockOreNew.extract(type.primary1, 2) : new ItemStack(ModItems.dust), c0 == null ? ItemBedrockOreNew.extract(type.primary1, 2) : new ItemStack(ModItems.dust),
c1 == null ? ItemBedrockOreNew.extract(type.primary2, 2) : new ItemStack(ModItems.dust))); c1 == null ? ItemBedrockOreNew.extract(type.primary2, 2) : new ItemStack(ModItems.dust)));
} }
} }
public static ElectrolysisMetalRecipe getRecipe(ItemStack stack) { public static ElectrolysisMetalRecipe getRecipe(ItemStack stack) {
if(stack == null || stack.getItem() == null)
return null;
ComparableStack comp = new ComparableStack(stack).makeSingular(); ComparableStack comp = new ComparableStack(stack).makeSingular();
if(recipes.containsKey(comp)) return recipes.get(comp); if(recipes.containsKey(comp)) return recipes.get(comp);
@ -180,7 +185,7 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
public static HashMap getRecipes() { public static HashMap getRecipes() {
HashMap<Object[], Object[]> recipes = new HashMap<Object[], Object[]>(); HashMap<Object[], Object[]> recipes = new HashMap<>();
for(Entry<AStack, ElectrolysisMetalRecipe> entry : ElectrolyserMetalRecipes.recipes.entrySet()) { for(Entry<AStack, ElectrolysisMetalRecipe> entry : ElectrolyserMetalRecipes.recipes.entrySet()) {
@ -266,11 +271,19 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
public MaterialStack output1; public MaterialStack output1;
public MaterialStack output2; public MaterialStack output2;
public ItemStack[] byproduct; public ItemStack[] byproduct;
public int duration;
public ElectrolysisMetalRecipe(MaterialStack output1, MaterialStack output2, ItemStack... byproduct) { public ElectrolysisMetalRecipe(MaterialStack output1, MaterialStack output2, ItemStack... byproduct) {
this.output1 = output1; this.output1 = output1;
this.output2 = output2; this.output2 = output2;
this.byproduct = byproduct; this.byproduct = byproduct;
duration = 600;
}
public ElectrolysisMetalRecipe(MaterialStack output1, MaterialStack output2, int duration, ItemStack... byproduct) {
this.output1 = output1;
this.output2 = output2;
this.byproduct = byproduct;
this.duration = duration;
} }
} }
} }

View File

@ -16,6 +16,7 @@ import com.hbm.inventory.gui.GUIElectrolyserMetal;
import com.hbm.inventory.material.MaterialShapes; import com.hbm.inventory.material.MaterialShapes;
import com.hbm.inventory.material.Mats; import com.hbm.inventory.material.Mats;
import com.hbm.inventory.material.Mats.MaterialStack; import com.hbm.inventory.material.Mats.MaterialStack;
import com.hbm.inventory.recipes.CrystallizerRecipes;
import com.hbm.inventory.recipes.ElectrolyserFluidRecipes; import com.hbm.inventory.recipes.ElectrolyserFluidRecipes;
import com.hbm.inventory.recipes.ElectrolyserFluidRecipes.ElectrolysisRecipe; import com.hbm.inventory.recipes.ElectrolyserFluidRecipes.ElectrolysisRecipe;
import com.hbm.inventory.recipes.ElectrolyserMetalRecipes; import com.hbm.inventory.recipes.ElectrolyserMetalRecipes;
@ -28,6 +29,7 @@ import com.hbm.packet.PacketDispatcher;
import com.hbm.tileentity.IGUIProvider; import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.IUpgradeInfoProvider; import com.hbm.tileentity.IUpgradeInfoProvider;
import com.hbm.tileentity.TileEntityMachineBase; import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.util.BobMathUtil;
import com.hbm.util.CrucibleUtil; import com.hbm.util.CrucibleUtil;
import com.hbm.util.I18nUtil; import com.hbm.util.I18nUtil;
import com.hbm.util.fauxpointtwelve.DirPos; import com.hbm.util.fauxpointtwelve.DirPos;
@ -59,16 +61,14 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
public int usageFluid; public int usageFluid;
public int progressFluid; public int progressFluid;
public static final int processFluidTimeBase = 20; public int processFluidTime = 100;
public int processFluidTime;
public int progressOre; public int progressOre;
public static final int processOreTimeBase = 600; public int processOreTime = 600;
public int processOreTime;
public MaterialStack leftStack; public MaterialStack leftStack;
public MaterialStack rightStack; public MaterialStack rightStack;
public int maxMaterial = MaterialShapes.BLOCK.q(16); public int maxMaterial = MaterialShapes.BLOCK.q(16);
public FluidTank[] tanks; public FluidTank[] tanks;
public TileEntityElectrolyser() { public TileEntityElectrolyser() {
@ -88,7 +88,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
tanks[2] = new FluidTank(Fluids.OXYGEN, 16000); tanks[2] = new FluidTank(Fluids.OXYGEN, 16000);
tanks[3] = new FluidTank(Fluids.NITRIC_ACID, 16000); tanks[3] = new FluidTank(Fluids.NITRIC_ACID, 16000);
} }
@Override @Override
public int[] getAccessibleSlotsFromSide(int meta) { public int[] getAccessibleSlotsFromSide(int meta) {
return new int[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }; return new int[] { 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
@ -114,13 +114,13 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
public void updateEntity() { public void updateEntity() {
if(!worldObj.isRemote) { if(!worldObj.isRemote) {
this.power = Library.chargeTEFromItems(slots, 0, power, maxPower); this.power = Library.chargeTEFromItems(slots, 0, power, maxPower);
this.tanks[0].setType(3, 4, slots); this.tanks[0].setType(3, 4, slots);
this.tanks[0].loadTank(5, 6, slots); this.tanks[0].loadTank(5, 6, slots);
this.tanks[1].unloadTank(7, 8, slots); this.tanks[1].unloadTank(7, 8, slots);
this.tanks[2].unloadTank(9, 10, slots); this.tanks[2].unloadTank(9, 10, slots);
if(worldObj.getTotalWorldTime() % 20 == 0) { if(worldObj.getTotalWorldTime() % 20 == 0) {
for(DirPos pos : this.getConPos()) { for(DirPos pos : this.getConPos()) {
this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); this.trySubscribe(worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
@ -131,46 +131,46 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); if(tanks[2].getFill() > 0) this.sendFluid(tanks[2], worldObj, pos.getX(), pos.getY(), pos.getZ(), pos.getDir());
} }
} }
UpgradeManager.eval(slots, 1, 2); UpgradeManager.eval(slots, 1, 2);
int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3); int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3);
int powerLevel = Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 3); int powerLevel = Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 3);
processFluidTime = processFluidTimeBase - processFluidTimeBase * speedLevel / 4;
processOreTime = processOreTimeBase - processOreTimeBase * speedLevel / 4;
usageOre = usageOreBase - usageOreBase * powerLevel / 4; usageOre = usageOreBase - usageOreBase * powerLevel / 4;
usageFluid = usageFluidBase - usageFluidBase * powerLevel / 4; usageFluid = usageFluidBase - usageFluidBase * powerLevel / 4;
if(this.canProcessFluid()) { for(int i = 0; i < getCycleCount(); i++) {
this.progressFluid++; if (this.canProcessFluid()) {
this.power -= this.usageFluid; this.progressFluid++;
this.power -= this.usageFluid;
if(this.progressFluid >= this.processFluidTime) {
this.processFluids(); if (this.progressFluid >= this.getDurationFluid()) {
this.progressFluid = 0; this.processFluids();
this.markChanged(); this.progressFluid = 0;
this.markChanged();
}
}
if (this.canProcessMetal()) {
this.progressOre++;
this.power -= this.usageOre;
if (this.progressOre >= this.getDurationMetal()) {
this.processMetal();
this.progressOre = 0;
this.markChanged();
}
} }
} }
if(this.canProcesMetal()) {
this.progressOre++;
this.power -= this.usageOre;
if(this.progressOre >= this.processOreTime) {
this.processMetal();
this.progressOre = 0;
this.markChanged();
}
}
if(this.leftStack != null) { if(this.leftStack != null) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite(); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset).getOpposite();
List<MaterialStack> toCast = new ArrayList(); List<MaterialStack> toCast = new ArrayList();
toCast.add(this.leftStack); toCast.add(this.leftStack);
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2D, zCoord + 0.5D + dir.offsetZ * 5.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3), impact); MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2D, zCoord + 0.5D + dir.offsetZ * 5.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3) * Math.max (getCycleCount() * speedLevel, 1), impact);
if(didPour != null) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
@ -181,19 +181,19 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
data.setFloat("base", 0.625F); data.setFloat("base", 0.625F);
data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875) + 2)); data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875) + 2));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2, zCoord + 0.5D + dir.offsetZ * 5.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50)); PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2, zCoord + 0.5D + dir.offsetZ * 5.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50));
if(this.leftStack.amount <= 0) this.leftStack = null; if(this.leftStack.amount <= 0) this.leftStack = null;
} }
} }
if(this.rightStack != null) { if(this.rightStack != null) {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
List<MaterialStack> toCast = new ArrayList(); List<MaterialStack> toCast = new ArrayList();
toCast.add(this.rightStack); toCast.add(this.rightStack);
Vec3 impact = Vec3.createVectorHelper(0, 0, 0); Vec3 impact = Vec3.createVectorHelper(0, 0, 0);
MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2D, zCoord + 0.5D + dir.offsetZ * 5.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3), impact); MaterialStack didPour = CrucibleUtil.pourFullStack(worldObj, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2D, zCoord + 0.5D + dir.offsetZ * 5.875D, 6, true, toCast, MaterialShapes.NUGGET.q(3) * Math.max (getCycleCount() * speedLevel, 1), impact);
if(didPour != null) { if(didPour != null) {
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
@ -204,19 +204,19 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
data.setFloat("base", 0.625F); data.setFloat("base", 0.625F);
data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875) + 2)); data.setFloat("len", Math.max(1F, yCoord - (float) (Math.ceil(impact.yCoord) - 0.875) + 2));
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2, zCoord + 0.5D + dir.offsetZ * 5.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50)); PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, xCoord + 0.5D + dir.offsetX * 5.875D, yCoord + 2, zCoord + 0.5D + dir.offsetZ * 5.875D), new TargetPoint(worldObj.provider.dimensionId, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 50));
if(this.rightStack.amount <= 0) this.rightStack = null; if(this.rightStack.amount <= 0) this.rightStack = null;
} }
} }
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
data.setLong("power", this.power); data.setLong("power", this.power);
data.setInteger("progressFluid", this.progressFluid); data.setInteger("progressFluid", this.progressFluid);
data.setInteger("progressOre", this.progressOre); data.setInteger("progressOre", this.progressOre);
data.setInteger("usageOre", this.usageOre); data.setInteger("usageOre", this.usageOre);
data.setInteger("usageFluid", this.usageFluid); data.setInteger("usageFluid", this.usageFluid);
data.setInteger("processFluidTime", this.processFluidTime); data.setInteger("processFluidTime", this.getDurationFluid());
data.setInteger("processOreTime", this.processOreTime); data.setInteger("processOreTime", this.getDurationMetal());
if(this.leftStack != null) { if(this.leftStack != null) {
data.setInteger("leftType", leftStack.material.id); data.setInteger("leftType", leftStack.material.id);
data.setInteger("leftAmount", leftStack.amount); data.setInteger("leftAmount", leftStack.amount);
@ -229,11 +229,11 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
this.networkPack(data, 50); this.networkPack(data, 50);
} }
} }
public DirPos[] getConPos() { public DirPos[] getConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP); ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] { return new DirPos[] {
new DirPos(xCoord - dir.offsetX * 6, yCoord, zCoord - dir.offsetZ * 6, dir.getOpposite()), new DirPos(xCoord - dir.offsetX * 6, yCoord, zCoord - dir.offsetZ * 6, dir.getOpposite()),
new DirPos(xCoord - dir.offsetX * 6 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 6 + rot.offsetZ, dir.getOpposite()), new DirPos(xCoord - dir.offsetX * 6 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 6 + rot.offsetZ, dir.getOpposite()),
@ -247,7 +247,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
@Override @Override
public void networkUnpack(NBTTagCompound nbt) { public void networkUnpack(NBTTagCompound nbt) {
super.networkUnpack(nbt); super.networkUnpack(nbt);
this.power = nbt.getLong("power"); this.power = nbt.getLong("power");
this.progressFluid = nbt.getInteger("progressFluid"); this.progressFluid = nbt.getInteger("progressFluid");
this.progressOre = nbt.getInteger("progressOre"); this.progressOre = nbt.getInteger("progressOre");
@ -261,48 +261,48 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
else this.rightStack = null; else this.rightStack = null;
for(int i = 0; i < 4; i++) tanks[i].readFromNBT(nbt, "t" + i); for(int i = 0; i < 4; i++) tanks[i].readFromNBT(nbt, "t" + i);
} }
public boolean canProcessFluid() { public boolean canProcessFluid() {
if(this.power < usageFluid) return false; if(this.power < usageFluid) return false;
ElectrolysisRecipe recipe = ElectrolyserFluidRecipes.recipes.get(tanks[0].getTankType()); ElectrolysisRecipe recipe = ElectrolyserFluidRecipes.recipes.get(tanks[0].getTankType());
if(recipe == null) return false; if(recipe == null) return false;
if(recipe.amount > tanks[0].getFill()) return false; if(recipe.amount > tanks[0].getFill()) return false;
if(recipe.output1.type == tanks[1].getTankType() && recipe.output1.fill + tanks[1].getFill() > tanks[1].getMaxFill()) return false; if(recipe.output1.type == tanks[1].getTankType() && recipe.output1.fill + tanks[1].getFill() > tanks[1].getMaxFill()) return false;
if(recipe.output2.type == tanks[2].getTankType() && recipe.output2.fill + tanks[2].getFill() > tanks[2].getMaxFill()) return false; if(recipe.output2.type == tanks[2].getTankType() && recipe.output2.fill + tanks[2].getFill() > tanks[2].getMaxFill()) return false;
if(recipe.byproduct != null) { if(recipe.byproduct != null) {
for(int i = 0; i < recipe.byproduct.length; i++) { for(int i = 0; i < recipe.byproduct.length; i++) {
ItemStack slot = slots[11 + i]; ItemStack slot = slots[11 + i];
ItemStack byproduct = recipe.byproduct[i]; ItemStack byproduct = recipe.byproduct[i];
if(slot == null) continue; if(slot == null) continue;
if(!slot.isItemEqual(byproduct)) return false; if(!slot.isItemEqual(byproduct)) return false;
if(slot.stackSize + byproduct.stackSize > slot.getMaxStackSize()) return false; if(slot.stackSize + byproduct.stackSize > slot.getMaxStackSize()) return false;
} }
} }
return true; return true;
} }
public void processFluids() { public void processFluids() {
ElectrolysisRecipe recipe = ElectrolyserFluidRecipes.recipes.get(tanks[0].getTankType()); ElectrolysisRecipe recipe = ElectrolyserFluidRecipes.recipes.get(tanks[0].getTankType());
tanks[0].setFill(tanks[0].getFill() - recipe.amount); tanks[0].setFill(tanks[0].getFill() - recipe.amount);
tanks[1].setTankType(recipe.output1.type); tanks[1].setTankType(recipe.output1.type);
tanks[2].setTankType(recipe.output2.type); tanks[2].setTankType(recipe.output2.type);
tanks[1].setFill(tanks[1].getFill() + recipe.output1.fill); tanks[1].setFill(tanks[1].getFill() + recipe.output1.fill);
tanks[2].setFill(tanks[2].getFill() + recipe.output2.fill); tanks[2].setFill(tanks[2].getFill() + recipe.output2.fill);
if(recipe.byproduct != null) { if(recipe.byproduct != null) {
for(int i = 0; i < recipe.byproduct.length; i++) { for(int i = 0; i < recipe.byproduct.length; i++) {
ItemStack slot = slots[11 + i]; ItemStack slot = slots[11 + i];
ItemStack byproduct = recipe.byproduct[i]; ItemStack byproduct = recipe.byproduct[i];
if(slot == null) { if(slot == null) {
slots[11 + i] = byproduct.copy(); slots[11 + i] = byproduct.copy();
} else { } else {
@ -311,63 +311,63 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
} }
} }
} }
public boolean canProcesMetal() { public boolean canProcessMetal() {
if(slots[14] == null) return false; if(slots[14] == null) return false;
if(this.power < usageOre) return false; if(this.power < usageOre) return false;
if(this.tanks[3].getFill() < 100) return false; if(this.tanks[3].getFill() < 100) return false;
ElectrolysisMetalRecipe recipe = ElectrolyserMetalRecipes.getRecipe(slots[14]); ElectrolysisMetalRecipe recipe = ElectrolyserMetalRecipes.getRecipe(slots[14]);
if(recipe == null) return false; if(recipe == null) return false;
if(leftStack != null) { if(leftStack != null) {
if(recipe.output1.material != leftStack.material) return false; if(recipe.output1.material != leftStack.material) return false;
if(recipe.output1.amount + leftStack.amount > this.maxMaterial) return false; if(recipe.output1.amount + leftStack.amount > this.maxMaterial) return false;
} }
if(rightStack != null) { if(rightStack != null) {
if(recipe.output2.material != rightStack.material) return false; if(recipe.output2.material != rightStack.material) return false;
if(recipe.output2.amount + rightStack.amount > this.maxMaterial) return false; if(recipe.output2.amount + rightStack.amount > this.maxMaterial) return false;
} }
if(recipe.byproduct != null) { if(recipe.byproduct != null) {
for(int i = 0; i < recipe.byproduct.length; i++) { for(int i = 0; i < recipe.byproduct.length; i++) {
ItemStack slot = slots[15 + i]; ItemStack slot = slots[15 + i];
ItemStack byproduct = recipe.byproduct[i]; ItemStack byproduct = recipe.byproduct[i];
if(slot == null) continue; if(slot == null) continue;
if(!slot.isItemEqual(byproduct)) return false; if(!slot.isItemEqual(byproduct)) return false;
if(slot.stackSize + byproduct.stackSize > slot.getMaxStackSize()) return false; if(slot.stackSize + byproduct.stackSize > slot.getMaxStackSize()) return false;
} }
} }
return true; return true;
} }
public void processMetal() { public void processMetal() {
ElectrolysisMetalRecipe recipe = ElectrolyserMetalRecipes.getRecipe(slots[14]); ElectrolysisMetalRecipe recipe = ElectrolyserMetalRecipes.getRecipe(slots[14]);
if(leftStack == null) { if(leftStack == null) {
leftStack = new MaterialStack(recipe.output1.material, recipe.output1.amount); leftStack = new MaterialStack(recipe.output1.material, recipe.output1.amount);
} else { } else {
leftStack.amount += recipe.output1.amount; leftStack.amount += recipe.output1.amount;
} }
if(rightStack == null) { if(rightStack == null) {
rightStack = new MaterialStack(recipe.output2.material, recipe.output2.amount); rightStack = new MaterialStack(recipe.output2.material, recipe.output2.amount);
} else { } else {
rightStack.amount += recipe.output2.amount; rightStack.amount += recipe.output2.amount;
} }
if(recipe.byproduct != null) { if(recipe.byproduct != null) {
for(int i = 0; i < recipe.byproduct.length; i++) { for(int i = 0; i < recipe.byproduct.length; i++) {
ItemStack slot = slots[15 + i]; ItemStack slot = slots[15 + i];
ItemStack byproduct = recipe.byproduct[i]; ItemStack byproduct = recipe.byproduct[i];
if(slot == null) { if(slot == null) {
slots[15 + i] = byproduct.copy(); slots[15 + i] = byproduct.copy();
} else { } else {
@ -375,11 +375,30 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
} }
} }
} }
this.tanks[3].setFill(this.tanks[3].getFill() - 100); this.tanks[3].setFill(this.tanks[3].getFill() - 100);
this.decrStackSize(14, 1); this.decrStackSize(14, 1);
} }
public int getDurationMetal() {
ElectrolysisMetalRecipe result = ElectrolyserMetalRecipes.getRecipe(slots[14]);
int base = result != null ? result.duration : 600;
int speed = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3) - Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 1);
return (int) Math.ceil((base * Math.max(1F - 0.25F * speed, 0.2)));
}
public int getDurationFluid() {
ElectrolysisRecipe result = ElectrolyserFluidRecipes.getRecipe(tanks[0].getTankType());
int base = result != null ? result.duration : 100;
int speed = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 3) - Math.min(UpgradeManager.getLevel(UpgradeType.POWER), 1);
return (int) Math.ceil((base * Math.max(1F - 0.25F * speed, 0.2)));
}
public int getCycleCount() {
int speed = UpgradeManager.getLevel(UpgradeType.OVERDRIVE);
return Math.min(1 + speed * 2, 7);
}
@Override @Override
public void readFromNBT(NBTTagCompound nbt) { public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt); super.readFromNBT(nbt);
@ -395,16 +414,16 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
else this.rightStack = null; else this.rightStack = null;
for(int i = 0; i < 4; i++) tanks[i].readFromNBT(nbt, "t" + i); for(int i = 0; i < 4; i++) tanks[i].readFromNBT(nbt, "t" + i);
} }
@Override @Override
public void writeToNBT(NBTTagCompound nbt) { public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt); super.writeToNBT(nbt);
nbt.setLong("power", this.power); nbt.setLong("power", this.power);
nbt.setInteger("progressFluid", this.progressFluid); nbt.setInteger("progressFluid", this.progressFluid);
nbt.setInteger("progressOre", this.progressOre); nbt.setInteger("progressOre", this.progressOre);
nbt.setInteger("processFluidTime", this.processFluidTime); nbt.setInteger("processFluidTime", getDurationFluid());
nbt.setInteger("processOreTime", this.processOreTime); nbt.setInteger("processOreTime", getDurationMetal());
if(this.leftStack != null) { if(this.leftStack != null) {
nbt.setInteger("leftType", leftStack.material.id); nbt.setInteger("leftType", leftStack.material.id);
nbt.setInteger("leftAmount", leftStack.amount); nbt.setInteger("leftAmount", leftStack.amount);
@ -414,13 +433,14 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
nbt.setInteger("rightAmount", rightStack.amount); nbt.setInteger("rightAmount", rightStack.amount);
} }
for(int i = 0; i < 4; i++) tanks[i].writeToNBT(nbt, "t" + i); for(int i = 0; i < 4; i++) tanks[i].writeToNBT(nbt, "t" + i);
} }
AxisAlignedBB bb = null; AxisAlignedBB bb = null;
@Override @Override
public AxisAlignedBB getRenderBoundingBox() { public AxisAlignedBB getRenderBoundingBox() {
if(bb == null) { if(bb == null) {
bb = AxisAlignedBB.getBoundingBox( bb = AxisAlignedBB.getBoundingBox(
xCoord - 5, xCoord - 5,
@ -431,10 +451,10 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
zCoord + 6 zCoord + 6
); );
} }
return bb; return bb;
} }
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public double getMaxRenderDistanceSquared() { public double getMaxRenderDistanceSquared() {
@ -501,7 +521,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
@Override @Override
public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) { public boolean canProvideInfo(UpgradeType type, int level, boolean extendedInfo) {
return type == UpgradeType.SPEED || type == UpgradeType.POWER; return type == UpgradeType.SPEED || type == UpgradeType.POWER || type == UpgradeType.OVERDRIVE;
} }
@Override @Override
@ -509,9 +529,14 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_electrolyser)); info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_electrolyser));
if(type == UpgradeType.SPEED) { if(type == UpgradeType.SPEED) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_DELAY, "-" + (level * 25) + "%")); info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_DELAY, "-" + (level * 25) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "+" + (level * 100) + "%"));
} }
if(type == UpgradeType.POWER) { if(type == UpgradeType.POWER) {
info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "-" + (level * 25) + "%")); info.add(EnumChatFormatting.GREEN + I18nUtil.resolveKey(this.KEY_CONSUMPTION, "-" + (level * 25) + "%"));
info.add(EnumChatFormatting.RED + I18nUtil.resolveKey(this.KEY_DELAY, "+" + (25) + "%"));
}
if(type == UpgradeType.OVERDRIVE) {
info.add((BobMathUtil.getBlink() ? EnumChatFormatting.RED : EnumChatFormatting.DARK_GRAY) + "YES");
} }
} }
@ -519,6 +544,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
public int getMaxLevel(UpgradeType type) { public int getMaxLevel(UpgradeType type) {
if(type == UpgradeType.SPEED) return 3; if(type == UpgradeType.SPEED) return 3;
if(type == UpgradeType.POWER) return 3; if(type == UpgradeType.POWER) return 3;
if(type == UpgradeType.OVERDRIVE) return 3;
return 0; return 0;
} }
} }

View File

@ -391,7 +391,7 @@ public class TileEntityMachineCrystallizer extends TileEntityMachineBase impleme
public int getMaxLevel(UpgradeType type) { public int getMaxLevel(UpgradeType type) {
if(type == UpgradeType.SPEED) return 3; if(type == UpgradeType.SPEED) return 3;
if(type == UpgradeType.EFFECT) return 3; if(type == UpgradeType.EFFECT) return 3;
if(type == UpgradeType.OVERDRIVE) return 2; if(type == UpgradeType.OVERDRIVE) return 3;
return 0; return 0;
} }
} }