mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
i want to die: cover yourself in oil edition
This commit is contained in:
parent
36cef5e2fe
commit
2f0c9de15b
@ -700,7 +700,6 @@ public class ModBlocks {
|
||||
public static final int guiID_rtg_furnace = 14;
|
||||
|
||||
public static Block machine_generator;
|
||||
public static final int guiID_machine_generator = 15;
|
||||
|
||||
public static Block machine_industrial_generator;
|
||||
public static final int guiID_machine_industrial_generator = 39;
|
||||
|
||||
@ -14,30 +14,29 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class MachineGenerator extends Block {
|
||||
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private IIcon iconSide;
|
||||
|
||||
public MachineGenerator(Material p_i45386_1_) {
|
||||
super(p_i45386_1_);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
this.iconSide = iconRegister.registerIcon(RefStrings.MODID + ":machine_generator_side");
|
||||
this.blockIcon = iconRegister.registerIcon(RefStrings.MODID + ":machine_generator");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int metadata) {
|
||||
return side == 0 ? blockIcon : (side == 1 ? blockIcon : iconSide);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_)
|
||||
{
|
||||
return ModItems.circuit_targeting_tier3;
|
||||
}
|
||||
public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) {
|
||||
return ModItems.circuit_targeting_tier3;
|
||||
}
|
||||
}
|
||||
|
||||
78
src/main/java/com/hbm/config/MachineDynConfig.java
Normal file
78
src/main/java/com/hbm/config/MachineDynConfig.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.hbm.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.main.MainRegistry;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.TileMappings;
|
||||
|
||||
public class MachineDynConfig {
|
||||
|
||||
public static final Gson gson = new Gson();
|
||||
|
||||
public static void initialize() {
|
||||
File dir = new File(MainRegistry.configDir.getAbsolutePath() + File.separatorChar + "hbmConfig");
|
||||
|
||||
if(!dir.exists()) {
|
||||
if(!dir.mkdir()) {
|
||||
throw new IllegalStateException("Unable to make recipe directory " + dir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
//it's a lit of dummy tile entity instances that are only used once in order to make the init work
|
||||
//not exactly a great solution but this little smear of ugliness carries all the good parts on its back so i will allow it
|
||||
List<IConfigurableMachine> dummies = new ArrayList();
|
||||
TileMappings.configurables.forEach(x -> { try { dummies.add(x.newInstance()); } catch(Exception ex) {} }); // <- lambda comes with a hidden little try/catch block hidden inside, like a kinder surprise egg that is filled with shit
|
||||
File file = new File(dir.getAbsolutePath() + File.separatorChar + "hbmMachines.json");
|
||||
|
||||
//dummies.forEach(x -> x.initDefaults());
|
||||
|
||||
//and now for the good part
|
||||
try { // <- useless overarching try/catch to make the reader shut up
|
||||
|
||||
if(file.exists()) {
|
||||
JsonObject json = gson.fromJson(new FileReader(file), JsonObject.class);
|
||||
|
||||
for(IConfigurableMachine dummy : dummies) {
|
||||
|
||||
try {
|
||||
JsonElement element = json.get(dummy.getConfigName());
|
||||
JsonObject obj = element != null ? element.getAsJsonObject() : new JsonObject();
|
||||
|
||||
//defaults usually already exist at this point, if not we can declare them before the actual reading part
|
||||
dummy.readIfPresent(obj);
|
||||
|
||||
} catch(Exception ex) { } // <- individual try/catch blocks so a single config breaking doesn't affect other machines. we only got a few dozen of these and it only happens once on startup so who the hell cares
|
||||
}
|
||||
}
|
||||
|
||||
JsonWriter writer = new JsonWriter(new FileWriter(file));
|
||||
writer.setIndent(" ");
|
||||
writer.beginObject();
|
||||
|
||||
for(IConfigurableMachine dummy : dummies) {
|
||||
|
||||
try {
|
||||
writer.name(dummy.getConfigName()).beginObject();
|
||||
dummy.writeConfig(writer);
|
||||
writer.endObject();
|
||||
|
||||
} catch(Exception ex) { } // <- more looped try/catch goodness because i hate myself
|
||||
}
|
||||
|
||||
writer.endObject();
|
||||
writer.close();
|
||||
|
||||
//and that was the entire magic, in a mere 50 lines
|
||||
|
||||
} catch(Exception ex) { }
|
||||
}
|
||||
}
|
||||
@ -17,7 +17,6 @@ import com.hbm.tileentity.machine.oil.*;
|
||||
import com.hbm.tileentity.machine.rbmk.*;
|
||||
import com.hbm.tileentity.machine.storage.*;
|
||||
import com.hbm.tileentity.turret.*;
|
||||
import com.hbm.wiaj.GuiWorldInAJar;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -163,13 +162,6 @@ public class GUIHandler implements IGuiHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_generator: {
|
||||
if(entity instanceof TileEntityMachineGenerator) {
|
||||
return new ContainerGenerator(player.inventory, (TileEntityMachineGenerator) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_electric_furnace: {
|
||||
if(entity instanceof TileEntityMachineElectricFurnace) {
|
||||
return new ContainerElectricFurnace(player.inventory, (TileEntityMachineElectricFurnace) entity);
|
||||
@ -968,13 +960,6 @@ public class GUIHandler implements IGuiHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_machine_generator: {
|
||||
if(entity instanceof TileEntityMachineGenerator) {
|
||||
return new GUIMachineGenerator(player.inventory, (TileEntityMachineGenerator) entity);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
case ModBlocks.guiID_electric_furnace: {
|
||||
if(entity instanceof TileEntityMachineElectricFurnace) {
|
||||
return new GUIMachineElectricFurnace(player.inventory, (TileEntityMachineElectricFurnace) entity);
|
||||
|
||||
@ -1,122 +0,0 @@
|
||||
package com.hbm.inventory.container;
|
||||
|
||||
import com.hbm.inventory.SlotMachineOutput;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGenerator;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerGenerator extends Container {
|
||||
|
||||
private TileEntityMachineGenerator diFurnace;
|
||||
|
||||
private int heat;
|
||||
|
||||
public ContainerGenerator(InventoryPlayer invPlayer, TileEntityMachineGenerator tedf) {
|
||||
|
||||
diFurnace = tedf;
|
||||
|
||||
this.addSlotToContainer(new Slot(tedf, 0, 116, 36));
|
||||
this.addSlotToContainer(new Slot(tedf, 1, 134, 36));
|
||||
this.addSlotToContainer(new Slot(tedf, 2, 152, 36));
|
||||
this.addSlotToContainer(new Slot(tedf, 3, 116, 54));
|
||||
this.addSlotToContainer(new Slot(tedf, 4, 134, 54));
|
||||
this.addSlotToContainer(new Slot(tedf, 5, 152, 54));
|
||||
this.addSlotToContainer(new Slot(tedf, 6, 116, 72));
|
||||
this.addSlotToContainer(new Slot(tedf, 7, 134, 72));
|
||||
this.addSlotToContainer(new Slot(tedf, 8, 152, 72));
|
||||
this.addSlotToContainer(new Slot(tedf, 9, 8, 90));
|
||||
this.addSlotToContainer(new Slot(tedf, 10, 26, 90));
|
||||
this.addSlotToContainer(new Slot(tedf, 11, 62, 90));
|
||||
this.addSlotToContainer(new SlotMachineOutput(tedf, 12, 8, 90 + 18));
|
||||
this.addSlotToContainer(new SlotMachineOutput(tedf, 13, 26, 90 + 18));
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
for(int j = 0; j < 9; j++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18 + 56));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 9; i++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142 + 56));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 1, this.diFurnace.heat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int par2)
|
||||
{
|
||||
ItemStack var3 = null;
|
||||
Slot var4 = (Slot) this.inventorySlots.get(par2);
|
||||
|
||||
if (var4 != null && var4.getHasStack())
|
||||
{
|
||||
ItemStack var5 = var4.getStack();
|
||||
var3 = var5.copy();
|
||||
|
||||
if (par2 <= 11) {
|
||||
if (!this.mergeItemStack(var5, 12, this.inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var5, 0, 12, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var5.stackSize == 0)
|
||||
{
|
||||
var4.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var4.onSlotChanged();
|
||||
}
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return diFurnace.isUseableByPlayer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
|
||||
for(int i = 0; i < this.crafters.size(); i++)
|
||||
{
|
||||
ICrafting par1 = (ICrafting)this.crafters.get(i);
|
||||
|
||||
if(this.heat != this.diFurnace.heat)
|
||||
{
|
||||
par1.sendProgressBarUpdate(this, 1, this.diFurnace.heat);
|
||||
}
|
||||
}
|
||||
|
||||
this.heat = this.diFurnace.heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgressBar(int i, int j) {
|
||||
if(i == 1)
|
||||
{
|
||||
diFurnace.heat = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,81 +0,0 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerGenerator;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineGenerator;
|
||||
|
||||
public class GUIMachineGenerator extends GuiInfoContainer {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_generator.png");
|
||||
private TileEntityMachineGenerator diFurnace;
|
||||
|
||||
public GUIMachineGenerator(InventoryPlayer invPlayer, TileEntityMachineGenerator tedf) {
|
||||
super(new ContainerGenerator(invPlayer, tedf));
|
||||
diFurnace = tedf;
|
||||
|
||||
this.xSize = 176;
|
||||
this.ySize = 222;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||
super.drawScreen(mouseX, mouseY, f);
|
||||
|
||||
diFurnace.tanks[0].renderTankInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 88 - 52, 16, 52);
|
||||
diFurnace.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 88 - 52, 16, 52);
|
||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 62, guiTop + 88 - 52, 16, 52, diFurnace.power, diFurnace.powerMax);
|
||||
|
||||
if(diFurnace.tanks[0].getFill() <= 0) {
|
||||
String[] text = new String[] { "Error: Water is required for",
|
||||
"the reactor to function properly!" };
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36, 16, 16, guiLeft - 8, guiTop + 36 + 16, text);
|
||||
}
|
||||
|
||||
if(diFurnace.tanks[1].getFill() <= 0) {
|
||||
String[] text1 = new String[] { "Use of coolant is advised." };
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 16, 16, 16, guiLeft - 8, guiTop + 36 + 16, text1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int i, int j) {
|
||||
String name = this.diFurnace.hasCustomInventoryName() ? this.diFurnace.getInventoryName() : I18n.format(this.diFurnace.getInventoryName());
|
||||
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
|
||||
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if(diFurnace.hasPower()) {
|
||||
int i = (int)diFurnace.getPowerScaled(52);
|
||||
drawTexturedModalRect(guiLeft + 62, guiTop + 88 - i, 224, 52 - i, 16, i);
|
||||
}
|
||||
|
||||
if(diFurnace.hasHeat()) {
|
||||
int i = diFurnace.getHeatScaled(52);
|
||||
drawTexturedModalRect(guiLeft + 98, guiTop + 88 - i, 208, 52 - i, 16, i);
|
||||
}
|
||||
|
||||
if(diFurnace.tanks[0].getFill() <= 0)
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 6);
|
||||
|
||||
if(diFurnace.tanks[1].getFill() <= 0)
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36 + 16, 16, 16, 7);
|
||||
|
||||
diFurnace.tanks[0].renderTank(guiLeft + 8, guiTop + 88, this.zLevel, 16, 52);
|
||||
diFurnace.tanks[1].renderTank(guiLeft + 26, guiTop + 88, this.zLevel, 16, 52);
|
||||
}
|
||||
}
|
||||
@ -305,6 +305,7 @@ public class MainRegistry {
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GUIHandler());
|
||||
|
||||
TileMappings.writeMappings();
|
||||
MachineDynConfig.initialize();
|
||||
|
||||
for(Entry<Class<? extends TileEntity>, String[]> e : TileMappings.map.entrySet()) {
|
||||
|
||||
|
||||
28
src/main/java/com/hbm/tileentity/IConfigurableMachine.java
Normal file
28
src/main/java/com/hbm/tileentity/IConfigurableMachine.java
Normal file
@ -0,0 +1,28 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
public interface IConfigurableMachine {
|
||||
|
||||
/* the name for the JOSN object for this machine */
|
||||
public String getConfigName();
|
||||
/* reads the JSON object and sets the machine's parameters, use defaults and ignore if a value is not yet present */
|
||||
public void readIfPresent(JsonObject obj);
|
||||
/* writes the entire config for this machine using the relevant values */
|
||||
public void writeConfig(JsonWriter writer) throws IOException;
|
||||
|
||||
public static boolean grab(JsonObject obj, String name, boolean def) {
|
||||
return obj.has(name) ? obj.get(name).getAsBoolean() : def;
|
||||
}
|
||||
|
||||
public static int grab(JsonObject obj, String name, int def) {
|
||||
return obj.has(name) ? obj.get(name).getAsInt() : def;
|
||||
}
|
||||
|
||||
public static double grab(JsonObject obj, String name, double def) {
|
||||
return obj.has(name) ? obj.get(name).getAsDouble() : def;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,8 @@
|
||||
package com.hbm.tileentity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.bomb.BlockVolcano.TileEntityVolcanoCore;
|
||||
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
|
||||
@ -28,6 +30,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
public class TileMappings {
|
||||
|
||||
public static HashMap<Class<? extends TileEntity>, String[]> map = new HashMap();
|
||||
public static List<Class<? extends IConfigurableMachine>> configurables = new ArrayList();
|
||||
|
||||
public static void writeMappings() {
|
||||
put(TileEntityTestBombAdvanced.class, "tilentity_testbombadvanced");
|
||||
@ -42,7 +45,6 @@ public class TileMappings {
|
||||
put(TileEntityMachineReactorBreeding.class, "tileentity_reactor");
|
||||
put(TileEntityNukeFurnace.class, "tileentity_nukefurnace");
|
||||
put(TileEntityRtgFurnace.class, "tileentity_rtgfurnace");
|
||||
put(TileEntityMachineGenerator.class, "tileentity_generator");
|
||||
put(TileEntityMachineElectricFurnace.class, "tileentity_electric_furnace");
|
||||
put(TileEntityDecoTapeRecorder.class, "tileentity_taperecorder");
|
||||
put(TileEntityDecoSteelPoles.class, "tileentity_steelpoles");
|
||||
@ -330,5 +332,9 @@ public class TileMappings {
|
||||
if((IFluidSource.class.isAssignableFrom(clazz) || IFluidAcceptor.class.isAssignableFrom(clazz)) && !IFluidConnector.class.isAssignableFrom(clazz)) {
|
||||
LoggingUtil.errorWithHighlight(clazz.getCanonicalName() + " implements the old interfaces but not IFluidConnector!");
|
||||
}
|
||||
|
||||
if(IConfigurableMachine.class.isAssignableFrom(clazz)) {
|
||||
configurables.add((Class<? extends IConfigurableMachine>) clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.explosion.vanillant.ExplosionVNT;
|
||||
import com.hbm.explosion.vanillant.standard.EntityProcessorStandard;
|
||||
@ -17,6 +20,7 @@ import com.hbm.inventory.fluid.trait.FT_Heatable;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingStep;
|
||||
import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
@ -30,14 +34,17 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluidSource, IFluidAcceptor, INBTPacketReceiver, IFluidStandardTransceiver {
|
||||
public class TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluidSource, IFluidAcceptor, INBTPacketReceiver, IFluidStandardTransceiver, IConfigurableMachine {
|
||||
|
||||
public int heat;
|
||||
public static final int maxHeat = 12_800_000; //the heat required to turn 64k of water into steam
|
||||
public static final double diffusion = 0.1D;
|
||||
public FluidTank[] tanks;
|
||||
public List<IFluidAcceptor> list = new ArrayList();
|
||||
public boolean hasExploded = false;
|
||||
|
||||
/* CONFIGURABLE */
|
||||
public static int maxHeat = 12_800_000; //the heat required to turn 64k of water into steam
|
||||
public static double diffusion = 0.1D;
|
||||
public static boolean canExplode = true;
|
||||
|
||||
public TileEntityHeatBoiler() {
|
||||
this.tanks = new FluidTank[2];
|
||||
@ -145,7 +152,7 @@ public class TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluid
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 2, zCoord + 0.5, "hbm:block.boilerGroan", 0.5F, 1.0F);
|
||||
}
|
||||
|
||||
if(outputOps == 0) {
|
||||
if(outputOps == 0 && canExplode) {
|
||||
this.hasExploded = true;
|
||||
BlockDummyable.safeRem = true;
|
||||
for(int x = xCoord - 1; x <= xCoord + 1; x++) {
|
||||
@ -305,4 +312,23 @@ public class TileEntityHeatBoiler extends TileEntityLoadedBase implements IFluid
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "boiler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
maxHeat = IConfigurableMachine.grab(obj, "I:maxHeat", maxHeat);
|
||||
diffusion = IConfigurableMachine.grab(obj, "D:diffusion", diffusion);
|
||||
canExplode = IConfigurableMachine.grab(obj, "B:canExplode", canExplode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("I:maxHeat").value(maxHeat);
|
||||
writer.name("D:diffusion").value(diffusion);
|
||||
writer.name("B:canExplode").value(canExplode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,517 +0,0 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.blocks.machine.MachineGenerator;
|
||||
import com.hbm.explosion.ExplosionNukeGeneric;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.inventory.fluid.tank.FluidTank;
|
||||
import com.hbm.items.ModItems;
|
||||
import com.hbm.items.machine.ItemFuelRod;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.AuxElectricityPacket;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
|
||||
import api.hbm.energy.IBatteryItem;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
@Deprecated //y'know, the single block reactor
|
||||
public class TileEntityMachineGenerator extends TileEntity implements ISidedInventory {
|
||||
|
||||
private ItemStack slots[];
|
||||
|
||||
public int heat;
|
||||
public final int heatMax = 100000;
|
||||
public long power;
|
||||
public final long powerMax = 100000;
|
||||
public boolean isLoaded = false;
|
||||
public FluidTank[] tanks;
|
||||
|
||||
private static final int[] slots_top = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8};
|
||||
private static final int[] slots_bottom = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
|
||||
private static final int[] slots_side = new int[] {9, 10, 11};
|
||||
|
||||
private String customName;
|
||||
|
||||
public TileEntityMachineGenerator() {
|
||||
slots = new ItemStack[14];
|
||||
tanks = new FluidTank[2];
|
||||
tanks[0] = new FluidTank(Fluids.WATER, 32000, 0);
|
||||
tanks[1] = new FluidTank(Fluids.COOLANT, 16000, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return slots.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return slots[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemStack) {
|
||||
slots[i] = itemStack;
|
||||
if(itemStack != null && itemStack.stackSize > getInventoryStackLimit())
|
||||
{
|
||||
itemStack.stackSize = getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return this.hasCustomInventoryName() ? this.customName : "container.generator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return this.customName != null && this.customName.length() > 0;
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
this.customName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
if(worldObj.getTileEntity(xCoord, yCoord, zCoord) != this)
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <=64;
|
||||
}
|
||||
}
|
||||
|
||||
//You scrubs aren't needed for anything (right now)
|
||||
@Override
|
||||
public void openInventory() {}
|
||||
@Override
|
||||
public void closeInventory() {}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
if(i == 0 ||
|
||||
i == 1 ||
|
||||
i == 2 ||
|
||||
i == 3 ||
|
||||
i == 4 ||
|
||||
i == 5 ||
|
||||
i == 6 ||
|
||||
i == 7 ||
|
||||
i == 8)
|
||||
if(itemStack.getItem() instanceof ItemFuelRod)
|
||||
return true;
|
||||
if(i == 9)
|
||||
if(itemStack.getItem() == Items.water_bucket)
|
||||
return true;
|
||||
if(i == 10)
|
||||
if(itemStack.getItem() == ModItems.fluid_tank_full)
|
||||
return true;
|
||||
if(i == 11)
|
||||
if(itemStack.getItem() instanceof IBatteryItem)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if(slots[i] != null)
|
||||
{
|
||||
if(slots[i].stackSize <= j)
|
||||
{
|
||||
ItemStack itemStack = slots[i];
|
||||
slots[i] = null;
|
||||
return itemStack;
|
||||
}
|
||||
ItemStack itemStack1 = slots[i].splitStack(j);
|
||||
if (slots[i].stackSize == 0)
|
||||
{
|
||||
slots[i] = null;
|
||||
}
|
||||
|
||||
return itemStack1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
NBTTagList list = nbt.getTagList("items", 10);
|
||||
|
||||
power = nbt.getLong("power");
|
||||
heat = nbt.getInteger("heat");
|
||||
slots = new ItemStack[getSizeInventory()];
|
||||
tanks[0].readFromNBT(nbt, "water");
|
||||
tanks[1].readFromNBT(nbt, "coolant");
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++)
|
||||
{
|
||||
NBTTagCompound nbt1 = list.getCompoundTagAt(i);
|
||||
byte b0 = nbt1.getByte("slot");
|
||||
if(b0 >= 0 && b0 < slots.length)
|
||||
{
|
||||
slots[b0] = ItemStack.loadItemStackFromNBT(nbt1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setLong("power", power);
|
||||
nbt.setInteger("heat", heat);
|
||||
NBTTagList list = new NBTTagList();
|
||||
tanks[0].writeToNBT(nbt, "water");
|
||||
tanks[1].writeToNBT(nbt, "coolant");
|
||||
|
||||
for(int i = 0; i < slots.length; i++)
|
||||
{
|
||||
if(slots[i] != null)
|
||||
{
|
||||
NBTTagCompound nbt1 = new NBTTagCompound();
|
||||
nbt1.setByte("slot", (byte)i);
|
||||
slots[i].writeToNBT(nbt1);
|
||||
list.appendTag(nbt1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("items", list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int p_94128_1_)
|
||||
{
|
||||
return p_94128_1_ == 0 ? slots_bottom : (p_94128_1_ == 1 ? slots_top : slots_side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int i, ItemStack itemStack, int j) {
|
||||
return this.isItemValidForSlot(i, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int i, ItemStack itemStack, int j) {
|
||||
if(i == 0 ||
|
||||
i == 1 ||
|
||||
i == 2 ||
|
||||
i == 3 ||
|
||||
i == 4 ||
|
||||
i == 5 ||
|
||||
i == 6 ||
|
||||
i == 7 ||
|
||||
i == 8)
|
||||
/*if(itemStack.getItem() == ModItems.rod_uranium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_dual_uranium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_quad_uranium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_plutonium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_dual_plutonium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_quad_plutonium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_mox_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_dual_mox_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_quad_mox_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_schrabidium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_dual_schrabidium_fuel_depleted ||
|
||||
itemStack.getItem() == ModItems.rod_quad_schrabidium_fuel_depleted)*/
|
||||
return true;
|
||||
if(i == 9 || i == 10)
|
||||
if(itemStack.getItem() == Items.bucket || itemStack.getItem() == ModItems.rod_empty || itemStack.getItem() == ModItems.rod_dual_empty || itemStack.getItem() == ModItems.rod_quad_empty)
|
||||
return true;
|
||||
if(i == 11)
|
||||
if (itemStack.getItem() instanceof IBatteryItem && ((IBatteryItem)itemStack.getItem()).getCharge(itemStack) == ((IBatteryItem)itemStack.getItem()).getMaxCharge())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getPowerScaled(long i) {
|
||||
return (power * i) / powerMax;
|
||||
}
|
||||
|
||||
public int getHeatScaled(int i) {
|
||||
return (heat * i) / heatMax;
|
||||
}
|
||||
|
||||
public boolean hasPower() {
|
||||
return power > 0;
|
||||
}
|
||||
|
||||
public boolean hasHeat() {
|
||||
return heat > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
tanks[0].loadTank(9, 12, slots);
|
||||
tanks[1].loadTank(10, 13, slots);
|
||||
|
||||
for(int i = 0; i < 2; i++)
|
||||
tanks[i].updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
|
||||
|
||||
//Batteries
|
||||
power = Library.chargeItemsFromTE(slots, 11, power, powerMax);
|
||||
|
||||
/*for(int i = 0; i < 9; i++)
|
||||
{
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_uranium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(100);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_uranium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_dual_uranium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(100);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_dual_uranium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_quad_uranium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(100);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_quad_uranium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_plutonium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(2);
|
||||
attemptPower(150);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_plutonium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_dual_plutonium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(2);
|
||||
attemptPower(150);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_dual_plutonium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_quad_plutonium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(2);
|
||||
attemptPower(150);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_quad_plutonium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_mox_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(50);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_mox_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_dual_mox_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(50);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_dual_mox_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_quad_mox_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(1);
|
||||
attemptPower(50);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_quad_mox_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_schrabidium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(10);
|
||||
attemptPower(25000);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_schrabidium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_dual_schrabidium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(10);
|
||||
attemptPower(25000);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_dual_schrabidium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
if(slots[i] != null && slots[i].getItem() == ModItems.rod_quad_schrabidium_fuel)
|
||||
{
|
||||
int j = ItemFuelRod.getLifeTime(slots[i]);
|
||||
ItemFuelRod.setLifeTime(slots[i], j + 1);
|
||||
attemptHeat(10);
|
||||
attemptPower(25000);
|
||||
|
||||
if(ItemFuelRod.getLifeTime(slots[i]) == ((ItemFuelRod)slots[i].getItem()).lifeTime)
|
||||
{
|
||||
this.slots[i] = new ItemStack(ModItems.rod_quad_schrabidium_fuel_depleted);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if(this.power > powerMax)
|
||||
{
|
||||
this.power = powerMax;
|
||||
}
|
||||
|
||||
if(this.heat > heatMax)
|
||||
{
|
||||
this.explode();
|
||||
}
|
||||
|
||||
if(((slots[0] != null && slots[0].getItem() instanceof ItemFuelRod) || slots[0] == null) &&
|
||||
((slots[1] != null && !(slots[1].getItem() instanceof ItemFuelRod)) || slots[1] == null) &&
|
||||
((slots[2] != null && !(slots[2].getItem() instanceof ItemFuelRod)) || slots[2] == null) &&
|
||||
((slots[3] != null && !(slots[3].getItem() instanceof ItemFuelRod)) || slots[3] == null) &&
|
||||
((slots[4] != null && !(slots[4].getItem() instanceof ItemFuelRod)) || slots[4] == null) &&
|
||||
((slots[5] != null && !(slots[5].getItem() instanceof ItemFuelRod)) || slots[5] == null) &&
|
||||
((slots[6] != null && !(slots[6].getItem() instanceof ItemFuelRod)) || slots[6] == null) &&
|
||||
((slots[7] != null && !(slots[7].getItem() instanceof ItemFuelRod)) || slots[7] == null) &&
|
||||
((slots[8] != null && !(slots[8].getItem() instanceof ItemFuelRod)) || slots[8] == null))
|
||||
{
|
||||
if(this.heat - 10 >= 0 && tanks[1].getFill() - 2 >= 0)
|
||||
{
|
||||
this.heat -= 10;
|
||||
this.tanks[1].setFill(tanks[1].getFill() - 2);
|
||||
}
|
||||
|
||||
if(this.heat < 10 && heat != 0 && this.tanks[1].getFill() != 0)
|
||||
{
|
||||
this.heat--;
|
||||
this.tanks[1].setFill(tanks[1].getFill() - 1);
|
||||
}
|
||||
|
||||
if(this.heat != 0 && this.tanks[1].getFill() == 0)
|
||||
{
|
||||
this.heat--;
|
||||
}
|
||||
|
||||
if(this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) instanceof MachineGenerator)
|
||||
this.isLoaded = false;
|
||||
|
||||
} else {
|
||||
|
||||
if(this.worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord) instanceof MachineGenerator)
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxElectricityPacket(xCoord, yCoord, zCoord, power), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 50));
|
||||
}
|
||||
}
|
||||
|
||||
public void attemptPower(int i) {
|
||||
|
||||
int j = (int) Math.ceil(i / 100);
|
||||
|
||||
if(this.tanks[0].getFill() - j >= 0)
|
||||
{
|
||||
this.power += i;
|
||||
if(j > tanks[0].getMaxFill() / 25)
|
||||
j = tanks[0].getMaxFill() / 25;
|
||||
this.tanks[0].setFill(tanks[0].getFill() - j);
|
||||
}
|
||||
}
|
||||
|
||||
public void attemptHeat(int i) {
|
||||
Random rand = new Random();
|
||||
|
||||
int j = rand.nextInt(i + 1);
|
||||
|
||||
if(this.tanks[1].getFill() - j >= 0)
|
||||
{
|
||||
this.tanks[1].setFill(tanks[1].getFill() - j);
|
||||
} else {
|
||||
this.heat += i;
|
||||
}
|
||||
}
|
||||
|
||||
public void explode() {
|
||||
for(int i = 0; i < slots.length; i++)
|
||||
{
|
||||
this.slots[i] = null;
|
||||
}
|
||||
|
||||
worldObj.createExplosion(null, this.xCoord, this.yCoord, this.zCoord, 18.0F, true);
|
||||
ExplosionNukeGeneric.waste(worldObj, this.xCoord, this.yCoord, this.zCoord, 35);
|
||||
worldObj.setBlock(this.xCoord, this.yCoord, this.zCoord, Blocks.flowing_lava);
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,14 @@
|
||||
package com.hbm.tileentity.machine;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.blocks.ModBlocks;
|
||||
import com.hbm.entity.projectile.EntityCog;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.tileentity.IConfigurableMachine;
|
||||
import com.hbm.tileentity.INBTPacketReceiver;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
@ -17,18 +22,23 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityStirling extends TileEntityLoadedBase implements INBTPacketReceiver, IEnergyGenerator {
|
||||
public class TileEntityStirling extends TileEntityLoadedBase implements INBTPacketReceiver, IEnergyGenerator, IConfigurableMachine {
|
||||
|
||||
public long powerBuffer;
|
||||
public int heat;
|
||||
public static final double diffusion = 0.1D;
|
||||
public static final double efficiency = 0.5D;
|
||||
private int warnCooldown = 0;
|
||||
private int overspeed = 0;
|
||||
public boolean hasCog = true;
|
||||
|
||||
public float spin;
|
||||
public float lastSpin;
|
||||
|
||||
/* CONFIGURABLE CONSTANTS */
|
||||
public static double diffusion = 0.1D;
|
||||
public static double efficiency = 0.5D;
|
||||
public static int maxHeatNormal = 300;
|
||||
public static int maxHeatSteel = 1500;
|
||||
public static int overspeedLimit = 300;
|
||||
|
||||
@Override
|
||||
public void updateEntity() {
|
||||
@ -52,7 +62,7 @@ public class TileEntityStirling extends TileEntityLoadedBase implements INBTPack
|
||||
worldObj.playSoundEffect(xCoord + 0.5, yCoord + 1, zCoord + 0.5, "hbm:block.warnOverspeed", 2.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(overspeed > 300) {
|
||||
if(overspeed > overspeedLimit) {
|
||||
this.hasCog = false;
|
||||
this.worldObj.newExplosion(null, xCoord + 0.5, yCoord + 1, zCoord + 0.5, 5F, false, false);
|
||||
|
||||
@ -207,4 +217,27 @@ public class TileEntityStirling extends TileEntityLoadedBase implements INBTPack
|
||||
public double getMaxRenderDistanceSquared() {
|
||||
return 65536.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigName() {
|
||||
return "stirling";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readIfPresent(JsonObject obj) {
|
||||
diffusion = IConfigurableMachine.grab(obj, "D:diffusion", diffusion);
|
||||
efficiency = IConfigurableMachine.grab(obj, "D:efficiency", efficiency);
|
||||
maxHeatNormal = IConfigurableMachine.grab(obj, "I:maxHeatNormal", maxHeatNormal);
|
||||
maxHeatSteel = IConfigurableMachine.grab(obj, "I:maxHeatSteel", maxHeatSteel);
|
||||
overspeedLimit = IConfigurableMachine.grab(obj, "I:overspeedLimit", overspeedLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeConfig(JsonWriter writer) throws IOException {
|
||||
writer.name("D:diffusion").value(diffusion);
|
||||
writer.name("D:efficiency").value(efficiency);
|
||||
writer.name("I:maxHeatNormal").value(maxHeatNormal);
|
||||
writer.name("I:maxHeatSteel").value(maxHeatSteel);
|
||||
writer.name("I:overspeedLimit").value(overspeedLimit);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user