aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
authordraknyte1 <draknyte1@hotmail.com>2017-03-12 13:55:59 +1000
committerdraknyte1 <draknyte1@hotmail.com>2017-03-12 13:55:59 +1000
commitd30eb824cb12b0a7301c435330875cf1c60fb29a (patch)
tree68be4a02d45ca04bb9b71d6f66ae3250f7f83b64 /src/Java/gtPlusPlus
parentf11f2ebc76a5a80851da94b03cbafb0608fc2a7d (diff)
downloadGT5-Unofficial-d30eb824cb12b0a7301c435330875cf1c60fb29a.tar.gz
GT5-Unofficial-d30eb824cb12b0a7301c435330875cf1c60fb29a.tar.bz2
GT5-Unofficial-d30eb824cb12b0a7301c435330875cf1c60fb29a.zip
+ Added missing classes from the Helium Generator. Forgot to commit them last time.
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/core/block/machine/HeliumGenerator.java93
-rw-r--r--src/Java/gtPlusPlus/core/container/Container_HeliumGenerator.java188
-rw-r--r--src/Java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java37
-rw-r--r--src/Java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java176
-rw-r--r--src/Java/gtPlusPlus/core/slots/SlotFuelRod.java25
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java156
6 files changed, 675 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/block/machine/HeliumGenerator.java b/src/Java/gtPlusPlus/core/block/machine/HeliumGenerator.java
new file mode 100644
index 0000000000..98c7eaafd2
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/block/machine/HeliumGenerator.java
@@ -0,0 +1,93 @@
+package gtPlusPlus.core.block.machine;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import cpw.mods.fml.common.registry.LanguageRegistry;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.core.creative.AddToCreativeTab;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator;
+import net.minecraft.block.BlockContainer;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.IIcon;
+import net.minecraft.world.World;
+
+public class HeliumGenerator extends BlockContainer
+{
+ @SideOnly(Side.CLIENT)
+ private IIcon textureTop;
+ @SideOnly(Side.CLIENT)
+ private IIcon textureBottom;
+ @SideOnly(Side.CLIENT)
+ private IIcon textureFront;
+
+
+ @SuppressWarnings("deprecation")
+ public HeliumGenerator()
+ {
+ super(Material.wood);
+ this.setBlockName("blockHeliumGenerator");
+ this.setCreativeTab(AddToCreativeTab.tabMachines);
+ GameRegistry.registerBlock(this, "blockHeliumGenerator");
+ LanguageRegistry.addName(this, "Helium Generator");
+
+ }
+
+ /**
+ * Gets the block's texture. Args: side, meta
+ */
+ @Override
+ @SideOnly(Side.CLIENT)
+ public IIcon getIcon(final int p_149691_1_, final int p_149691_2_)
+ {
+ return p_149691_1_ == 1 ? this.textureTop : (p_149691_1_ == 0 ? this.textureBottom : ((p_149691_1_ != 2) && (p_149691_1_ != 4) ? this.blockIcon : this.textureFront));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(final IIconRegister p_149651_1_)
+ {
+ this.blockIcon = p_149651_1_.registerIcon(CORE.MODID + ":" + "Chrono/" + "CyberPanel2");
+ this.textureTop = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "CyberPanel2");
+ this.textureBottom = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "CyberPanel");
+ this.textureFront = p_149651_1_.registerIcon(CORE.MODID + ":" + "TileEntities/" + "CyberPanel");
+ }
+
+ /**
+ * Called upon block activation (right click on the block.)
+ */
+ @Override
+ public boolean onBlockActivated(final World world, final int x, final int y, final int z, final EntityPlayer player, final int side, final float lx, final float ly, final float lz)
+ {
+ if (world.isRemote) {
+ return true;
+ }
+
+ final TileEntity te = world.getTileEntity(x, y, z);
+ if ((te != null) && (te instanceof TileEntityHeliumGenerator)){ //TODO
+ player.openGui(GTplusplus.instance, 1, world, x, y, z); //TODO
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public int getRenderBlockPass() {
+ return 1;
+ }
+
+ @Override
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ @Override
+ public TileEntity createNewTileEntity(final World world, final int p_149915_2_) {
+ return new TileEntityHeliumGenerator();
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/container/Container_HeliumGenerator.java b/src/Java/gtPlusPlus/core/container/Container_HeliumGenerator.java
new file mode 100644
index 0000000000..f98d0cd561
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/container/Container_HeliumGenerator.java
@@ -0,0 +1,188 @@
+package gtPlusPlus.core.container;
+
+import gtPlusPlus.core.block.ModBlocks;
+import gtPlusPlus.core.inventories.InventoryHeliumGenerator;
+import gtPlusPlus.core.slots.SlotFuelRod;
+import gtPlusPlus.core.slots.SlotNoInput;
+import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator;
+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;
+import net.minecraft.world.World;
+
+public class Container_HeliumGenerator extends Container {
+
+ protected TileEntityHeliumGenerator tile_entity;
+ public final InventoryHeliumGenerator inventoryChest;
+
+ private final World worldObj;
+ private final int posX;
+ private final int posY;
+ private final int posZ;
+
+
+ public static int StorageSlotNumber = 18; //Number of slots in storage area
+ public static int InventorySlotNumber = 36; //Inventory Slots (Inventory and Hotbar)
+ public static int FullSlotNumber = InventorySlotNumber + StorageSlotNumber; //All slots
+
+ private final int[] slotStorage = new int[15];
+
+ public Container_HeliumGenerator(final InventoryPlayer inventory, final TileEntityHeliumGenerator te){
+ this.tile_entity = te;
+ this.inventoryChest = te.getInventory();
+
+ int var6;
+ int var7;
+ this.worldObj = te.getWorldObj();
+ this.posX = te.xCoord;
+ this.posY = te.yCoord;
+ this.posZ = te.zCoord;
+
+ int o=0;
+
+ //Output
+ this.addSlotToContainer(new SlotNoInput(this.inventoryChest, 0, 80, 35));
+ this.slotStorage[o] = o;
+ o++;
+
+ //Side A
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 3; ++var7)
+ {
+ this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, var7 + (var6 * 4), 36+ 8 + (var7 * 18), 8 + 7 + (var6 * 18)));
+ this.slotStorage[o] = o;
+ o++;
+ }
+ }
+
+ //Side B
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 3; ++var7)
+ {
+ this.addSlotToContainer(new SlotFuelRod(this.inventoryChest, var7 + (var6 * 4), 90 + 8 + (var7 * 18), 8 + 7 + (var6 * 18)));
+ this.slotStorage[o] = o;
+ o++;
+ }
+ }
+
+ o=0;
+
+ //Player Inventory
+ for (var6 = 0; var6 < 3; ++var6)
+ {
+ for (var7 = 0; var7 < 9; ++var7)
+ {
+ this.addSlotToContainer(new Slot(inventory, var7 + (var6 * 9) + 9, 8 + (var7 * 18), 84 + (var6 * 18)));
+ }
+ }
+
+ //Player Hotbar
+ for (var6 = 0; var6 < 9; ++var6)
+ {
+ this.addSlotToContainer(new Slot(inventory, var6, 8 + (var6 * 18), 142));
+ }
+
+ }
+
+ @Override
+ public ItemStack slotClick(final int aSlotIndex, final int aMouseclick, final int aShifthold, final EntityPlayer aPlayer){
+
+ if (!aPlayer.worldObj.isRemote){
+ if ((aSlotIndex == 999) || (aSlotIndex == -999)){
+ //Utils.LOG_WARNING("??? - "+aSlotIndex);
+ }
+ }
+ return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
+ }
+
+
+
+
+
+ @Override
+ public void onContainerClosed(final EntityPlayer par1EntityPlayer){
+ super.onContainerClosed(par1EntityPlayer);
+ }
+
+
+ @Override
+ public boolean canInteractWith(final EntityPlayer par1EntityPlayer){
+ if (this.worldObj.getBlock(this.posX, this.posY, this.posZ) != ModBlocks.blockHeliumGenerator){
+ return false;
+ }
+
+ return par1EntityPlayer.getDistanceSq(this.posX + 0.5D, this.posY + 0.5D, this.posZ + 0.5D) <= 64D;
+ }
+
+
+ @Override
+ public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int par2)
+ {
+ ItemStack var3 = null;
+ final Slot var4 = (Slot)this.inventorySlots.get(par2);
+
+ if ((var4 != null) && var4.getHasStack())
+ {
+ final ItemStack var5 = var4.getStack();
+ var3 = var5.copy();
+
+ /*if (par2 == 0)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, true))
+ {
+ return null;
+ }
+
+ var4.onSlotChange(var5, var3);
+ }
+ else if (par2 >= InOutputSlotNumber && par2 < InventoryOutSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InventoryOutSlotNumber, FullSlotNumber, false))
+ {
+ return null;
+ }
+ }
+ else if (par2 >= InventoryOutSlotNumber && par2 < FullSlotNumber)
+ {
+ if (!this.mergeItemStack(var5, InOutputSlotNumber, InventoryOutSlotNumber, false))
+ {
+ return null;
+ }
+ }
+ else if (!this.mergeItemStack(var5, InOutputSlotNumber, FullSlotNumber, false))
+ {
+ return null;
+ }*/
+
+ if (var5.stackSize == 0)
+ {
+ var4.putStack((ItemStack)null);
+ }
+ else
+ {
+ var4.onSlotChanged();
+ }
+
+ if (var5.stackSize == var3.stackSize)
+ {
+ return null;
+ }
+
+ var4.onPickupFromSlot(par1EntityPlayer, var5);
+ }
+
+ return var3;
+ }
+
+ //Can merge Slot
+ @Override
+ public boolean func_94530_a(final ItemStack p_94530_1_, final Slot p_94530_2_) {
+ return super.func_94530_a(p_94530_1_, p_94530_2_);
+ }
+
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java b/src/Java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java
new file mode 100644
index 0000000000..0f02b709e6
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/gui/machine/GUI_HeliumGenerator.java
@@ -0,0 +1,37 @@
+package gtPlusPlus.core.gui.machine;
+
+import org.lwjgl.opengl.GL11;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gtPlusPlus.core.container.Container_HeliumGenerator;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.tileentities.general.TileEntityHeliumGenerator;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.util.ResourceLocation;
+
+@SideOnly(Side.CLIENT)
+public class GUI_HeliumGenerator extends GuiContainer {
+
+ private static final ResourceLocation guiTexture = new ResourceLocation(CORE.MODID, "textures/gui/helium_collector_gui.png");
+
+ public GUI_HeliumGenerator(final InventoryPlayer player_inventory, final TileEntityHeliumGenerator te){
+ super(new Container_HeliumGenerator(player_inventory, te));
+ }
+
+ @Override
+ protected void drawGuiContainerForegroundLayer(final int i, final int j){
+ //this.fontRendererObj.drawString(I18n.format("", new Object[0]), 28, 6, 4210752);
+ }
+
+ @Override
+ protected void drawGuiContainerBackgroundLayer(final float f, final int i, final int j){
+ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ this.mc.renderEngine.bindTexture(guiTexture);
+ final int x = (this.width - this.xSize) / 2;
+ final int y = (this.height - this.ySize) / 2;
+ this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java b/src/Java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java
new file mode 100644
index 0000000000..0288aa4d29
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/inventories/InventoryHeliumGenerator.java
@@ -0,0 +1,176 @@
+package gtPlusPlus.core.inventories;
+
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+
+public class InventoryHeliumGenerator implements IInventory{
+
+ private final String name = "Helium";
+
+ /** Defining your inventory size this way is handy */
+ public static final int INV_SIZE = 19;
+
+ /** Inventory's size must be same as number of slots you add to the Container class */
+ private ItemStack[] inventory = new ItemStack[INV_SIZE];
+
+ public void readFromNBT(final NBTTagCompound nbt){
+ final NBTTagList list = nbt.getTagList("Items", 10);
+ this.inventory = new ItemStack[INV_SIZE];
+ for(int i = 0;i<list.tagCount();i++){
+ final NBTTagCompound data = list.getCompoundTagAt(i);
+ final int slot = data.getInteger("Slot");
+ if((slot >= 0) && (slot < INV_SIZE)){
+ //Utils.LOG_INFO("Trying to read NBT data from inventory.");
+ this.inventory[slot] = ItemStack.loadItemStackFromNBT(data);
+ }
+ }
+ }
+
+ public void writeToNBT(final NBTTagCompound nbt){
+ final NBTTagList list = new NBTTagList();
+ for(int i = 0;i<INV_SIZE;i++){
+ final ItemStack stack = this.inventory[i];
+ if(stack != null){
+ //Utils.LOG_INFO("Trying to write NBT data to inventory.");
+ final NBTTagCompound data = new NBTTagCompound();
+ stack.writeToNBT(data);
+ data.setInteger("Slot", i);
+ list.appendTag(data);
+ }
+ }
+ nbt.setTag("Items", list);
+ }
+
+ @Override
+ public int getSizeInventory()
+ {
+ return this.inventory.length;
+ }
+
+ public ItemStack[] getInventory(){
+ return this.inventory;
+ }
+
+ @Override
+ public ItemStack getStackInSlot(final int slot)
+ {
+ return this.inventory[slot];
+ }
+
+ @Override
+ public ItemStack decrStackSize(final int slot, final int amount)
+ {
+ ItemStack stack = this.getStackInSlot(slot);
+ if(stack != null)
+ {
+ if(stack.stackSize > amount)
+ {
+ stack = stack.splitStack(amount);
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+ else
+ {
+ // this method also calls markDirty, so we don't need to call it again
+ this.setInventorySlotContents(slot, null);
+ }
+ }
+ return stack;
+ }
+
+ @Override
+ public ItemStack getStackInSlotOnClosing(final int slot)
+ {
+ final ItemStack stack = this.getStackInSlot(slot);
+ this.setInventorySlotContents(slot, null);
+ return stack;
+ }
+
+ @Override
+ public void setInventorySlotContents(final int slot, final ItemStack stack)
+ {
+ this.inventory[slot] = stack;
+
+ if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit()))
+ {
+ stack.stackSize = this.getInventoryStackLimit();
+ }
+
+ // Don't forget this line or your inventory will not be saved!
+ this.markDirty();
+ }
+
+ // 1.7.2+ renamed to getInventoryName
+ @Override
+ public String getInventoryName()
+ {
+ return this.name;
+ }
+
+ // 1.7.2+ renamed to hasCustomInventoryName
+ @Override
+ public boolean hasCustomInventoryName()
+ {
+ return this.name.length() > 0;
+ }
+
+ @Override
+ public int getInventoryStackLimit()
+ {
+ return 64;
+ }
+
+ /**
+ * This is the method that will handle saving the inventory contents, as it is called (or should be called!)
+ * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also
+ * let you change things in your inventory without ever opening a Gui, if you want.
+ */
+ // 1.7.2+ renamed to markDirty
+ @Override
+ public void markDirty()
+ {
+ for (int i = 0; i < this.getSizeInventory(); ++i)
+ {
+ final ItemStack temp = this.getStackInSlot(i);
+ if (temp != null){
+ //Utils.LOG_INFO("Slot "+i+" contains "+temp.getDisplayName()+" x"+temp.stackSize);
+ }
+
+ if ((temp != null) && (temp.stackSize == 0)) {
+ this.inventory[i] = null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isUseableByPlayer(final EntityPlayer entityplayer)
+ {
+ return true;
+ }
+
+ // 1.7.2+ renamed to openInventory(EntityPlayer player)
+ @Override
+ public void openInventory() {}
+
+ // 1.7.2+ renamed to closeInventory(EntityPlayer player)
+ @Override
+ public void closeInventory() {}
+
+ /**
+ * This method doesn't seem to do what it claims to do, as
+ * items can still be left-clicked and placed in the inventory
+ * even when this returns false
+ */
+ @Override
+ public boolean isItemValidForSlot(final int slot, final ItemStack itemstack)
+ {
+ // Don't want to be able to store the inventory item within itself
+ // Bad things will happen, like losing your inventory
+ // Actually, this needs a custom Slot to work
+ return true;
+ }
+
+} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/slots/SlotFuelRod.java b/src/Java/gtPlusPlus/core/slots/SlotFuelRod.java
new file mode 100644
index 0000000000..f925376c69
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/slots/SlotFuelRod.java
@@ -0,0 +1,25 @@
+package gtPlusPlus.core.slots;
+
+import ic2.core.Ic2Items;
+import net.minecraft.inventory.IInventory;
+import net.minecraft.inventory.Slot;
+import net.minecraft.item.ItemStack;
+
+public class SlotFuelRod extends Slot{
+
+ public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) {
+ super(inventory, index, x, y);
+
+ }
+
+ @Override
+ public boolean isItemValid(final ItemStack itemstack) {
+ return itemstack.getItem().getClass() == Ic2Items.fuelRod.getItem().getClass();
+ }
+
+ @Override
+ public int getSlotStackLimit() {
+ return 1;
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java
new file mode 100644
index 0000000000..7cf7c992e2
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityHeliumGenerator.java
@@ -0,0 +1,156 @@
+package gtPlusPlus.core.tileentities.general;
+
+import gregtech.api.enums.GT_Values;
+import gtPlusPlus.core.inventories.InventoryHeliumGenerator;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.item.ItemUtils;
+import gtPlusPlus.core.util.math.MathUtils;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+
+public class TileEntityHeliumGenerator extends TileEntity{
+
+ private int tickCount = 0;
+ private final InventoryHeliumGenerator inventoryContents; //TODO
+ private int locationX;
+ private int locationY;
+ private int locationZ;
+ private int baseTickRate = 1200;
+
+ public TileEntityHeliumGenerator(){
+ this.inventoryContents = new InventoryHeliumGenerator();//number of slots - without product slot
+ this.setTileLocation();
+ }
+
+ public boolean setTileLocation(){
+ if (this.hasWorldObj()){
+ if (!this.getWorldObj().isRemote){
+ this.locationX = this.xCoord;
+ this.locationY = this.yCoord;
+ this.locationZ = this.zCoord;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public InventoryHeliumGenerator getInventory(){
+ return this.inventoryContents;
+ }
+
+ public boolean tryAddLoot(){
+ if (this.getInventory().getInventory() != null){
+ int checkingSlot = 0;
+ final ItemStack loot = this.generateLootForFishTrap();
+ for (final ItemStack contents : this.getInventory().getInventory()){
+ if (contents == null){
+ this.getInventory().setInventorySlotContents(checkingSlot, loot);
+ this.markDirty();
+ return true;
+ }
+ else if (contents.getItem() == loot.getItem()){
+ if (contents.stackSize < contents.getMaxStackSize()){
+ contents.stackSize++;
+ this.markDirty();
+ return true;
+ }
+ else {
+ this.getInventory().setInventorySlotContents(checkingSlot, loot);
+ this.markDirty();
+ return true;
+ }
+ }
+ else {
+
+ }
+ checkingSlot++;
+ }
+ }
+ this.markDirty();
+ return false;
+ }
+
+ private ItemStack generateLootForFishTrap() {
+ final int lootWeight = MathUtils.randInt(0, 1000);
+ ItemStack loot = GT_Values.NI;
+ if (lootWeight > 990){
+ loot = ItemUtils.getSimpleStack(Items.slime_ball);
+ }
+ return loot;
+ }
+
+ @Override
+ public void updateEntity(){
+ if (!this.worldObj.isRemote){
+ this.tickCount++;
+ //Utils.LOG_INFO("Ticking "+this.tickCount);
+ //Check if the Tile is within water once per second.
+ if ((this.tickCount%20)==0){
+
+ }
+ else {
+
+ }
+
+ if (true){
+ this.calculateTickrate();
+ }
+
+ //Try add some loot once every 30 seconds.
+ if ((this.tickCount%this.baseTickRate)==0){
+ if (true){
+ //Add loot
+ //Utils.LOG_INFO("Adding Loot to the fishtrap at x["+this.locationX+"] y["+this.locationY+"] z["+this.locationZ+"] (Ticking for loot every "+this.baseTickRate+" ticks)");
+ this.tryAddLoot();
+ this.markDirty();
+ }
+ else {
+ Utils.LOG_INFO("This Trap does not have enough water around it.");
+ Utils.LOG_INFO("Not adding Loot to the fishtrap at x["+this.locationX+"] y["+this.locationY+"] z["+this.locationZ+"] (Ticking for loot every "+this.baseTickRate+" ticks)");
+ this.markDirty();
+ }
+ this.tickCount = 0;
+ }
+ if (this.tickCount > (this.baseTickRate+500)){
+ this.tickCount = 0;
+ }
+
+
+ }
+ }
+
+ public void calculateTickrate(){
+ int calculateTickrate = 0;
+ this.baseTickRate = calculateTickrate;
+ }
+
+ public boolean anyPlayerInRange(){
+ return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null;
+ }
+
+ public NBTTagCompound getTag(final NBTTagCompound nbt, final String tag){
+ if(!nbt.hasKey(tag)){
+ nbt.setTag(tag, new NBTTagCompound());
+ }
+ return nbt.getCompoundTag(tag);
+ }
+
+ @Override
+ public void writeToNBT(final NBTTagCompound nbt){
+ super.writeToNBT(nbt);
+ //Utils.LOG_INFO("Trying to write NBT data to TE.");
+ final NBTTagCompound chestData = new NBTTagCompound();
+ this.inventoryContents.writeToNBT(chestData);
+ nbt.setTag("ContentsChest", chestData);
+ }
+
+ @Override
+ public void readFromNBT(final NBTTagCompound nbt){
+ super.readFromNBT(nbt);
+ //Utils.LOG_INFO("Trying to read NBT data from TE.");
+ this.inventoryContents.readFromNBT(nbt.getCompoundTag("ContentsChest"));
+ }
+
+}