mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-24 15:00:48 +00:00
Merge pull request #1571 from 70000hp/electrolyzer-improvements
Electrolyzer Improvements part 1
This commit is contained in:
commit
958a099bac
@ -10,8 +10,10 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.inventory.FluidStack;
|
||||
import com.hbm.inventory.RecipesCommon;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
import com.hbm.inventory.recipes.loader.SerializableRecipe;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemFluidIcon;
|
||||
@ -24,9 +26,10 @@ public class ElectrolyserFluidRecipes extends SerializableRecipe {
|
||||
|
||||
@Override
|
||||
public void registerDefaults() {
|
||||
recipes.put(Fluids.WATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.HYDROGEN, 200), new FluidStack(Fluids.OXYGEN, 200)));
|
||||
recipes.put(Fluids.HEAVYWATER, new ElectrolysisRecipe(2_000, new FluidStack(Fluids.DEUTERIUM, 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), 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.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.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;
|
||||
}
|
||||
public static ElectrolysisRecipe getRecipe(FluidType type) {
|
||||
if(type == null)
|
||||
return null;
|
||||
return recipes.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileName() {
|
||||
@ -100,12 +108,23 @@ public class ElectrolyserFluidRecipes extends SerializableRecipe {
|
||||
public FluidStack output2;
|
||||
public int amount;
|
||||
public ItemStack[] byproduct;
|
||||
public int duration;
|
||||
|
||||
public ElectrolysisRecipe(int amount, FluidStack output1, FluidStack output2, ItemStack... byproduct) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
this.amount = amount;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import com.hbm.items.machine.ItemScraps;
|
||||
import com.hbm.items.special.ItemBedrockOreNew;
|
||||
import com.hbm.items.special.ItemBedrockOreNew.BedrockOreGrade;
|
||||
import com.hbm.items.special.ItemBedrockOreNew.BedrockOreType;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.ItemStackUtil;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
@ -134,22 +135,23 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
|
||||
|
||||
for(BedrockOreType type : BedrockOreType.values()) {
|
||||
|
||||
MaterialStack f0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(12));
|
||||
MaterialStack f1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(6));
|
||||
MaterialStack f0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(7));
|
||||
MaterialStack f1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(4));
|
||||
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_FIRST, type)), new ElectrolysisMetalRecipe(
|
||||
f0 != null ? f0 : 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),
|
||||
f1 == null ? ItemBedrockOreNew.extract(type.primary2, 6) : new ItemStack(ModItems.dust),
|
||||
20,
|
||||
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)));
|
||||
|
||||
MaterialStack s0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(6));
|
||||
MaterialStack s1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(12));
|
||||
MaterialStack s0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(4));
|
||||
MaterialStack s1 = ItemBedrockOreNew.toFluid(type.primary2, MaterialShapes.INGOT.q(7));
|
||||
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.PRIMARY_SECOND, type)), new ElectrolysisMetalRecipe(
|
||||
s0 != null ? s0 : 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),
|
||||
s1 == null ? ItemBedrockOreNew.extract(type.primary2, 6) : new ItemStack(ModItems.dust),
|
||||
20,
|
||||
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)));
|
||||
|
||||
MaterialStack c0 = ItemBedrockOreNew.toFluid(type.primary1, MaterialShapes.INGOT.q(2));
|
||||
@ -157,12 +159,15 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
|
||||
recipes.put(new ComparableStack(ItemBedrockOreNew.make(BedrockOreGrade.CRUMBS, type)), new ElectrolysisMetalRecipe(
|
||||
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)),
|
||||
20,
|
||||
c0 == null ? ItemBedrockOreNew.extract(type.primary1, 2) : new ItemStack(ModItems.dust),
|
||||
c1 == null ? ItemBedrockOreNew.extract(type.primary2, 2) : new ItemStack(ModItems.dust)));
|
||||
}
|
||||
}
|
||||
|
||||
public static ElectrolysisMetalRecipe getRecipe(ItemStack stack) {
|
||||
if(stack == null || stack.getItem() == null)
|
||||
return null;
|
||||
|
||||
ComparableStack comp = new ComparableStack(stack).makeSingular();
|
||||
|
||||
@ -180,7 +185,7 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
|
||||
|
||||
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()) {
|
||||
|
||||
@ -266,11 +271,19 @@ public class ElectrolyserMetalRecipes extends SerializableRecipe {
|
||||
public MaterialStack output1;
|
||||
public MaterialStack output2;
|
||||
public ItemStack[] byproduct;
|
||||
public int duration;
|
||||
|
||||
public ElectrolysisMetalRecipe(MaterialStack output1, MaterialStack output2, ItemStack... byproduct) {
|
||||
this.output1 = output1;
|
||||
this.output2 = output2;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.hbm.inventory.gui.GUIElectrolyserMetal;
|
||||
import com.hbm.inventory.material.MaterialShapes;
|
||||
import com.hbm.inventory.material.Mats;
|
||||
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.ElectrolysisRecipe;
|
||||
import com.hbm.inventory.recipes.ElectrolyserMetalRecipes;
|
||||
@ -28,6 +29,7 @@ import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.tileentity.IGUIProvider;
|
||||
import com.hbm.tileentity.IUpgradeInfoProvider;
|
||||
import com.hbm.tileentity.TileEntityMachineBase;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.CrucibleUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
@ -59,11 +61,9 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
public int usageFluid;
|
||||
|
||||
public int progressFluid;
|
||||
public static final int processFluidTimeBase = 20;
|
||||
public int processFluidTime;
|
||||
public int processFluidTime = 100;
|
||||
public int progressOre;
|
||||
public static final int processOreTimeBase = 600;
|
||||
public int processOreTime;
|
||||
public int processOreTime = 600;
|
||||
|
||||
public MaterialStack leftStack;
|
||||
public MaterialStack rightStack;
|
||||
@ -136,30 +136,30 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
int speedLevel = Math.min(UpgradeManager.getLevel(UpgradeType.SPEED), 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;
|
||||
usageFluid = usageFluidBase - usageFluidBase * powerLevel / 4;
|
||||
|
||||
if(this.canProcessFluid()) {
|
||||
this.progressFluid++;
|
||||
this.power -= this.usageFluid;
|
||||
for(int i = 0; i < getCycleCount(); i++) {
|
||||
if (this.canProcessFluid()) {
|
||||
this.progressFluid++;
|
||||
this.power -= this.usageFluid;
|
||||
|
||||
if(this.progressFluid >= this.processFluidTime) {
|
||||
this.processFluids();
|
||||
this.progressFluid = 0;
|
||||
this.markChanged();
|
||||
if (this.progressFluid >= this.getDurationFluid()) {
|
||||
this.processFluids();
|
||||
this.progressFluid = 0;
|
||||
this.markChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(this.canProcesMetal()) {
|
||||
this.progressOre++;
|
||||
this.power -= this.usageOre;
|
||||
if (this.canProcessMetal()) {
|
||||
this.progressOre++;
|
||||
this.power -= this.usageOre;
|
||||
|
||||
if(this.progressOre >= this.processOreTime) {
|
||||
this.processMetal();
|
||||
this.progressOre = 0;
|
||||
this.markChanged();
|
||||
if (this.progressOre >= this.getDurationMetal()) {
|
||||
this.processMetal();
|
||||
this.progressOre = 0;
|
||||
this.markChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
toCast.add(this.leftStack);
|
||||
|
||||
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) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
@ -193,7 +193,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
toCast.add(this.rightStack);
|
||||
|
||||
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) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
@ -215,8 +215,8 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
data.setInteger("progressOre", this.progressOre);
|
||||
data.setInteger("usageOre", this.usageOre);
|
||||
data.setInteger("usageFluid", this.usageFluid);
|
||||
data.setInteger("processFluidTime", this.processFluidTime);
|
||||
data.setInteger("processOreTime", this.processOreTime);
|
||||
data.setInteger("processFluidTime", this.getDurationFluid());
|
||||
data.setInteger("processOreTime", this.getDurationMetal());
|
||||
if(this.leftStack != null) {
|
||||
data.setInteger("leftType", leftStack.material.id);
|
||||
data.setInteger("leftAmount", leftStack.amount);
|
||||
@ -312,7 +312,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canProcesMetal() {
|
||||
public boolean canProcessMetal() {
|
||||
|
||||
if(slots[14] == null) return false;
|
||||
if(this.power < usageOre) return false;
|
||||
@ -380,6 +380,25 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
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
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
@ -403,8 +422,8 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
nbt.setLong("power", this.power);
|
||||
nbt.setInteger("progressFluid", this.progressFluid);
|
||||
nbt.setInteger("progressOre", this.progressOre);
|
||||
nbt.setInteger("processFluidTime", this.processFluidTime);
|
||||
nbt.setInteger("processOreTime", this.processOreTime);
|
||||
nbt.setInteger("processFluidTime", getDurationFluid());
|
||||
nbt.setInteger("processOreTime", getDurationMetal());
|
||||
if(this.leftStack != null) {
|
||||
nbt.setInteger("leftType", leftStack.material.id);
|
||||
nbt.setInteger("leftAmount", leftStack.amount);
|
||||
@ -414,6 +433,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
nbt.setInteger("rightAmount", rightStack.amount);
|
||||
}
|
||||
for(int i = 0; i < 4; i++) tanks[i].writeToNBT(nbt, "t" + i);
|
||||
|
||||
}
|
||||
|
||||
AxisAlignedBB bb = null;
|
||||
@ -501,7 +521,7 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
|
||||
@Override
|
||||
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
|
||||
@ -509,9 +529,14 @@ public class TileEntityElectrolyser extends TileEntityMachineBase implements IEn
|
||||
info.add(IUpgradeInfoProvider.getStandardLabel(ModBlocks.machine_electrolyser));
|
||||
if(type == UpgradeType.SPEED) {
|
||||
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) {
|
||||
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) {
|
||||
if(type == UpgradeType.SPEED) return 3;
|
||||
if(type == UpgradeType.POWER) return 3;
|
||||
if(type == UpgradeType.OVERDRIVE) return 3;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ public class TileEntityMachineCrystallizer extends TileEntityMachineBase impleme
|
||||
public int getMaxLevel(UpgradeType type) {
|
||||
if(type == UpgradeType.SPEED) return 3;
|
||||
if(type == UpgradeType.EFFECT) return 3;
|
||||
if(type == UpgradeType.OVERDRIVE) return 2;
|
||||
if(type == UpgradeType.OVERDRIVE) return 3;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user