aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/block/machine
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-09-07 16:36:25 +1000
commit221c2f0fe81430e7dd4087e5f5845bd7c62ec56d (patch)
treed6e0faaef01b9d517828557e1be82500d476f95e /src/Java/gtPlusPlus/core/block/machine
parent5872c0947ce7bc788b03fa2fb690b8815d3d0a04 (diff)
downloadGT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.gz
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.tar.bz2
GT5-Unofficial-221c2f0fe81430e7dd4087e5f5845bd7c62ec56d.zip
% Refactored the entire project to stop using MiscUtils everywhere possible, now it's gtPlusPlus.
Diffstat (limited to 'src/Java/gtPlusPlus/core/block/machine')
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java35
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java83
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java83
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java5
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java165
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java75
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java72
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java78
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java648
9 files changed, 1244 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java
new file mode 100644
index 0000000000..2832d4d0a4
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/BlockGtFrameBox.java
@@ -0,0 +1,35 @@
+package gtPlusPlus.core.block.machine;
+
+import gtPlusPlus.core.block.base.MetaBlock;
+import gtPlusPlus.core.block.base.BasicBlock.BlockTypes;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.block.material.Material;
+import net.minecraft.world.IBlockAccess;
+
+public class BlockGtFrameBox extends MetaBlock {
+
+ private int[] colours;
+ private int totalColours;
+
+ public BlockGtFrameBox(
+ String unlocalizedName, Material material,
+ BlockTypes blockTypeENUM, boolean recolour, int... colour) {
+ super(unlocalizedName, material, blockTypeENUM.getBlockSoundType());
+ this.setBlockTextureName(CORE.MODID + ":" + "blockGtFrame");
+ this.setHarvestLevel(blockTypeENUM.getHarvestTool(), 2);
+ if (recolour && (colour != null && colour.length > 0)){
+ colours = colour;
+ totalColours = colours.length;
+ }
+ }
+
+ @Override
+ public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_,
+ int p_149720_3_, int p_149720_4_) {
+ for (int i : colours){
+
+ }
+ return super.colorMultiplier(p_149720_1_, p_149720_2_, p_149720_3_, p_149720_4_);
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java
new file mode 100644
index 0000000000..4f426b99c9
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_Charger.java
@@ -0,0 +1,83 @@
+package gtPlusPlus.core.block.machine;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityCharger;
+
+import java.util.ArrayList;
+
+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.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import scala.util.Random;
+
+public class Machine_Charger extends BlockContainer
+{
+ private static final String name = "Charging Machine";
+
+ private final Random rand = new Random();
+
+ public Machine_Charger(String unlocalizedName)
+ {
+ super(Material.iron);
+ //GameRegistry.registerBlock(this, unlocalizedName);
+ this.setBlockName(unlocalizedName);
+ this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz)
+ {
+ if (world.isRemote) return true;
+
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null && te instanceof TileEntityCharger)
+ {
+ player.openGui(GTplusplus.instance, 1, world, x, y, z);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void breakBlock(World world, int x, int y, int z, Block block, int par6)
+ {
+ if (world.isRemote) return;
+
+ ArrayList drops = new ArrayList();
+
+ TileEntity teRaw = world.getTileEntity(x, y, z);
+
+ if (teRaw != null && teRaw instanceof TileEntityCharger)
+ {
+ TileEntityCharger te = (TileEntityCharger) teRaw;
+
+ for (int i = 0; i < te.getSizeInventory(); i++)
+ {
+ ItemStack stack = te.getStackInSlot(i);
+
+ if (stack != null) drops.add(stack.copy());
+ }
+ }
+
+ for (int i = 0;i < drops.size();i++)
+ {
+ EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i));
+ item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25);
+ world.spawnEntityInWorld(item);
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int par2)
+ {
+ return new TileEntityCharger();
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java
new file mode 100644
index 0000000000..011e293000
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_NHG.java
@@ -0,0 +1,83 @@
+package gtPlusPlus.core.block.machine;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.machines.TileEntityNHG;
+
+import java.util.ArrayList;
+
+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.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+import scala.util.Random;
+
+public class Machine_NHG extends BlockContainer
+{
+ private static final String name = "Nuclear Fueled Helium Generator";
+
+ private final Random rand = new Random();
+
+ public Machine_NHG(String unlocalizedName)
+ {
+ super(Material.iron);
+ //GameRegistry.registerBlock(this, unlocalizedName);
+ this.setBlockName(unlocalizedName);
+ this.setBlockTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ }
+
+ @Override
+ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float lx, float ly, float lz)
+ {
+ if (world.isRemote) return true;
+
+ TileEntity te = world.getTileEntity(x, y, z);
+ if (te != null && te instanceof TileEntityNHG)
+ {
+ player.openGui(GTplusplus.instance, 0, world, x, y, z);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void breakBlock(World world, int x, int y, int z, Block block, int par6)
+ {
+ if (world.isRemote) return;
+
+ ArrayList drops = new ArrayList();
+
+ TileEntity teRaw = world.getTileEntity(x, y, z);
+
+ if (teRaw != null && teRaw instanceof TileEntityNHG)
+ {
+ TileEntityNHG te = (TileEntityNHG) teRaw;
+
+ for (int i = 0; i < te.getSizeInventory(); i++)
+ {
+ ItemStack stack = te.getStackInSlot(i);
+
+ if (stack != null) drops.add(stack.copy());
+ }
+ }
+
+ for (int i = 0;i < drops.size();i++)
+ {
+ EntityItem item = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, (ItemStack) drops.get(i));
+ item.setVelocity((rand.nextDouble() - 0.5) * 0.25, rand.nextDouble() * 0.5 * 0.25, (rand.nextDouble() - 0.5) * 0.25);
+ world.spawnEntityInWorld(item);
+ }
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int par2)
+ {
+ return new TileEntityNHG();
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java
new file mode 100644
index 0000000000..e964a9da01
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/Machine_WireiusDeletus.java
@@ -0,0 +1,5 @@
+package gtPlusPlus.core.block.machine;
+
+public class Machine_WireiusDeletus { //A Block that removes GT Cable and Wire from it's inventory.
+
+}
diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java
new file mode 100644
index 0000000000..7a76b09cca
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/block/HeliumGenerator.java
@@ -0,0 +1,165 @@
+package gtPlusPlus.core.block.machine.heliumgen.block;
+
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+public class HeliumGenerator extends BlockContainer {
+
+ private IIcon top, sides, front;
+ private Random randy = new Random();
+
+ public HeliumGenerator(){
+ super(Material.iron);
+ setStepSound(Block.soundTypeMetal);
+ setHardness(20.0F);
+ setBlockName("helium_collector");
+ setHarvestLevel("pickaxe", 3);
+ setCreativeTab(AddToCreativeTab.tabMachines);
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void registerBlockIcons (IIconRegister iconRegister)
+ {
+ this.top = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE");
+ this.sides = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_SIDE");
+ this.front = iconRegister.registerIcon(CORE.MODID+":blockHeliumCollector_FRONT");
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side){
+ if(side == 1)
+ return top;
+ int facing = 2;
+ TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z);
+ if(machine != null)
+ facing = machine.getFacing();
+ if(side == facing)
+ return front;
+ else
+ return sides;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon (int side, int metadata)
+ {
+ if(side == 1)
+ return top;
+ if(side == 3)
+ return front;
+ return sides;
+ }
+
+ @Override
+ public boolean onBlockActivated (World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9)
+ {
+ if (world.isRemote)
+ {
+ return true;
+ }
+ player.openGui(GTplusplus.instance, 2, world, x, y, z);
+ return true;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(World world, int meta)
+ {
+ return new TileEntityHeliumGenerator();
+ }
+
+ @Override
+ public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack item)
+ {
+ TileEntity tile = world.getTileEntity(x, y, z);
+ if(tile instanceof TileEntityHeliumGenerator) {
+ TileEntityHeliumGenerator machine = (TileEntityHeliumGenerator)tile;
+ int l = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
+
+ if (l == 0)
+ machine.setFacing((short) 2);
+
+ if (l == 1)
+ machine.setFacing((short) 5);
+
+ if (l == 2)
+ machine.setFacing((short) 3);
+
+ if (l == 3)
+ machine.setFacing((short) 4);
+ }
+
+ }
+
+ @Override
+ public void breakBlock(World world, int x, int y, int z, Block block, int wut)
+ {
+ TileEntityHeliumGenerator collector = (TileEntityHeliumGenerator)world.getTileEntity(x, y, z);
+
+ if (collector != null)
+ {
+ int i = 0;
+ for (i = 0; i < collector.getSizeInventory(); i++){
+
+ ItemStack itemstack = collector.getStackInSlot(i);
+
+ if (itemstack != null)
+ {
+ float f = this.randy.nextFloat() * 0.8F + 0.1F;
+ float f1 = this.randy.nextFloat() * 0.8F + 0.1F;
+ float f2 = this.randy.nextFloat() * 0.8F + 0.1F;
+
+ while (itemstack.stackSize > 0)
+ {
+ int j1 = this.randy.nextInt(21) + 10;
+
+ if (j1 > itemstack.stackSize)
+ {
+ j1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= j1;
+ EntityItem entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
+
+ if (itemstack.hasTagCompound())
+ {
+ entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
+ }
+
+ float f3 = 0.05F;
+ entityitem.motionX = (double)((float)this.randy.nextGaussian() * f3);
+ entityitem.motionY = (double)((float)this.randy.nextGaussian() * f3 + 0.2F);
+ entityitem.motionZ = (double)((float)this.randy.nextGaussian() * f3);
+ world.spawnEntityInWorld(entityitem);
+ }
+ }
+
+ world.func_147453_f(x, y, z, block);
+ }
+ }
+
+ super.breakBlock(world, x, y, z, block, wut);
+ }
+}
diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java
new file mode 100644
index 0000000000..d701f6f125
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/container/ContainerHeliumGenerator.java
@@ -0,0 +1,75 @@
+package gtPlusPlus.core.block.machine.heliumgen.container;
+
+import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator;
+import ic2.core.ContainerBase;
+import ic2.core.slot.SlotInvSlot;
+
+import java.util.List;
+
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
+import net.minecraft.inventory.SlotFurnace;
+
+public class ContainerHeliumGenerator
+extends ContainerBase<TileEntityHeliumGenerator>
+{
+ public short size;
+
+ public ContainerHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine)
+ {
+ super(machine);
+ //Utils.LOG_WARNING("containerHeliumGenerator");
+ short sr = machine.getReactorSize();
+ this.addSlotToContainer(new SlotFurnace(player.player, machine, 2, 80, 35));
+ this.size = sr;
+ int startX = 16;
+ int startY = 16;
+ int i = 0;
+ for (i = 0; i < 9; i++)
+ {
+ int x = i % this.size;
+ int y = i / this.size;
+
+ addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y));
+ }
+ startX = 108;
+ startY = 16;
+ for (i = 9; i < 18; i++)
+ {
+ int x = i % this.size;
+ int y = (i-9) / this.size;
+
+ addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y));
+ }
+ for (i = 0; i < 3; ++i)
+ {
+ for (int j = 0; j < 9; ++j)
+ {
+ this.addSlotToContainer(new Slot(player, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
+ }
+ }
+
+ for (i = 0; i < 9; ++i)
+ {
+ this.addSlotToContainer(new Slot(player, i, 8 + i * 18, 142));
+ }
+ // addSlotToContainer(new SlotInvSlot(machine.coolantinputSlot, 0, 8, 25));
+ //addSlotToContainer(new SlotInvSlot(machine.hotcoolinputSlot, 0, 188, 25));
+ //addSlotToContainer(new SlotInvSlot(machine.coolantoutputSlot, 0, 8, 115));
+ //addSlotToContainer(new SlotInvSlot(machine.hotcoolantoutputSlot, 0, 188, 115));
+ }
+
+ @Override
+ public List<String> getNetworkedFields()
+ {
+ List<String> ret = super.getNetworkedFields();
+
+ ret.add("heat");
+ ret.add("maxHeat");
+ ret.add("EmitHeat");
+ /*ret.add("inputTank");
+ ret.add("outputTank");
+ ret.add("fluidcoolreactor");*/
+ return ret;
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java
new file mode 100644
index 0000000000..2106f144be
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/gui/GUIHeliumGenerator.java
@@ -0,0 +1,72 @@
+package gtPlusPlus.core.block.machine.heliumgen.gui;
+
+import gtPlusPlus.core.block.machine.heliumgen.container.ContainerHeliumGenerator;
+import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator;
+import gtPlusPlus.core.lib.CORE;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+import net.minecraft.util.StatCollector;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+
+@SideOnly(Side.CLIENT)
+public class GUIHeliumGenerator extends GuiContainer
+{
+ private static final ResourceLocation collectorGuiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png");
+
+ public GUIHeliumGenerator(InventoryPlayer player, TileEntityHeliumGenerator machine)
+ {
+ super(new ContainerHeliumGenerator(player, machine));
+ }
+
+ /**
+ * Draw the foreground layer for the GuiContainer (everything in front of the items)
+ */
+ @Override
+ protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
+ {
+ String s = StatCollector.translateToLocal("Helium Collector");
+ this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
+ this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
+
+ this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+-1), 80, 35, 2);
+
+ short sr = 3;
+ int size = sr;
+ int startX = 16;
+ int startY = 16;
+ int i = 0;
+ for (i = 0; i < 9; i++)
+ {
+ int x = i % size;
+ int y = i / size;
+ this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752);
+ //addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y));
+ }
+ startX = 108;
+ startY = 16;
+ for (i = 9; i < 18; i++)
+ {
+ int x = i % size;
+ int y = (i-9) / size;
+ this.fontRendererObj.drawString(StatCollector.translateToLocal("|"+i), startX + 18 * x, startY + 18 * y, 4210752);
+ // addSlotToContainer(new SlotInvSlot(machine.reactorSlot, i, startX + 18 * x, startY + 18 * y));
+ }
+
+ }
+
+ @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);
+ this.mc.getTextureManager().bindTexture(collectorGuiTexture);
+ int k = (this.width - this.xSize) / 2;
+ int l = (this.height - this.ySize) / 2;
+ this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
+
+ }
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java
new file mode 100644
index 0000000000..86507a2d64
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/slots/InvSlotRadiation.java
@@ -0,0 +1,78 @@
+package gtPlusPlus.core.block.machine.heliumgen.slots;
+
+import gtPlusPlus.core.block.machine.heliumgen.tileentity.TileEntityHeliumGenerator;
+import ic2.core.block.invslot.InvSlot;
+import net.minecraft.item.ItemStack;
+
+public class InvSlotRadiation extends InvSlot
+{
+ public InvSlotRadiation(TileEntityHeliumGenerator base, String name1, int oldStartIndex1, int count)
+ {
+ super(base, name1, oldStartIndex1, InvSlot.Access.IO, count);
+
+ setStackSizeLimit(1);
+ }
+
+ @Override
+ public boolean accepts(ItemStack itemStack)
+ {
+ return ((TileEntityHeliumGenerator)this.base).isUsefulItem(itemStack, true);
+ }
+
+ @Override
+ public int size()
+ {
+ //Utils.LOG_INFO("InvSlotRadiation/Size");
+ return 3 * 6;
+ }
+
+ public int rawSize()
+ {
+ return super.size();
+ }
+
+ @Override
+ public ItemStack get(int index)
+ {
+ return super.get(mapIndex(index));
+ }
+
+ public ItemStack get(int x, int y)
+ {
+ return super.get(y * 9 + x);
+ }
+
+ @Override
+ public void put(int index, ItemStack content)
+ {
+ super.put(mapIndex(index), content);
+ }
+
+ public void put(int x, int y, ItemStack content)
+ {
+ super.put(y * 9 + x, content);
+ }
+
+ private int mapIndex(int index)
+ {
+ int size = size();
+ int cols = size / 6;
+ if (index < size)
+ {
+ int row = index / cols;
+ int col = index % cols;
+
+ return row * 9 + col;
+ }
+ index -= size;
+ int remCols = 9 - cols;
+
+ int row = index / remCols;
+ int col = cols + index % remCols;
+
+ return row * 9 + col;
+ }
+
+ private final int rows = 6;
+ private final int maxCols = 9;
+}
diff --git a/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java
new file mode 100644
index 0000000000..06c13f997a
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/heliumgen/tileentity/TileEntityHeliumGenerator.java
@@ -0,0 +1,648 @@
+package gtPlusPlus.core.block.machine.heliumgen.tileentity;
+
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.block.machine.heliumgen.slots.InvSlotRadiation;
+import gtPlusPlus.core.item.ModItems;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.item.UtilsItems;
+import ic2.api.Direction;
+import ic2.api.reactor.IReactor;
+import ic2.api.reactor.IReactorComponent;
+import ic2.api.tile.IWrenchable;
+import ic2.core.IC2;
+import ic2.core.IC2DamageSource;
+import ic2.core.Ic2Items;
+import ic2.core.block.TileEntityInventory;
+import ic2.core.init.MainConfig;
+import ic2.core.item.reactor.ItemReactorHeatStorage;
+import ic2.core.network.NetworkManager;
+import ic2.core.util.ConfigUtil;
+
+import java.util.List;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.World;
+
+public class TileEntityHeliumGenerator extends TileEntityInventory implements IInventory ,IReactor, IWrenchable {
+
+ private ItemStack heliumStack;
+ private int facing = 2;
+ private int progress;
+
+
+ public void update2Entity(){
+ Utils.LOG_WARNING("updateEntity");
+ if(++progress >= 40){
+ //if(++progress >= 300){
+ if(heliumStack == null)
+ heliumStack = UtilsItems.getSimpleStack(ModItems.itemHeliumBlob);
+ else if(heliumStack.getItem() == ModItems.itemHeliumBlob && heliumStack.stackSize < 64)
+ heliumStack.stackSize++;
+ progress = 0;
+ markDirty();
+ }
+ }
+
+ @Override
+ public short getFacing(){
+ return (short) facing;
+ }
+
+ @Override
+ public void setFacing(short dir){
+ facing = dir;
+ }
+
+ /*@Override
+ public void readCustomNBT(NBTTagCompound tag)
+ {
+ this.heliumStack = ItemStack.loadItemStackFromNBT(tag.getCompoundTag("Helium"));
+ this.progress = tag.getInteger("Progress");
+ this.facing = tag.getShort("Facing");
+ this.heat = tag.getInteger("heat");
+ this.prevActive = (this.active = tag.getBoolean("active"));
+ }
+
+ @Override
+ public void writeCustomNBT(NBTTagCompound tag)
+ {
+ tag.setInteger("Progress", this.progress);
+ tag.setShort("Facing", (short) this.facing);
+ tag.setInteger("heat", this.heat);
+ tag.setBoolean("active", this.active);
+ if(heliumStack != null) {
+ NBTTagCompound produce = new NBTTagCompound();
+ heliumStack.writeToNBT(produce);
+ tag.setTag("Helium", produce);
+ }
+ else
+ tag.removeTag("Helium");
+ }*/
+
+
+ @Override
+ public void readFromNBT(NBTTagCompound nbttagcompound)
+ {
+ super.readFromNBT(nbttagcompound);
+
+ //this.heliumStack = ItemStack.loadItemStackFromNBT(nbttagcompound.getCompoundTag("Helium"));
+ NBTTagList list = nbttagcompound.getTagList("Items", 10);
+ for (int i = 0; i < list.tagCount(); ++i) {
+ NBTTagCompound stackTag = list.getCompoundTagAt(i);
+ int slot = stackTag.getByte("Slot") & 255;
+ this.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(stackTag));
+ }
+ this.progress = nbttagcompound.getInteger("Progress");
+ this.facing = nbttagcompound.getShort("Facing");
+ this.heat = nbttagcompound.getInteger("heat");
+ this.output = nbttagcompound.getShort("output");
+ this.prevActive = (this.active = nbttagcompound.getBoolean("active"));
+ }
+
+ @Override
+ public void writeToNBT(NBTTagCompound nbttagcompound)
+ {
+ super.writeToNBT(nbttagcompound);
+
+ nbttagcompound.setInteger("Progress", this.progress);
+ nbttagcompound.setShort("Facing", (short) this.facing);
+ nbttagcompound.setInteger("heat", this.heat);
+ nbttagcompound.setShort("output", (short)(int)getReactorEnergyOutput());
+ nbttagcompound.setBoolean("active", this.active);
+ /*if(heliumStack != null) {
+ NBTTagCompound produce = new NBTTagCompound();
+ heliumStack.writeToNBT(produce);
+ nbttagcompound.setTag("Helium", produce);
+ }
+ else
+ nbttagcompound.removeTag("Helium");*/
+ NBTTagList list = new NBTTagList();
+ for (int i = 0; i < this.getSizeInventory(); ++i) {
+ if (this.getStackInSlot(i) != null) {
+ NBTTagCompound stackTag = new NBTTagCompound();
+ stackTag.setByte("Slot", (byte) i);
+ this.getStackInSlot(i).writeToNBT(stackTag);
+ list.appendTag(stackTag);
+ }
+ }
+ nbttagcompound.setTag("Items", list);
+ }
+
+
+ @Override
+ public Packet getDescriptionPacket() {
+ NBTTagCompound tag = new NBTTagCompound();
+ writeToNBT(tag);
+ return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, -999, tag);
+ }
+
+ @Override
+ public void onDataPacket(net.minecraft.network.NetworkManager net, S35PacketUpdateTileEntity packet) {
+ super.onDataPacket(net, packet);
+ readFromNBT(packet.func_148857_g());
+ }
+
+
+ @Override
+ public int getSizeInventory()
+ {
+ return 19;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(int slot){
+ return heliumStack;
+ }
+
+ @Override
+ public ItemStack decrStackSize(int slot, int decrement){
+ Utils.LOG_WARNING("decrStackSize");
+ if(heliumStack == null)
+ return null;
+ if(decrement < heliumStack.stackSize){
+ ItemStack take = heliumStack.splitStack(decrement);
+ if(heliumStack.stackSize <= 0)
+ heliumStack = null;
+ return take;
+ }
+ ItemStack take = heliumStack;
+ heliumStack = null;
+ return take;
+ }
+
+ @Override
+ public void openInventory() {}
+ @Override
+ public void closeInventory() {}
+
+ @Override
+ public boolean isUseableByPlayer(EntityPlayer player)
+ {
+ return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) == this && player.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D) <= 64.0D;
+ }
+
+ @Override
+ public boolean isItemValidForSlot(int slot, ItemStack stack){
+ return false;
+ }
+
+ @Override
+ public int getInventoryStackLimit(){
+ return 64;
+ }
+
+ @Override
+ public void setInventorySlotContents(int slot, ItemStack stack){
+ heliumStack = stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(int slot){
+ return null;
+ }
+
+ /**
+ * Returns the name of the inventory
+ */
+ @Override
+ public String getInventoryName()
+ {
+ //return "container.helium_collector";
+ return "container.helium_collector";
+ }
+
+ /**
+ * Returns if the inventory is named
+ */
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return false;
+ }
+
+ //IC2 Nuclear Code
+
+
+ public Block[][][] surroundings = new Block[5][5][5];
+ public final InvSlotRadiation reactorSlot;
+ public float output = 0.0F;
+ public int updateTicker;
+ public int heat = 5000;
+ public int maxHeat = 100000;
+ public float hem = 1.0F;
+ private int EmitHeatbuffer = 0;
+ public int EmitHeat = 0;
+ private boolean redstone = false;
+ private boolean fluidcoolreactor = false;
+ private boolean active = true;
+ public boolean prevActive = false;
+
+
+ public short getReactorSize()
+ {
+ //Utils.LOG_WARNING("getReactorSize");
+ if (this.worldObj == null) {
+ Utils.LOG_WARNING("getReactorSize == 9");
+ return 9;
+ }
+ short cols = 3;
+ //Utils.LOG_WARNING("getReactorSize == "+cols);
+ for (Direction direction : Direction.directions)
+ {
+ TileEntity target = direction.applyToTileEntity(this);
+ if ((target instanceof TileEntityHeliumGenerator)) {
+ cols = (short)(cols + 1);
+ Utils.LOG_WARNING("getReactorSize =1= "+cols);
+ }
+ }
+ //Utils.LOG_WARNING("getReactorSize == "+cols);
+ return cols;
+ }
+
+ protected void updateEntityServer()
+ {
+ Utils.LOG_WARNING("updateEntityServer");
+ super.updateEntity();
+
+ if (this.updateTicker++ % getTickRate() != 0) {
+ return;
+ }
+ if (!this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2))
+ {
+ this.output = 0.0F;
+ }
+ else
+ {
+
+ dropAllUnfittingStuff();
+
+ this.output = 0.0F;
+ this.maxHeat = 10000;
+ this.hem = 1.0F;
+
+ processChambers();
+ this.EmitHeatbuffer = 0;
+ if (calculateHeatEffects()) {
+ return;
+ }
+ setActive((this.heat >= 1000) || (this.output > 0.0F));
+
+ markDirty();
+ }
+ ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "output");
+ }
+
+ @Override
+ public void setActive(boolean active1)
+ {
+ Utils.LOG_WARNING("setActive");
+ this.active = active1;
+ if (this.prevActive != active1) {
+ ((NetworkManager)IC2.network.get()).updateTileEntityField(this, "active");
+ }
+ this.prevActive = active1;
+ }
+
+ public void dropAllUnfittingStuff()
+ {
+ Utils.LOG_WARNING("dropAllUnfittingStuff");
+ for (int i = 0; i < this.reactorSlot.size(); i++)
+ {
+ ItemStack stack = this.reactorSlot.get(i);
+ if ((stack != null) && (!isUsefulItem(stack, false)))
+ {
+ this.reactorSlot.put(i, null);
+ eject(stack);
+ }
+ }
+ for (int i = this.reactorSlot.size(); i < this.reactorSlot.rawSize(); i++)
+ {
+ ItemStack stack = this.reactorSlot.get(i);
+
+ this.reactorSlot.put(i, null);
+ eject(stack);
+ }
+ }
+
+ public void eject(ItemStack drop)
+ {
+ Utils.LOG_WARNING("eject");
+ if ((!IC2.platform.isSimulating()) || (drop == null)) {
+ return;
+ }
+ float f = 0.7F;
+ double d = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
+ double d1 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
+ double d2 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
+ EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d1, this.zCoord + d2, drop);
+ entityitem.delayBeforeCanPickup = 10;
+ this.worldObj.spawnEntityInWorld(entityitem);
+ }
+
+ public boolean isUsefulItem(ItemStack stack, boolean forInsertion)
+ {
+ //Utils.LOG_WARNING("isUsefulItem");
+ Item item = stack.getItem();
+ if ((forInsertion) && (this.fluidcoolreactor) &&
+ ((item instanceof ItemReactorHeatStorage)) &&
+ (((ItemReactorHeatStorage)item).getCustomDamage(stack) > 0)) {
+ return false;
+ }
+ if ((item instanceof IReactorComponent)) {
+ return true;
+ }
+ return (item == Ic2Items.TritiumCell.getItem()) || (item == Ic2Items.reactorDepletedUraniumSimple.getItem()) || (item == Ic2Items.reactorDepletedUraniumDual.getItem()) || (item == Ic2Items.reactorDepletedUraniumQuad.getItem()) || (item == Ic2Items.reactorDepletedMOXSimple.getItem()) || (item == Ic2Items.reactorDepletedMOXDual.getItem()) || (item == Ic2Items.reactorDepletedMOXQuad.getItem());
+ }
+
+ public boolean calculateHeatEffects()
+ {
+ Utils.LOG_WARNING("calculateHeatEffects");
+ if ((this.heat < 8000) || (!IC2.platform.isSimulating()) || (ConfigUtil.getFloat(MainConfig.get(), "protection/reactorExplosionPowerLimit") <= 0.0F)) {
+ return false;
+ }
+ float power = this.heat / this.maxHeat;
+ if (power >= 1.0F)
+ {
+ explode();
+ return true;
+ }
+ if ((power >= 0.85F) && (this.worldObj.rand.nextFloat() <= 0.2F * this.hem))
+ {
+ int[] coord = getRandCoord(2);
+ if (coord != null)
+ {
+ Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]);
+ if (block.isAir(this.worldObj, coord[0], coord[1], coord[2]))
+ {
+ this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7);
+ }
+ else if ((block.getBlockHardness(this.worldObj, coord[0], coord[1], coord[2]) >= 0.0F) && (this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null))
+ {
+ Material mat = block.getMaterial();
+ if ((mat == Material.rock) || (mat == Material.iron) || (mat == Material.lava) || (mat == Material.ground) || (mat == Material.clay)) {
+ this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.flowing_lava, 15, 7);
+ } else {
+ this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7);
+ }
+ }
+ }
+ }
+ if (power >= 0.7F)
+ {
+ List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(this.xCoord - 3, this.yCoord - 3, this.zCoord - 3, this.xCoord + 4, this.yCoord + 4, this.zCoord + 4));
+ for (int l = 0; l < list1.size(); l++)
+ {
+ Entity ent = (Entity)list1.get(l);
+ ent.attackEntityFrom(IC2DamageSource.radiation, (int)(this.worldObj.rand.nextInt(4) * this.hem));
+ }
+ }
+ if ((power >= 0.5F) && (this.worldObj.rand.nextFloat() <= this.hem))
+ {
+ int[] coord = getRandCoord(2);
+ if (coord != null)
+ {
+ Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]);
+ if (block.getMaterial() == Material.water) {
+ this.worldObj.setBlockToAir(coord[0], coord[1], coord[2]);
+ }
+ }
+ }
+ if ((power >= 0.4F) && (this.worldObj.rand.nextFloat() <= this.hem))
+ {
+ int[] coord = getRandCoord(2);
+ if ((coord != null) &&
+ (this.worldObj.getTileEntity(coord[0], coord[1], coord[2]) == null))
+ {
+ Block block = this.worldObj.getBlock(coord[0], coord[1], coord[2]);
+ Material mat = block.getMaterial();
+ if ((mat == Material.wood) || (mat == Material.leaves) || (mat == Material.cloth)) {
+ this.worldObj.setBlock(coord[0], coord[1], coord[2], Blocks.fire, 0, 7);
+ }
+ }
+ }
+ return false;
+ }
+
+ public int[] getRandCoord(int radius)
+ {
+ if (radius <= 0) {
+ return null;
+ }
+ int[] c = new int[3];
+ c[0] = (this.xCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius);
+ c[1] = (this.yCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius);
+ c[2] = (this.zCoord + this.worldObj.rand.nextInt(2 * radius + 1) - radius);
+ if ((c[0] == this.xCoord) && (c[1] == this.yCoord) && (c[2] == this.zCoord)) {
+ return null;
+ }
+ return c;
+ }
+
+ public void processChambers()
+ {
+ Utils.LOG_WARNING("processChambers");
+ int size = getReactorSize();
+ for (int pass = 0; pass < 6; pass++) {
+ for (int y = 0; y < 3; y++) {
+ for (int x = 0; x < size; x++)
+ {
+ ItemStack stack = this.reactorSlot.get(x, y);
+ if ((stack != null) && ((stack.getItem() instanceof IReactorComponent)))
+ {
+ IReactorComponent comp = (IReactorComponent)stack.getItem();
+ comp.processChamber(this, stack, x, y, pass == 0);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public ChunkCoordinates getPosition()
+ {
+ return new ChunkCoordinates(this.xCoord, this.yCoord, this.zCoord);
+ }
+
+ @Override
+ public World getWorld() {
+ return this.worldObj;
+ }
+
+ @Override
+ public int getHeat() {
+ return this.heat;
+ }
+
+ @Override
+ public void setHeat(int heat1)
+ {
+ this.heat = heat1;
+ }
+
+ @Override
+ public int addHeat(int amount)
+ {
+ this.heat += amount;
+ return this.heat;
+ }
+
+ @Override
+ public int getMaxHeat()
+ {
+ return this.maxHeat;
+ }
+
+ @Override
+ public void setMaxHeat(int newMaxHeat)
+ {
+ this.maxHeat = newMaxHeat;
+ }
+
+ @Override
+ public void addEmitHeat(int heat)
+ {
+ this.EmitHeatbuffer += heat;
+ }
+
+ @Override
+ public float getHeatEffectModifier()
+ {
+ return this.hem;
+ }
+
+ @Override
+ public void setHeatEffectModifier(float newHEM)
+ {
+ this.hem = newHEM;
+ }
+
+ @Override
+ public float getReactorEnergyOutput()
+ {
+ return this.output;
+ }
+
+ @Override
+ public double getReactorEUEnergyOutput()
+ {
+ return getOfferedEnergy();
+ }
+
+ public double getOfferedEnergy()
+ {
+ return getReactorEnergyOutput() * 5.0F * 1.0F;
+ }
+
+ @Override
+ public float addOutput(float energy)
+ {
+ return this.output += energy;
+ }
+
+ @Override
+ public ItemStack getItemAt(int x, int y)
+ {
+ Utils.LOG_WARNING("getItemAt");
+ if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) {
+ return null;
+ }
+ return this.reactorSlot.get(x, y);
+ }
+
+ @Override
+ public void setItemAt(int x, int y, ItemStack item)
+ {
+ Utils.LOG_WARNING("setItemAt");
+ if ((x < 0) || (x >= getReactorSize()) || (y < 0) || (y >= 6)) {
+ return;
+ }
+ this.reactorSlot.put(x, y, item);
+ }
+
+ public TileEntityHeliumGenerator() {
+ this.updateTicker = IC2.random.nextInt(getTickRate());
+ this.reactorSlot = new InvSlotRadiation(this, "helium_collector", 0, 54); //TODO
+ }
+
+ @Override
+ public void explode() {
+ Utils.LOG_WARNING("Explosion");
+ //TODO
+ }
+
+ @Override
+ public int getTickRate()
+ {
+ return 20;
+ }
+
+ public boolean receiveredstone()
+ {
+ Utils.LOG_WARNING("receiveRedstone");
+ if ((this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord)) || (this.redstone)) {
+ decrStackSize(-1, 1);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean produceEnergy()
+ {
+ Utils.LOG_WARNING("produceEnergy");
+ return (receiveredstone()) && (ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/generator") > 0.0F);
+ }
+
+ @Override
+ public void setRedstoneSignal(boolean redstone)
+ {
+ this.redstone = redstone;
+ }
+
+ @Override
+ public boolean isFluidCooled() {
+ Utils.LOG_WARNING("isFluidCooled");
+ return false;
+ }
+
+ @Override
+ public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
+ {
+ return true;
+ }
+
+ @Override
+ public boolean wrenchCanRemove(EntityPlayer entityPlayer)
+ {
+ return true;
+ }
+
+ @Override
+ public float getWrenchDropRate()
+ {
+ return 1F;
+ }
+
+ @Override
+ public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
+ {
+ return new ItemStack(ModBlocks.blockHeliumGenerator, 1);
+ }
+
+}