diff --git a/assets/hbm/sounds.json b/assets/hbm/sounds.json index 4c54ca7a4..011740c26 100644 --- a/assets/hbm/sounds.json +++ b/assets/hbm/sounds.json @@ -17,6 +17,8 @@ "block.broadcast2": {"category": "block", "sounds": [{"name": "block/broadcast2", "stream": false}]}, "block.broadcast3": {"category": "block", "sounds": [{"name": "block/broadcast3", "stream": false}]}, "block.sonarPing": {"category": "block", "sounds": [{"name": "block/sonarPing", "stream": false}]}, + "block.reactorStart": {"category": "block", "sounds": [{"name": "block/reactorStart", "stream": false}]}, + "block.reactorStop": {"category": "block", "sounds": [{"name": "block/reactorStop", "stream": false}]}, "item.techBleep": {"category": "player", "sounds": [{"name": "tool/techBleep", "stream": false}]}, "item.techBoop": {"category": "player", "sounds": [{"name": "tool/techBoop", "stream": false}]}, diff --git a/assets/hbm/sounds/block/reactorStart.ogg b/assets/hbm/sounds/block/reactorStart.ogg new file mode 100644 index 000000000..3d27088ed Binary files /dev/null and b/assets/hbm/sounds/block/reactorStart.ogg differ diff --git a/assets/hbm/sounds/block/reactorStop.ogg b/assets/hbm/sounds/block/reactorStop.ogg new file mode 100644 index 000000000..8c8cf6363 Binary files /dev/null and b/assets/hbm/sounds/block/reactorStop.ogg differ diff --git a/assets/hbm/textures/gui/gui_radar.png b/assets/hbm/textures/gui/gui_radar.png index 5b13fd40d..0e601449e 100644 Binary files a/assets/hbm/textures/gui/gui_radar.png and b/assets/hbm/textures/gui/gui_radar.png differ diff --git a/assets/hbm/textures/gui/gui_reactor_small.png b/assets/hbm/textures/gui/gui_reactor_small.png new file mode 100644 index 000000000..7dfce4066 Binary files /dev/null and b/assets/hbm/textures/gui/gui_reactor_small.png differ diff --git a/assets/hbm/textures/gui/gui_selenium.png b/assets/hbm/textures/gui/gui_selenium.png index 5cf250a6b..654594236 100644 Binary files a/assets/hbm/textures/gui/gui_selenium.png and b/assets/hbm/textures/gui/gui_selenium.png differ diff --git a/com/hbm/blocks/ModBlocks.java b/com/hbm/blocks/ModBlocks.java index 4ca1d7a54..7cc9a6824 100644 --- a/com/hbm/blocks/ModBlocks.java +++ b/com/hbm/blocks/ModBlocks.java @@ -436,6 +436,9 @@ public class ModBlocks { public static Block machine_satlinker; public static final int guiID_satlinker = 64; + public static Block machine_reactor_small; + public static final int guiID_reactor_small = 65; + public static Block machine_spp_bottom; public static Block machine_spp_top; @@ -835,6 +838,7 @@ public class ModBlocks { machine_turbofan = new MachineTurbofan(Material.iron).setBlockName("machine_turbofan").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_turbofan"); machine_press = new MachinePress(Material.iron).setBlockName("machine_press").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_press"); machine_selenium = new MachineSeleniumEngine(Material.iron).setBlockName("machine_selenium").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_selenium"); + machine_reactor_small = new MachineReactorSmall(Material.iron).setBlockName("machine_reactor_small").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_reactor_small"); machine_schrabidium_transmutator = new MachineSchrabidiumTransmutator(Material.iron).setBlockName("machine_schrabidium_transmutator").setHardness(5.0F).setResistance(100.0F).setCreativeTab(MainRegistry.machineTab); @@ -1118,6 +1122,7 @@ public class ModBlocks { GameRegistry.registerBlock(machine_diesel, machine_diesel.getUnlocalizedName()); GameRegistry.registerBlock(machine_selenium, machine_selenium.getUnlocalizedName()); GameRegistry.registerBlock(machine_generator, machine_generator.getUnlocalizedName()); + GameRegistry.registerBlock(machine_reactor_small, machine_reactor_small.getUnlocalizedName()); GameRegistry.registerBlock(machine_industrial_generator, machine_industrial_generator.getUnlocalizedName()); GameRegistry.registerBlock(machine_radgen, machine_radgen.getUnlocalizedName()); GameRegistry.registerBlock(machine_cyclotron, machine_cyclotron.getUnlocalizedName()); diff --git a/com/hbm/blocks/machine/MachineReactorSmall.java b/com/hbm/blocks/machine/MachineReactorSmall.java new file mode 100644 index 000000000..878c97725 --- /dev/null +++ b/com/hbm/blocks/machine/MachineReactorSmall.java @@ -0,0 +1,127 @@ +package com.hbm.blocks.machine; + +import java.util.Random; + +import com.hbm.blocks.ModBlocks; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.machine.TileEntityMachinePress; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.block.material.Material; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class MachineReactorSmall extends BlockContainer { + + private final Random field_149933_a = new Random(); + private static boolean keepInventory; + + public MachineReactorSmall(Material p_i45386_1_) { + super(p_i45386_1_); + } + + @Override + public Item getItemDropped(int p_149650_1_, Random p_149650_2_, int p_149650_3_) + { + return Item.getItemFromBlock(ModBlocks.machine_reactor_small); + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new TileEntityMachineReactorSmall(); + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) + { + if (!keepInventory) + { + ISidedInventory tileentityfurnace = (ISidedInventory)p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_); + + if (tileentityfurnace != null) + { + for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) + { + ItemStack itemstack = tileentityfurnace.getStackInSlot(i1); + + if (itemstack != null) + { + float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F; + + while (itemstack.stackSize > 0) + { + int j1 = this.field_149933_a.nextInt(21) + 10; + + if (j1 > itemstack.stackSize) + { + j1 = itemstack.stackSize; + } + + itemstack.stackSize -= j1; + EntityItem entityitem = new EntityItem(p_149749_1_, p_149749_2_ + f, p_149749_3_ + f1, p_149749_4_ + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); + + if (itemstack.hasTagCompound()) + { + entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); + } + + float f3 = 0.05F; + entityitem.motionX = (float)this.field_149933_a.nextGaussian() * f3; + entityitem.motionY = (float)this.field_149933_a.nextGaussian() * f3 + 0.2F; + entityitem.motionZ = (float)this.field_149933_a.nextGaussian() * f3; + p_149749_1_.spawnEntityInWorld(entityitem); + } + } + } + + p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_); + } + } + + super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { + if(world.isRemote) + { + return true; + } else if(!player.isSneaking()) + { + TileEntityMachineReactorSmall entity = (TileEntityMachineReactorSmall) world.getTileEntity(x, y, z); + if(entity != null) + { + FMLNetworkHandler.openGui(player, MainRegistry.instance, ModBlocks.guiID_reactor_small, world, x, y, z); + } + return true; + } else { + return false; + } + } +} diff --git a/com/hbm/handler/GUIHandler.java b/com/hbm/handler/GUIHandler.java index fcca6f030..3f95b45a3 100644 --- a/com/hbm/handler/GUIHandler.java +++ b/com/hbm/handler/GUIHandler.java @@ -55,6 +55,7 @@ import com.hbm.tileentity.machine.TileEntityMachineRTG; import com.hbm.tileentity.machine.TileEntityMachineRadGen; import com.hbm.tileentity.machine.TileEntityMachineRadar; import com.hbm.tileentity.machine.TileEntityMachineReactor; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; import com.hbm.tileentity.machine.TileEntityMachineRefinery; import com.hbm.tileentity.machine.TileEntityMachineSchrabidiumTransmutator; import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; @@ -648,6 +649,15 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_reactor_small: + { + if(entity instanceof TileEntityMachineReactorSmall) + { + return new ContainerMachineReactorSmall(player.inventory, (TileEntityMachineReactorSmall) entity); + } + return null; + } } return null; } @@ -1225,6 +1235,15 @@ public class GUIHandler implements IGuiHandler { } return null; } + + case ModBlocks.guiID_reactor_small: + { + if(entity instanceof TileEntityMachineReactorSmall) + { + return new GUIMachineReactorSmall(player.inventory, (TileEntityMachineReactorSmall) entity); + } + return null; + } } } else { //CLIENTONLY GUIS diff --git a/com/hbm/inventory/container/ContainerMachineReactorSmall.java b/com/hbm/inventory/container/ContainerMachineReactorSmall.java new file mode 100644 index 000000000..41681a0cd --- /dev/null +++ b/com/hbm/inventory/container/ContainerMachineReactorSmall.java @@ -0,0 +1,98 @@ +package com.hbm.inventory.container; + +import com.hbm.inventory.SlotMachineOutput; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; +import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerMachineReactorSmall extends Container { + +private TileEntityMachineReactorSmall seleniumEngine; + + public ContainerMachineReactorSmall(InventoryPlayer invPlayer, TileEntityMachineReactorSmall tedf) { + + seleniumEngine = tedf; + + //Rods + this.addSlotToContainer(new Slot(tedf, 0, 98, 18)); + this.addSlotToContainer(new Slot(tedf, 1, 134, 18)); + this.addSlotToContainer(new Slot(tedf, 2, 80, 36)); + this.addSlotToContainer(new Slot(tedf, 3, 116, 36)); + this.addSlotToContainer(new Slot(tedf, 4, 152, 36)); + this.addSlotToContainer(new Slot(tedf, 5, 98, 54)); + this.addSlotToContainer(new Slot(tedf, 6, 134, 54)); + this.addSlotToContainer(new Slot(tedf, 7, 80, 72)); + this.addSlotToContainer(new Slot(tedf, 8, 116, 72)); + this.addSlotToContainer(new Slot(tedf, 9, 152, 72)); + this.addSlotToContainer(new Slot(tedf, 10, 98, 90)); + this.addSlotToContainer(new Slot(tedf, 11, 134, 90)); + + //Fluid IO + this.addSlotToContainer(new Slot(tedf, 12, 8, 90)); + this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 13, 8, 108)); + this.addSlotToContainer(new Slot(tedf, 14, 26, 90)); + this.addSlotToContainer(new SlotMachineOutput(invPlayer.player, tedf, 15, 26, 108)); + + //Battery + this.addSlotToContainer(new Slot(tedf, 16, 62, 108)); + + 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 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 <= 16) { + if (!this.mergeItemStack(var5, 17, this.inventorySlots.size(), true)) + { + return null; + } + } else { + if (!this.mergeItemStack(var5, 0, 13, true)) + if (!this.mergeItemStack(var5, 14, 15, true)) + if (!this.mergeItemStack(var5, 16, 17, true)) + return null; + } + + if (var5.stackSize == 0) + { + var4.putStack((ItemStack) null); + } + else + { + var4.onSlotChanged(); + } + } + + return var3; + } + + @Override + public boolean canInteractWith(EntityPlayer player) { + return seleniumEngine.isUseableByPlayer(player); + } +} diff --git a/com/hbm/inventory/gui/GUIMachineReactorSmall.java b/com/hbm/inventory/gui/GUIMachineReactorSmall.java new file mode 100644 index 000000000..83dfd1585 --- /dev/null +++ b/com/hbm/inventory/gui/GUIMachineReactorSmall.java @@ -0,0 +1,103 @@ +package com.hbm.inventory.gui; + +import org.lwjgl.opengl.GL11; + +import com.hbm.inventory.FluidTank; +import com.hbm.inventory.container.ContainerMachineReactorSmall; +import com.hbm.inventory.container.ContainerMachineSelenium; +import com.hbm.lib.RefStrings; +import com.hbm.packet.AuxButtonPacket; +import com.hbm.packet.PacketDispatcher; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; +import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; + +public class GUIMachineReactorSmall extends GuiInfoContainer { + + private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_reactor_small.png"); + private TileEntityMachineReactorSmall diFurnace; + + public GUIMachineReactorSmall(InventoryPlayer invPlayer, TileEntityMachineReactorSmall tedf) { + super(new ContainerMachineReactorSmall(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 + 36, 16, 52); + diFurnace.tanks[1].renderTankInfo(this, mouseX, mouseY, guiLeft + 26, guiTop + 36, 16, 52); + this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 80, guiTop + 108, 88, 7, diFurnace.power, diFurnace.powerMax); + } + + @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); + } + + protected void mouseClicked(int x, int y, int i) { + super.mouseClicked(x, y, i); + + if(guiLeft + 53 <= x && guiLeft + 53 + 16 > x && guiTop + 54 < y && guiTop + 54 + 16 >= y) { + + 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)); + } + } + + @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.power > 0) { + int i = (int)diFurnace.getPowerScaled(88); + + i = (int) Math.min(i, 88); + + drawTexturedModalRect(guiLeft + 80, guiTop + 108, 0, 222, i, 7); + } + if(diFurnace.heat > 0) { + int i = diFurnace.getHeatScaled(88); + + i = (int) Math.min(i, 160); + + drawTexturedModalRect(guiLeft + 80, guiTop + 117, 0, 229, i, 7); + } + + if(!diFurnace.retracting) + drawTexturedModalRect(guiLeft + 52, guiTop + 53, 212, 0, 18, 18); + + if(diFurnace.rods >= diFurnace.rodsMax) { + + for(int x = 0; x < 3; x++) + for(int y = 0; y < 3; y++) + drawTexturedModalRect(guiLeft + 79 + 36 * x, guiTop + 17 + 36 * y, 176, 0, 18, 18); + + } else if(diFurnace.rods > 0) { + + for(int x = 0; x < 3; x++) + for(int y = 0; y < 3; y++) + drawTexturedModalRect(guiLeft + 79 + 36 * x, guiTop + 17 + 36 * y, 194, 0, 18, 18); + + } + + Minecraft.getMinecraft().getTextureManager().bindTexture(diFurnace.tanks[0].getSheet()); + diFurnace.tanks[0].renderTank(this, guiLeft + 8, guiTop + 88, diFurnace.tanks[0].getTankType().textureX() * FluidTank.x, diFurnace.tanks[0].getTankType().textureY() * FluidTank.y, 16, 52); + Minecraft.getMinecraft().getTextureManager().bindTexture(diFurnace.tanks[1].getSheet()); + diFurnace.tanks[1].renderTank(this, guiLeft + 26, guiTop + 88, diFurnace.tanks[1].getTankType().textureX() * FluidTank.x, diFurnace.tanks[1].getTankType().textureY() * FluidTank.y, 16, 52); + } +} diff --git a/com/hbm/items/ModItems.java b/com/hbm/items/ModItems.java index 8371b7eb7..addf23948 100644 --- a/com/hbm/items/ModItems.java +++ b/com/hbm/items/ModItems.java @@ -1761,18 +1761,18 @@ public class ModItems { rod_quad_schrabidium = new ItemCustomLore().setUnlocalizedName("rod_quad_schrabidium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_schrabidium"); rod_quad_solinium = new ItemCustomLore().setUnlocalizedName("rod_quad_solinium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_solinium"); - rod_uranium_fuel = new ItemFuelRod(10000).setUnlocalizedName("rod_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_uranium_fuel"); - rod_dual_uranium_fuel = new ItemFuelRod(20000).setUnlocalizedName("rod_dual_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_uranium_fuel"); - rod_quad_uranium_fuel = new ItemFuelRod(40000).setUnlocalizedName("rod_quad_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_uranium_fuel"); - rod_plutonium_fuel = new ItemFuelRod(25000).setUnlocalizedName("rod_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_plutonium_fuel"); - rod_dual_plutonium_fuel = new ItemFuelRod(50000).setUnlocalizedName("rod_dual_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_plutonium_fuel"); - rod_quad_plutonium_fuel = new ItemFuelRod(100000).setUnlocalizedName("rod_quad_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_plutonium_fuel"); - rod_mox_fuel = new ItemFuelRod(100000).setUnlocalizedName("rod_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_mox_fuel"); - rod_dual_mox_fuel = new ItemFuelRod(200000).setUnlocalizedName("rod_dual_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_mox_fuel"); - rod_quad_mox_fuel = new ItemFuelRod(400000).setUnlocalizedName("rod_quad_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_mox_fuel"); - rod_schrabidium_fuel = new ItemFuelRod(2500000).setUnlocalizedName("rod_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_schrabidium_fuel"); - rod_dual_schrabidium_fuel = new ItemFuelRod(5000000).setUnlocalizedName("rod_dual_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_schrabidium_fuel"); - rod_quad_schrabidium_fuel = new ItemFuelRod(10000000).setUnlocalizedName("rod_quad_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_schrabidium_fuel"); + rod_uranium_fuel = new ItemFuelRod(10000, 100).setUnlocalizedName("rod_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_uranium_fuel"); + rod_dual_uranium_fuel = new ItemFuelRod(20000, 100).setUnlocalizedName("rod_dual_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_uranium_fuel"); + rod_quad_uranium_fuel = new ItemFuelRod(40000, 100).setUnlocalizedName("rod_quad_uranium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_uranium_fuel"); + rod_plutonium_fuel = new ItemFuelRod(25000, 250).setUnlocalizedName("rod_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_plutonium_fuel"); + rod_dual_plutonium_fuel = new ItemFuelRod(50000, 250).setUnlocalizedName("rod_dual_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_plutonium_fuel"); + rod_quad_plutonium_fuel = new ItemFuelRod(100000, 250).setUnlocalizedName("rod_quad_plutonium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_plutonium_fuel"); + rod_mox_fuel = new ItemFuelRod(100000, 75).setUnlocalizedName("rod_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_mox_fuel"); + rod_dual_mox_fuel = new ItemFuelRod(200000, 75).setUnlocalizedName("rod_dual_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_mox_fuel"); + rod_quad_mox_fuel = new ItemFuelRod(400000, 75).setUnlocalizedName("rod_quad_mox_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_mox_fuel"); + rod_schrabidium_fuel = new ItemFuelRod(2500000, 1000).setUnlocalizedName("rod_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_schrabidium_fuel"); + rod_dual_schrabidium_fuel = new ItemFuelRod(5000000, 1000).setUnlocalizedName("rod_dual_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_schrabidium_fuel"); + rod_quad_schrabidium_fuel = new ItemFuelRod(10000000, 1000).setUnlocalizedName("rod_quad_schrabidium_fuel").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_quad_empty).setTextureName(RefStrings.MODID + ":rod_quad_schrabidium_fuel"); rod_water = new ItemCustomLore().setUnlocalizedName("rod_water").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_empty).setTextureName(RefStrings.MODID + ":rod_water"); rod_dual_water = new ItemCustomLore().setUnlocalizedName("rod_dual_water").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.rod_dual_empty).setTextureName(RefStrings.MODID + ":rod_dual_water"); diff --git a/com/hbm/items/special/ItemFuelRod.java b/com/hbm/items/special/ItemFuelRod.java index 4797df0f6..18adffe9d 100644 --- a/com/hbm/items/special/ItemFuelRod.java +++ b/com/hbm/items/special/ItemFuelRod.java @@ -11,9 +11,11 @@ import net.minecraft.nbt.NBTTagCompound; public class ItemFuelRod extends ItemRadioactive { public int lifeTime; + public int heat; - public ItemFuelRod(int life) { + public ItemFuelRod(int life, int heat) { this.lifeTime = life; + this.heat = heat; this.setMaxDamage(100); } @@ -25,85 +27,85 @@ public class ItemFuelRod extends ItemRadioactive { if(this == ModItems.rod_uranium_fuel) { list.add("Generates 100 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 10000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_dual_uranium_fuel) { list.add("Generates 100 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 20000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_quad_uranium_fuel) { list.add("Generates 100 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 40000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_plutonium_fuel) { list.add("Generates 150 power per tick"); - list.add("Generates 2 heat per tick"); - list.add("Lasts 25000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_dual_plutonium_fuel) { list.add("Generates 150 power per tick"); - list.add("Generates 2 heat per tick"); - list.add("Lasts 50000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_quad_plutonium_fuel) { list.add("Generates 150 power per tick"); - list.add("Generates 2 heat per tick"); - list.add("Lasts 100000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_mox_fuel) { list.add("Generates 50 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 100000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_dual_mox_fuel) { list.add("Generates 50 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 200000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_quad_mox_fuel) { list.add("Generates 50 power per tick"); - list.add("Generates 1 heat per tick"); - list.add("Lasts 400000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_schrabidium_fuel) { list.add("Generates 25000 power per tick"); - list.add("Generates 10 heat per tick"); - list.add("Lasts 2500000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_dual_schrabidium_fuel) { list.add("Generates 25000 power per tick"); - list.add("Generates 10 heat per tick"); - list.add("Lasts 5000000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } if(this == ModItems.rod_quad_schrabidium_fuel) { list.add("Generates 25000 power per tick"); - list.add("Generates 10 heat per tick"); - list.add("Lasts 10000000 ticks"); + list.add("Generates " + heat + " heat per tick"); + list.add("Lasts " + lifeTime + " ticks"); } } diff --git a/com/hbm/main/ClientProxy.java b/com/hbm/main/ClientProxy.java index 069205f72..8f2b8fc5f 100644 --- a/com/hbm/main/ClientProxy.java +++ b/com/hbm/main/ClientProxy.java @@ -95,6 +95,7 @@ public class ClientProxy extends ServerProxy ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineRadGen.class, new RenderRadGen()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineRadar.class, new RenderRadar()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineSeleniumEngine.class, new RenderSelenium()); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineReactorSmall.class, new RenderSmallReactor()); //RenderingRegistry.registerEntityRenderingHandler(EntityRocket.class, new RenderRocket()); RenderingRegistry.registerEntityRenderingHandler(EntityRocket.class, new RenderSnowball(ModItems.man_core)); diff --git a/com/hbm/main/MainRegistry.java b/com/hbm/main/MainRegistry.java index 713930c92..2895e9b7f 100644 --- a/com/hbm/main/MainRegistry.java +++ b/com/hbm/main/MainRegistry.java @@ -259,6 +259,7 @@ import com.hbm.tileentity.machine.TileEntityMachineRTG; import com.hbm.tileentity.machine.TileEntityMachineRadGen; import com.hbm.tileentity.machine.TileEntityMachineRadar; import com.hbm.tileentity.machine.TileEntityMachineReactor; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; import com.hbm.tileentity.machine.TileEntityMachineRefinery; import com.hbm.tileentity.machine.TileEntityMachineSPP; import com.hbm.tileentity.machine.TileEntityMachineSchrabidiumTransmutator; @@ -644,6 +645,7 @@ public class MainRegistry GameRegistry.registerTileEntity(TileEntityCelPrimeTanks.class, "tileentity_cel_prime_storage"); GameRegistry.registerTileEntity(TileEntityMachineSeleniumEngine.class, "tileentity_selenium_engine"); GameRegistry.registerTileEntity(TileEntityMachineSatLinker.class, "tileentity_satlinker"); + GameRegistry.registerTileEntity(TileEntityMachineReactorSmall.class, "tileentity_small_reactor"); EntityRegistry.registerModEntity(EntityRocket.class, "entity_rocket", 0, this, 250, 1, true); EntityRegistry.registerModEntity(EntityNukeExplosion.class, "entity_nuke_explosion", 1, this, 250, 1, true); diff --git a/com/hbm/packet/AuxButtonPacket.java b/com/hbm/packet/AuxButtonPacket.java new file mode 100644 index 000000000..c5afe714a --- /dev/null +++ b/com/hbm/packet/AuxButtonPacket.java @@ -0,0 +1,87 @@ +package com.hbm.packet; + +import com.hbm.explosion.ExplosionLarge; +import com.hbm.saveddata.SatelliteSaveStructure; +import com.hbm.saveddata.SatelliteSavedData; +import com.hbm.tileentity.bomb.TileEntityTurretCIWS; +import com.hbm.tileentity.bomb.TileEntityTurretCheapo; +import com.hbm.tileentity.machine.TileEntityAMSBase; +import com.hbm.tileentity.machine.TileEntityAMSEmitter; +import com.hbm.tileentity.machine.TileEntityAMSLimiter; +import com.hbm.tileentity.machine.TileEntityMachineDiesel; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; +import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; + +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; + +public class AuxButtonPacket implements IMessage { + + int x; + int y; + int z; + int value; + int id; + + public AuxButtonPacket() + { + + } + + public AuxButtonPacket(int x, int y, int z, int value, int id) + { + this.x = x; + this.y = y; + this.z = z; + this.value = value; + this.id = id; + } + + @Override + public void fromBytes(ByteBuf buf) { + x = buf.readInt(); + y = buf.readInt(); + z = buf.readInt(); + value = buf.readInt(); + id = buf.readInt(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeInt(x); + buf.writeInt(y); + buf.writeInt(z); + buf.writeInt(value); + buf.writeInt(id); + } + + public static class Handler implements IMessageHandler { + + @Override + public IMessage onMessage(AuxButtonPacket m, MessageContext ctx) { + + EntityPlayer p = ctx.getServerHandler().playerEntity; + + //try { + TileEntity te = p.worldObj.getTileEntity(m.x, m.y, m.z); + + if (te instanceof TileEntityMachineReactorSmall) { + TileEntityMachineReactorSmall reactor = (TileEntityMachineReactorSmall)te; + + reactor.retracting = m.value == 1; + } + + //} catch (Exception x) { } + + return null; + } + } +} diff --git a/com/hbm/packet/AuxGaugePacket.java b/com/hbm/packet/AuxGaugePacket.java index 8778c7652..4c91a0143 100644 --- a/com/hbm/packet/AuxGaugePacket.java +++ b/com/hbm/packet/AuxGaugePacket.java @@ -8,6 +8,7 @@ import com.hbm.tileentity.machine.TileEntityAMSBase; import com.hbm.tileentity.machine.TileEntityAMSEmitter; import com.hbm.tileentity.machine.TileEntityAMSLimiter; import com.hbm.tileentity.machine.TileEntityMachineDiesel; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; import cpw.mods.fml.common.network.simpleimpl.IMessage; @@ -116,6 +117,16 @@ public class AuxGaugePacket implements IMessage { selenium.powerCap = m.value; } + if (te instanceof TileEntityMachineReactorSmall) { + TileEntityMachineReactorSmall reactor = (TileEntityMachineReactorSmall)te; + + if(m.id == 0) + reactor.rods = m.value; + if(m.id == 1) + reactor.retracting = m.value == 1; + if(m.id == 2) + reactor.heat = m.value; + } } catch (Exception x) { } return null; diff --git a/com/hbm/packet/PacketDispatcher.java b/com/hbm/packet/PacketDispatcher.java index ac4e5f998..b7b13672a 100644 --- a/com/hbm/packet/PacketDispatcher.java +++ b/com/hbm/packet/PacketDispatcher.java @@ -51,7 +51,7 @@ public class PacketDispatcher { wrapper.registerMessage(TEPressPacket.Handler.class, TEPressPacket.class, i++, Side.CLIENT); //Electricity gauge for GUI rendering wrapper.registerMessage(AuxElectricityPacket.Handler.class, AuxElectricityPacket.class, i++, Side.CLIENT); - //Electricity gauge for GUI rendering + //Universal package for machine gauges and states wrapper.registerMessage(AuxGaugePacket.Handler.class, AuxGaugePacket.class, i++, Side.CLIENT); //Siren packet for looped sounds wrapper.registerMessage(TESirenPacket.Handler.class, TESirenPacket.class, i++, Side.CLIENT); @@ -63,6 +63,8 @@ public class PacketDispatcher { wrapper.registerMessage(TERadarDestructorPacket.Handler.class, TERadarDestructorPacket.class, i++, Side.CLIENT); //Signals server to perform orbital strike wrapper.registerMessage(SatLaserPacket.Handler.class, SatLaserPacket.class, i++, Side.SERVER); + //Universal package for sending small info packs back to server + wrapper.registerMessage(AuxButtonPacket.Handler.class, AuxButtonPacket.class, i++, Side.SERVER); } } diff --git a/com/hbm/render/tileentity/RenderSmallReactor.java b/com/hbm/render/tileentity/RenderSmallReactor.java new file mode 100644 index 000000000..32a4598df --- /dev/null +++ b/com/hbm/render/tileentity/RenderSmallReactor.java @@ -0,0 +1,35 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; + +import com.hbm.main.ResourceManager; +import com.hbm.tileentity.machine.TileEntityMachineReactorSmall; +import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +public class RenderSmallReactor extends TileEntitySpecialRenderer { + + @Override + public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) + { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5D, y, z + 0.5D); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glRotatef(180, 0F, 1F, 0F); + + TileEntityMachineReactorSmall reactor = (TileEntityMachineReactorSmall)tileEntity; + + bindTexture(ResourceManager.reactor_small_base_tex); + ResourceManager.reactor_small_base.renderAll(); + + GL11.glTranslated(0.0D, reactor.rods / 100D, 0.0D); + + bindTexture(ResourceManager.reactor_small_rods_tex); + ResourceManager.reactor_small_rods.renderAll(); + + GL11.glPopMatrix(); + } +} diff --git a/com/hbm/tileentity/machine/TileEntityMachineReactorSmall.java b/com/hbm/tileentity/machine/TileEntityMachineReactorSmall.java new file mode 100644 index 000000000..791bdc81a --- /dev/null +++ b/com/hbm/tileentity/machine/TileEntityMachineReactorSmall.java @@ -0,0 +1,556 @@ +package com.hbm.tileentity.machine; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import com.hbm.blocks.machine.MachineGenerator; +import com.hbm.explosion.ExplosionNukeGeneric; +import com.hbm.handler.FluidTypeHandler.FluidType; +import com.hbm.interfaces.IConsumer; +import com.hbm.interfaces.IFluidAcceptor; +import com.hbm.interfaces.IFluidContainer; +import com.hbm.interfaces.ISource; +import com.hbm.inventory.FluidTank; +import com.hbm.items.ModItems; +import com.hbm.items.special.ItemBattery; +import com.hbm.items.special.ItemFuelRod; +import com.hbm.lib.Library; +import com.hbm.packet.AuxElectricityPacket; +import com.hbm.packet.AuxGaugePacket; +import com.hbm.packet.PacketDispatcher; + +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.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityMachineReactorSmall extends TileEntity implements ISidedInventory, ISource, IFluidContainer, IFluidAcceptor { + + private ItemStack slots[]; + + public int heat; + public final int heatMax = 10000; + public long power; + public final long powerMax = 100000; + public int rods; + public final int rodsMax = 100; + public boolean retracting = true; + public int age = 0; + public List list = new ArrayList(); + 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 TileEntityMachineReactorSmall() { + slots = new ItemStack[17]; + tanks = new FluidTank[2]; + tanks[0] = new FluidTank(FluidType.WATER, 32000, 0); + tanks[1] = new FluidTank(FluidType.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 == 12) + if(itemStack.getItem() == ModItems.rod_water || itemStack.getItem() == ModItems.rod_dual_water || itemStack.getItem() == ModItems.rod_quad_water || itemStack.getItem() == Items.water_bucket) + return true; + if(i == 14) + if(itemStack.getItem() == ModItems.rod_coolant || itemStack.getItem() == ModItems.rod_dual_coolant || itemStack.getItem() == ModItems.rod_quad_coolant) + return true; + if(i == 16) + if(itemStack.getItem() instanceof ItemBattery) + 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 ItemBattery && ItemBattery.getCharge(itemStack) == ItemBattery.getMaxChargeStatic(itemStack)) + 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; + } + + private int[] getNeighbouringSlots(int id) { + + switch(id) { + case 0: return new int[] { 1, 5 }; + case 1: return new int[] { 0, 6 }; + case 2: return new int[] { 3, 7 }; + case 3: return new int[] { 2, 4, 8 }; + case 4: return new int[] { 3, 9 }; + case 5: return new int[] { 0, 6, 0xA }; + case 6: return new int[] { 1, 5, 0xB }; + case 7: return new int[] { 2, 8 }; + case 8: return new int[] { 3, 7, 9}; + case 9: return new int[] { 4, 8 }; + case 10: return new int[] { 5, 0xB }; + case 11: return new int[] { 6, 0xA }; + } + + return null; + } + + @Override + public void updateEntity() { + + age++; + if(age >= 20) + { + age = 0; + } + + if(age == 9 || age == 19) + ffgeuaInit(); + + if(!worldObj.isRemote) + { + tanks[0].loadTank(12, 13, slots); + tanks[1].loadTank(14, 15, slots); + + if(retracting && rods > 0) { + + if(rods == rodsMax) + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStart", 1.0F, 0.75F); + + rods--; + + if(rods == 0) + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 1.0F, 1.0F); + } + if(!retracting && rods < rodsMax) { + + if(rods == 0) + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStart", 1.0F, 0.75F); + + rods++; + + if(rods == rodsMax) + this.worldObj.playSoundEffect(this.xCoord, this.yCoord, this.zCoord, "hbm:block.reactorStop", 1.0F, 1.0F); + } + + for(int i = 0; i < 2; i++) + tanks[i].updateTank(xCoord, yCoord, zCoord); + + //Batteries + power = Library.chargeItemsFromTE(slots, 11, power, powerMax); + + if(rods >= rodsMax) + for(int i = 0; i < 12; i++) + { + if(slots[i] != null && slots[i].getItem() instanceof ItemFuelRod) + decay(i); + } + + if(this.power > powerMax) + { + this.power = powerMax; + } + + if(this.heat > heatMax) + { + this.explode(); + } + + PacketDispatcher.wrapper.sendToAll(new AuxElectricityPacket(xCoord, yCoord, zCoord, power)); + 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, heat, 2)); + } + } + + private boolean hasFuelRod(int id) { + if(id > 11) + return false; + + if(slots[id] != null) + return slots[id].getItem() instanceof ItemFuelRod; + + return false; + } + + private int getNeightbourCount(int id) { + + int[] neighbours = this.getNeighbouringSlots(id); + + if(neighbours == null) + return 0; + + int count = 0; + + for(int i = 0; i < neighbours.length; i++) + if(hasFuelRod(neighbours[i])) + count++; + + return count; + + } + + //itemstack in slots[id] has to contain ItemFuelRod item + private void decay(int id) { + if(id > 11) + return; + + int decay = getNeightbourCount(id) + 1; + + for(int i = 0; i < decay; i++) { + ItemFuelRod rod = ((ItemFuelRod)slots[id].getItem()); + this.heat += rod.heat; + ItemFuelRod.setLifeTime(slots[id], ItemFuelRod.getLifeTime(slots[id]) + 1); + ItemFuelRod.updateDamage(slots[id]); + + if(ItemFuelRod.getLifeTime(slots[id]) <= 0) { + onRunOut(id); + return; + } + } + } + + //itemstack in slots[id] has to contain ItemFuelRod item + private void onRunOut(int id) { + + Item item = slots[id].getItem(); + + if(item == ModItems.rod_uranium_fuel) { + slots[id] = new ItemStack(ModItems.rod_uranium_fuel_depleted); + + } else if(item == ModItems.rod_plutonium_fuel) { + slots[id] = new ItemStack(ModItems.rod_plutonium_fuel_depleted); + + } else if(item == ModItems.rod_mox_fuel) { + slots[id] = new ItemStack(ModItems.rod_mox_fuel_depleted); + + } else if(item == ModItems.rod_schrabidium_fuel) { + slots[id] = new ItemStack(ModItems.rod_schrabidium_fuel_depleted); + + } else if(item == ModItems.rod_dual_uranium_fuel) { + slots[id] = new ItemStack(ModItems.rod_dual_uranium_fuel_depleted); + + } else if(item == ModItems.rod_dual_plutonium_fuel) { + slots[id] = new ItemStack(ModItems.rod_dual_plutonium_fuel_depleted); + + } else if(item == ModItems.rod_dual_mox_fuel) { + slots[id] = new ItemStack(ModItems.rod_dual_mox_fuel_depleted); + + } else if(item == ModItems.rod_dual_schrabidium_fuel) { + slots[id] = new ItemStack(ModItems.rod_dual_schrabidium_fuel_depleted); + + } else if(item == ModItems.rod_quad_uranium_fuel) { + slots[id] = new ItemStack(ModItems.rod_quad_uranium_fuel_depleted); + + } else if(item == ModItems.rod_quad_plutonium_fuel) { + slots[id] = new ItemStack(ModItems.rod_quad_plutonium_fuel_depleted); + + } else if(item == ModItems.rod_quad_mox_fuel) { + slots[id] = new ItemStack(ModItems.rod_quad_mox_fuel_depleted); + + } else if(item == ModItems.rod_quad_schrabidium_fuel) { + slots[id] = new ItemStack(ModItems.rod_quad_schrabidium_fuel_depleted); + } + } + + private 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); + } + + @Override + public void ffgeua(int x, int y, int z, boolean newTact) { + + Library.ffgeua(x, y, z, newTact, this, worldObj); + } + + @Override + public void ffgeuaInit() { + ffgeua(this.xCoord - 1, this.yCoord + 1, this.zCoord, getTact()); + ffgeua(this.xCoord + 1, this.yCoord + 1, this.zCoord, getTact()); + ffgeua(this.xCoord, this.yCoord + 1, this.zCoord - 1, getTact()); + ffgeua(this.xCoord, this.yCoord + 1, this.zCoord + 1, getTact()); + + ffgeua(this.xCoord - 1, this.yCoord - 1, this.zCoord, getTact()); + ffgeua(this.xCoord + 1, this.yCoord - 1, this.zCoord, getTact()); + ffgeua(this.xCoord, this.yCoord - 1, this.zCoord - 1, getTact()); + ffgeua(this.xCoord, this.yCoord - 1, this.zCoord + 1, getTact()); + } + + @Override + public boolean getTact() { + if(age >= 0 && age < 10) + { + return true; + } + + return false; + } + + @Override + public long getSPower() { + return power; + } + + @Override + public void setSPower(long i) { + this.power = i; + } + + @Override + public List getList() { + return list; + } + + @Override + public void clearList() { + this.list.clear(); + } + + @Override + public int getMaxAFluidFill(FluidType type) { + if(type.name().equals(tanks[0].getTankType().name())) + return tanks[0].getMaxFill(); + else if(type.name().equals(tanks[1].getTankType().name())) + return tanks[1].getMaxFill(); + else + return 0; + } + + @Override + public void setAFluidFill(int i, FluidType type) { + if(type.name().equals(tanks[0].getTankType().name())) + tanks[0].setFill(i); + else if(type.name().equals(tanks[1].getTankType().name())) + tanks[1].setFill(i); + } + + @Override + public int getAFluidFill(FluidType type) { + if(type.name().equals(tanks[0].getTankType().name())) + return tanks[0].getFill(); + else if(type.name().equals(tanks[1].getTankType().name())) + return tanks[1].getFill(); + else + return 0; + } + + @Override + public void setFillstate(int fill, int index) { + if(index < 2 && tanks[index] != null) + tanks[index].setFill(fill); + } + + @Override + public void setType(FluidType type, int index) { + if(index < 2 && tanks[index] != null) + tanks[index].setTankType(type); + } +} \ No newline at end of file