aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
authordraknyte1 <draknyte1@hotmail.com>2017-02-18 09:43:48 +1000
committerdraknyte1 <draknyte1@hotmail.com>2017-02-18 09:43:48 +1000
commit0b26602190bb40b501c15b2e7672131b97f325b6 (patch)
tree04b4d6f8bdd3c84b95d29ca70fb76a835fd1c419 /src/Java/gtPlusPlus
parent12a40731f44d171aa6a68c8d760178892845faaa (diff)
downloadGT5-Unofficial-0b26602190bb40b501c15b2e7672131b97f325b6.tar.gz
GT5-Unofficial-0b26602190bb40b501c15b2e7672131b97f325b6.tar.bz2
GT5-Unofficial-0b26602190bb40b501c15b2e7672131b97f325b6.zip
% Changed NBT handling for the FishTrap Inventory and Tile entity.
$ Fish Traps no longer work if they have more than 4 others directly beside them. (Fixes an issue where a FishTrap out of water with 4-6 other traps around it would still work).
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java3
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java37
2 files changed, 28 insertions, 12 deletions
diff --git a/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java b/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java
index 9037de451f..7af1f08bd7 100644
--- a/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java
+++ b/src/Java/gtPlusPlus/core/inventories/InventoryFishtrap.java
@@ -1,5 +1,6 @@
package gtPlusPlus.core.inventories;
+import gtPlusPlus.core.util.Utils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -34,6 +35,7 @@ public class InventoryFishTrap implements IInventory{
int slot = data.getInteger("Slot");
if(slot >= 0 && slot < INV_SIZE)
{
+ Utils.LOG_INFO("Trying to read NBT data from inventory.");
inventory[slot] = ItemStack.loadItemStackFromNBT(data);
}
}
@@ -47,6 +49,7 @@ public class InventoryFishTrap implements IInventory{
ItemStack stack = inventory[i];
if(stack != null)
{
+ Utils.LOG_INFO("Trying to write NBT data to inventory.");
NBTTagCompound data = new NBTTagCompound();
stack.writeToNBT(data);
data.setInteger("Slot", i);
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
index 9e7f050f22..df573d5112 100644
--- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
+++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java
@@ -56,15 +56,26 @@ public class TileEntityFishTrap extends TileEntity{
surroundingBlocks[4] = worldObj.getBlock(locationX, locationY, locationZ+1);
surroundingBlocks[5] = worldObj.getBlock(locationX, locationY, locationZ-1);
int waterCount = 0;
+ int trapCount = 0;
for (Block checkBlock : surroundingBlocks){
if (checkBlock == Blocks.water || checkBlock == Blocks.flowing_water || checkBlock.getUnlocalizedName().toLowerCase().contains("water") || checkBlock == ModBlocks.blockFishTrap){
+ if (checkBlock != ModBlocks.blockFishTrap){
waterCount++;
+ }
+ else {
+ waterCount++;
+ trapCount++;
+ }
}
}
- if (waterCount >= 2){
+ if (waterCount >= 2 && trapCount <= 4){
this.waterSides = waterCount;
return true;
}
+ else if (waterCount >= 2 && trapCount > 4){
+ Utils.LOG_INFO("Too many fish traps surrounding this one.");
+ 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)");
+ }
}
}
//Utils.LOG_INFO("Error finding water");
@@ -82,15 +93,18 @@ public class TileEntityFishTrap extends TileEntity{
for (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++;;
+ contents.stackSize++;
+ this.markDirty();
return true;
}
else {
this.getInventory().setInventorySlotContents(checkingSlot, loot);
+ this.markDirty();
return true;
}
}
@@ -100,7 +114,7 @@ public class TileEntityFishTrap extends TileEntity{
checkingSlot++;
}
}
-
+ this.markDirty();
return false;
}
@@ -152,7 +166,12 @@ public class TileEntityFishTrap extends TileEntity{
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)");
tryAddLoot();
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)");
+ markDirty();
+ }
this.tickCount = 0;
}
if (this.tickCount > (this.baseTickRate+500)){
@@ -204,21 +223,15 @@ public class TileEntityFishTrap extends TileEntity{
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
//super.writeToNBT(tagCompound);
+ Utils.LOG_INFO("Trying to write NBT data to TE.");
inventoryContents.writeToNBT(getTag(tagCompound, "ContentsChest"));
-
- /*UUID ownerUUID = getOwnerUUID();
- if (ownerUUID != null){
- tagCompound.setLong("OwnerUUIDMost", ownerUUID.getMostSignificantBits());
- tagCompound.setLong("OwnerUUIDLeast", ownerUUID.getLeastSignificantBits());
- }*/
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
//super.readFromNBT(tagCompound);
+ Utils.LOG_INFO("Trying to read NBT data from TE.");
inventoryContents.readFromNBT(tagCompound.getCompoundTag("ContentsChest"));
-
- /*setOwnerUUID(new UUID(tagCompound.getLong("OwnerUUIDMost"), tagCompound.getLong("OwnerUUIDLeast")));*/
}
}