balanced steam and turbine, added reactor interactions

This commit is contained in:
HbmMods 2018-11-08 19:57:32 +01:00
parent bdcb9b3d88
commit 9444dfb296
4 changed files with 193 additions and 44 deletions

View File

@ -476,7 +476,7 @@ public class MachineRecipes {
public static Object[] getBoilerOutput(FluidType type) { public static Object[] getBoilerOutput(FluidType type) {
switch(type) { switch(type) {
case WATER: return new Object[] { FluidType.STEAM, 5, 5, 10000 }; case WATER: return new Object[] { FluidType.STEAM, 500, 5, 10000 };
case STEAM: return new Object[] { FluidType.HOTSTEAM, 5, 50, 30000 }; case STEAM: return new Object[] { FluidType.HOTSTEAM, 5, 50, 30000 };
case HOTSTEAM: return new Object[] { FluidType.SUPERHOTSTEAM, 5, 50, 45000 }; case HOTSTEAM: return new Object[] { FluidType.SUPERHOTSTEAM, 5, 50, 45000 };
case OIL: return new Object[] { FluidType.HOTOIL, 5, 5, 35000 }; case OIL: return new Object[] { FluidType.HOTOIL, 5, 5, 35000 };
@ -490,7 +490,7 @@ public class MachineRecipes {
public static Object[] getTurbineOutput(FluidType type) { public static Object[] getTurbineOutput(FluidType type) {
switch(type) { switch(type) {
case STEAM: return new Object[] { FluidType.WATER, 5, 5, 50 }; case STEAM: return new Object[] { FluidType.WATER, 5, 500, 50 };
case HOTSTEAM: return new Object[] { FluidType.STEAM, 50, 5, 100 }; case HOTSTEAM: return new Object[] { FluidType.STEAM, 50, 5, 100 };
case SUPERHOTSTEAM: return new Object[] { FluidType.HOTSTEAM, 50, 5, 150 }; case SUPERHOTSTEAM: return new Object[] { FluidType.HOTSTEAM, 50, 5, 150 };
} }

View File

@ -72,6 +72,21 @@ public class GUIMachineReactorSmall extends GuiInfoContainer {
"the reactor to function properly!" }; "the reactor to function properly!" };
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 32 + 16, 16, 16, guiLeft - 8, guiTop + 36 + 32 + 16, text3); this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 32 + 16, 16, 16, guiLeft - 8, guiTop + 36 + 32 + 16, text3);
} }
String s = "0";
switch(diFurnace.tanks[2].getTankType()) {
case STEAM: s = "1x"; break;
case HOTSTEAM:s = "10x"; break;
case SUPERHOTSTEAM: s = "100x"; break;
}
String[] text4 = new String[] { "Steam compression switch.",
"Current compression level: " + s};
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 63, guiTop + 107, 14, 18, mouseX, mouseY, text4);
String[] text5 = new String[] { diFurnace.retracting ? "Raise control rods." : "Lower control rods."};
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 52, guiTop + 53, 18, 18, mouseX, mouseY, text5);
} }
@Override @Override
@ -85,7 +100,7 @@ public class GUIMachineReactorSmall extends GuiInfoContainer {
protected void mouseClicked(int x, int y, int i) { protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i); super.mouseClicked(x, y, i);
if(guiLeft + 53 <= x && guiLeft + 53 + 16 > x && guiTop + 54 < y && guiTop + 54 + 16 >= y) { if(guiLeft + 52 <= x && guiLeft + 52 + 16 > x && guiTop + 53 < y && guiTop + 53 + 16 >= y) {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F));
PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, diFurnace.retracting ? 0 : 1, 0)); PacketDispatcher.wrapper.sendToServer(new AuxButtonPacket(diFurnace.xCoord, diFurnace.yCoord, diFurnace.zCoord, diFurnace.retracting ? 0 : 1, 0));
@ -117,6 +132,21 @@ public class GUIMachineReactorSmall extends GuiInfoContainer {
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(diFurnace.tanks[2].getFill() > 0) {
int i = diFurnace.getSteamScaled(88);
//i = (int) Math.min(i, 160);
int offset = 234;
switch(diFurnace.tanks[2].getTankType()) {
case HOTSTEAM: offset += 4; break;
case SUPERHOTSTEAM: offset += 8; break;
}
drawTexturedModalRect(guiLeft + 80, guiTop + 108, 0, offset, i, 4);
}
if(diFurnace.hasHullHeat()) { if(diFurnace.hasHullHeat()) {
int i = diFurnace.getHullHeatScaled(88); int i = diFurnace.getHullHeatScaled(88);

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.machine.MachineGenerator; import com.hbm.blocks.machine.MachineGenerator;
import com.hbm.explosion.ExplosionNukeGeneric; import com.hbm.explosion.ExplosionNukeGeneric;
import com.hbm.handler.FluidTypeHandler.FluidType; import com.hbm.handler.FluidTypeHandler.FluidType;
@ -25,6 +26,7 @@ import com.hbm.potion.HbmPotion;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -66,7 +68,7 @@ public class TileEntityMachineReactorSmall extends TileEntity
tanks = new FluidTank[3]; tanks = new FluidTank[3];
tanks[0] = new FluidTank(FluidType.WATER, 32000, 0); tanks[0] = new FluidTank(FluidType.WATER, 32000, 0);
tanks[1] = new FluidTank(FluidType.COOLANT, 16000, 1); tanks[1] = new FluidTank(FluidType.COOLANT, 16000, 1);
tanks[2] = new FluidTank(FluidType.STEAM, 16000, 2); tanks[2] = new FluidTank(FluidType.STEAM, 8000, 2);
} }
@Override @Override
@ -257,6 +259,10 @@ public class TileEntityMachineReactorSmall extends TileEntity
return (hullHeat * i) / maxHullHeat; return (hullHeat * i) / maxHullHeat;
} }
public int getSteamScaled(int i) {
return (tanks[2].getFill() * i) / tanks[2].getMaxFill();
}
public boolean hasCoreHeat() { public boolean hasCoreHeat() {
return coreHeat > 0; return coreHeat > 0;
} }
@ -310,28 +316,6 @@ public class TileEntityMachineReactorSmall extends TileEntity
if (age == 9 || age == 19) if (age == 9 || age == 19)
fillFluidInit(tanks[2].getTankType()); fillFluidInit(tanks[2].getTankType());
if (tanks[0].getFill() < tanks[0].getMaxFill()) {
if (worldObj.getBlock(xCoord + 1, yCoord + 1, zCoord) == Blocks.water
|| worldObj.getBlock(xCoord + 1, yCoord + 1, zCoord) == Blocks.flowing_water)
tanks[0].setFill(tanks[0].getFill() + 25);
if (worldObj.getBlock(xCoord - 1, yCoord + 1, zCoord) == Blocks.water
|| worldObj.getBlock(xCoord - 1, yCoord + 1, zCoord) == Blocks.flowing_water)
tanks[0].setFill(tanks[0].getFill() + 25);
if (worldObj.getBlock(xCoord, yCoord + 1, zCoord + 1) == Blocks.water
|| worldObj.getBlock(xCoord, yCoord + 1, zCoord + 1) == Blocks.flowing_water)
tanks[0].setFill(tanks[0].getFill() + 25);
if (worldObj.getBlock(xCoord, yCoord + 1, zCoord - 1) == Blocks.water
|| worldObj.getBlock(xCoord, yCoord + 1, zCoord - 1) == Blocks.flowing_water)
tanks[0].setFill(tanks[0].getFill() + 25);
if (tanks[0].getFill() > tanks[0].getMaxFill())
tanks[0].setFill(tanks[0].getMaxFill());
}
tanks[0].loadTank(12, 13, slots); tanks[0].loadTank(12, 13, slots);
tanks[1].loadTank(14, 15, slots); tanks[1].loadTank(14, 15, slots);
@ -360,17 +344,21 @@ public class TileEntityMachineReactorSmall extends TileEntity
1.0F); 1.0F);
} }
for (int i = 0; i < 3; i++)
tanks[i].updateTank(xCoord, yCoord, zCoord);
if (rods >= rodsMax) if (rods >= rodsMax)
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
if (slots[i] != null && slots[i].getItem() instanceof ItemFuelRod) if (slots[i] != null && slots[i].getItem() instanceof ItemFuelRod)
decay(i); decay(i);
} }
coreHeatMod = 1.0;
hullHeatMod = 1.0;
conversionMod = 1.0;
decayMod = 1.0;
getInteractions();
if (this.coreHeat > 0 && this.tanks[1].getFill() > 0 && this.hullHeat < this.maxHullHeat) { if (this.coreHeat > 0 && this.tanks[1].getFill() > 0 && this.hullHeat < this.maxHullHeat) {
this.hullHeat += this.coreHeat * 0.175; this.hullHeat += this.coreHeat * 0.175 * hullHeatMod;
this.coreHeat -= this.coreHeat * 0.1; this.coreHeat -= this.coreHeat * 0.1;
this.tanks[1].setFill(this.tanks[1].getFill() - 10); this.tanks[1].setFill(this.tanks[1].getFill() - 10);
@ -386,11 +374,6 @@ public class TileEntityMachineReactorSmall extends TileEntity
if (this.hullHeat > 0 && this.tanks[0].getFill() > 0) { if (this.hullHeat > 0 && this.tanks[0].getFill() > 0) {
generateSteam(); generateSteam();
this.hullHeat -= this.hullHeat * 0.085; this.hullHeat -= this.hullHeat * 0.085;
this.tanks[0].setFill(this.tanks[0].getFill() - 100);
if (this.tanks[0].getFill() < 0)
this.tanks[0].setFill(0);
} }
if (this.coreHeat > maxCoreHeat) { if (this.coreHeat > maxCoreHeat) {
@ -417,6 +400,9 @@ public class TileEntityMachineReactorSmall extends TileEntity
} }
} }
for (int i = 0; i < 3; i++)
tanks[i].updateTank(xCoord, yCoord, zCoord);
PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, rods, 0)); PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, rods, 0));
PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, retracting ? 1 : 0, 1)); PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, retracting ? 1 : 0, 1));
PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, coreHeat, 2)); PacketDispatcher.wrapper.sendToAll(new AuxGaugePacket(xCoord, yCoord, zCoord, coreHeat, 2));
@ -428,20 +414,151 @@ public class TileEntityMachineReactorSmall extends TileEntity
//function of SHS produced per tick //function of SHS produced per tick
//maxes out at heat% * tank capacity / 20 //maxes out at heat% * tank capacity / 20
int producted = (int) double steam = (((double)hullHeat / (double)maxHullHeat) * ((double)tanks[2].getMaxFill() / 50D)) * conversionMod;
(((double)hullHeat / (double)maxHullHeat) * ((double)tanks[2].getMaxFill() / 20D));
double water = steam;
switch(tanks[2].getTankType()) { switch(tanks[2].getTankType()) {
case STEAM: case STEAM:
water /= 100D;
break; break;
case HOTSTEAM: case HOTSTEAM:
water /= 10;
break; break;
case SUPERHOTSTEAM: case SUPERHOTSTEAM:
break; break;
} }
tanks[0].setFill(tanks[0].getFill() - (int)Math.ceil(water));
tanks[2].setFill(tanks[2].getFill() + (int)Math.floor(steam));
if(tanks[0].getFill() < 0)
tanks[0].setFill(0);
if(tanks[2].getFill() > tanks[2].getMaxFill()) if(tanks[2].getFill() > tanks[2].getMaxFill())
tanks[2].setFill(tanks[2].getMaxFill()); tanks[2].setFill(tanks[2].getMaxFill());
}
private void getInteractions() {
getInteractionForBlock(xCoord + 1, yCoord + 1, zCoord);
getInteractionForBlock(xCoord - 1, yCoord + 1, zCoord);
getInteractionForBlock(xCoord, yCoord + 1, zCoord + 1);
getInteractionForBlock(xCoord, yCoord + 1, zCoord - 1);
TileEntity te1 = worldObj.getTileEntity(xCoord + 2, yCoord, zCoord);
TileEntity te2 = worldObj.getTileEntity(xCoord - 2, yCoord, zCoord);
TileEntity te3 = worldObj.getTileEntity(xCoord, yCoord, zCoord + 2);
TileEntity te4 = worldObj.getTileEntity(xCoord, yCoord, zCoord - 2);
boolean b1 = blocksRad(xCoord + 1, yCoord + 1, zCoord);
boolean b2 = blocksRad(xCoord - 1, yCoord + 1, zCoord);
boolean b3 = blocksRad(xCoord, yCoord + 1, zCoord + 1);
boolean b4 = blocksRad(xCoord, yCoord + 1, zCoord - 1);
TileEntityMachineReactorSmall[] reactors = new TileEntityMachineReactorSmall[4];
reactors[0] = ((te1 instanceof TileEntityMachineReactorSmall && !b1) ? (TileEntityMachineReactorSmall)te1 : null);
reactors[1] = ((te2 instanceof TileEntityMachineReactorSmall && !b2) ? (TileEntityMachineReactorSmall)te2 : null);
reactors[2] = ((te3 instanceof TileEntityMachineReactorSmall && !b3) ? (TileEntityMachineReactorSmall)te3 : null);
reactors[3] = ((te4 instanceof TileEntityMachineReactorSmall && !b4) ? (TileEntityMachineReactorSmall)te4 : null);
for(int i = 0; i < 4; i++) {
if(reactors[i] != null && reactors[i].rods >= rodsMax && reactors[i].getRodCount() > 0) {
decayMod += reactors[i].getRodCount() / 2D;
}
}
}
private double decayMod = 1.0D;
private double coreHeatMod = 1.0D;
private double hullHeatMod = 1.0D;
private double conversionMod = 1.0D;
private void getInteractionForBlock(int x, int y, int z) {
Block b = worldObj.getBlock(x, y, z);
TileEntity te = worldObj.getTileEntity(x, y, z);
if(b == Blocks.lava || b == Blocks.flowing_lava) {
hullHeatMod *= 3;
conversionMod *= 0.5;
} else if(b == Blocks.redstone_block) {
conversionMod *= 1.15;
} else if(b == ModBlocks.block_lead) {
decayMod += 1;
} else if(b == Blocks.water || b == Blocks.flowing_water) {
tanks[0].setFill(tanks[0].getFill() + 25);
if(tanks[0].getFill() > tanks[0].getMaxFill())
tanks[0].setFill(tanks[0].getMaxFill());
} else if(b == ModBlocks.block_niter) {
if(tanks[0].getFill() >= 50 && tanks[1].getFill() + 5 <= tanks[1].getMaxFill()) {
tanks[0].setFill(tanks[0].getFill() - 50);
tanks[1].setFill(tanks[1].getFill() + 5);
}
} else if(te instanceof TileEntityMachineReactor) {
TileEntityMachineReactor reactor = (TileEntityMachineReactor)te;
if(reactor.dualPower < 1)
reactor.dualPower = 1;
} else if(te instanceof TileEntityNukeFurnace) {
TileEntityNukeFurnace reactor = (TileEntityNukeFurnace)te;
if(reactor.dualPower < 1)
reactor.dualPower = 1;
} else if(b == ModBlocks.block_uranium) {
coreHeatMod *= 1.05;
} else if(b == Blocks.coal_block) {
hullHeatMod *= 1.1;
} else if(b == ModBlocks.block_beryllium) {
hullHeatMod *= 0.95;
conversionMod *= 1.05;
} else if(b == ModBlocks.block_schrabidium) {
decayMod += 1;
conversionMod *= 1.25;
hullHeatMod *= 1.1;
} else if(b == ModBlocks.block_waste) {
decayMod += 3;
}
}
private boolean blocksRad(int x, int y, int z) {
Block b = worldObj.getBlock(x, y, z);
if(b == ModBlocks.block_lead || b == ModBlocks.block_desh || b == ModBlocks.brick_concrete)
return true;
if(b.getExplosionResistance(null) >= 100)
return true;
return false;
}
public int getRodCount() {
int count = 0;
for(int i = 0; i < 12; i++) {
if(slots[i] != null && slots[i].getItem() instanceof ItemFuelRod)
count++;
}
return count;
} }
private boolean hasFuelRod(int id) { private boolean hasFuelRod(int id) {
@ -478,9 +595,11 @@ public class TileEntityMachineReactorSmall extends TileEntity
int decay = getNeightbourCount(id) + 1; int decay = getNeightbourCount(id) + 1;
decay *= decayMod;
for (int i = 0; i < decay; i++) { for (int i = 0; i < decay; i++) {
ItemFuelRod rod = ((ItemFuelRod) slots[id].getItem()); ItemFuelRod rod = ((ItemFuelRod) slots[id].getItem());
this.coreHeat += rod.heat; this.coreHeat += rod.heat * coreHeatMod;
ItemFuelRod.setLifeTime(slots[id], ItemFuelRod.getLifeTime(slots[id]) + 1); ItemFuelRod.setLifeTime(slots[id], ItemFuelRod.getLifeTime(slots[id]) + 1);
ItemFuelRod.updateDamage(slots[id]); ItemFuelRod.updateDamage(slots[id]);

View File

@ -45,8 +45,8 @@ public class TileEntityMachineTurbine extends TileEntity implements ISidedInvent
public TileEntityMachineTurbine() { public TileEntityMachineTurbine() {
slots = new ItemStack[7]; slots = new ItemStack[7];
tanks = new FluidTank[2]; tanks = new FluidTank[2];
tanks[0] = new FluidTank(FluidType.STEAM, 8000, 0); tanks[0] = new FluidTank(FluidType.STEAM, 16000, 0);
tanks[1] = new FluidTank(FluidType.WATER, 8000, 1); tanks[1] = new FluidTank(FluidType.WATER, 32000, 1);
} }
@Override @Override
@ -219,12 +219,12 @@ public class TileEntityMachineTurbine extends TileEntity implements ISidedInvent
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
age++; age++;
if(age >= 20) if(age >= 10)
{ {
age = 0; age = 0;
} }
if(age == 9 || age == 19) { if(age == 4 || age == 9) {
fillFluidInit(tanks[1].getTankType()); fillFluidInit(tanks[1].getTankType());
ffgeuaInit(); ffgeuaInit();
} }
@ -239,7 +239,7 @@ public class TileEntityMachineTurbine extends TileEntity implements ISidedInvent
} else { } else {
tanks[1].setTankType((FluidType) outs[0]); tanks[1].setTankType((FluidType) outs[0]);
for(int i = 0; i < tanks[0].getFill() / 50 + 1; i++) { for(int i = 0; i < tanks[0].getFill() / 1000 + 1; i++) {
if(tanks[0].getFill() >= (Integer)outs[2] && tanks[1].getFill() + (Integer)outs[1] <= tanks[1].getMaxFill()) { if(tanks[0].getFill() >= (Integer)outs[2] && tanks[1].getFill() + (Integer)outs[1] <= tanks[1].getMaxFill()) {
tanks[0].setFill(tanks[0].getFill() - (Integer)outs[2]); tanks[0].setFill(tanks[0].getFill() - (Integer)outs[2]);
tanks[1].setFill(tanks[1].getFill() + (Integer)outs[1]); tanks[1].setFill(tanks[1].getFill() + (Integer)outs[1]);
@ -295,7 +295,7 @@ public class TileEntityMachineTurbine extends TileEntity implements ISidedInvent
@Override @Override
public boolean getTact() { public boolean getTact() {
if(age >= 0 && age < 10) if(age >= 0 && age < 5)
{ {
return true; return true;
} }