diff options
author | draknyte1 <draknyte1@hotmail.com> | 2017-02-15 18:12:06 +1000 |
---|---|---|
committer | draknyte1 <draknyte1@hotmail.com> | 2017-02-15 18:12:06 +1000 |
commit | 3022f3f4f96d8892b6d8c073eea7f852dcf1d71c (patch) | |
tree | 9eff729af8fb949111db54050138047f4ff3caed /src/Java/gtPlusPlus/core/tileentities | |
parent | 099ad908e559e0d4753fe265462b2263dc6f3ba3 (diff) | |
download | GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.tar.gz GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.tar.bz2 GT5-Unofficial-3022f3f4f96d8892b6d8c073eea7f852dcf1d71c.zip |
$ Fixed GT material blast smelter recipes not using GT dusts.
+ Added Double Clay Plates.
+ Added the TileEntity for a Fish Trap.
Diffstat (limited to 'src/Java/gtPlusPlus/core/tileentities')
-rw-r--r-- | src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java new file mode 100644 index 0000000000..61cacb06e8 --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityFishTrap.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.tileentities.general; + +import java.util.UUID; + +import gtPlusPlus.core.inventories.*; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityFishTrap extends TileEntity{ + + private UUID ownerUUID; + private int tickCount = 0; + private boolean isInWater = false; + private InventoryFishtrap inventoryChest; + private int locationX = this.xCoord; + private int locationY = this.yCoord;; + private int locationZ = this.zCoord;; + + public TileEntityFishTrap(){ + this.inventoryChest = new InventoryFishtrap();//number of slots - without product slot + this.canUpdate(); + } + + public boolean setTileLocation(){ + if (this.hasWorldObj()){ + locationX = this.xCoord; + locationY = this.yCoord; + locationZ = this.zCoord; + return true; + + } + return false; + } + + public final boolean isSurroundedByWater(){ + Block[] surroundingBlocks = new Block[6]; + if (this.hasWorldObj()){ + surroundingBlocks[0] = worldObj.getBlock(locationX, locationY+1, locationZ); //Above + surroundingBlocks[1] = worldObj.getBlock(locationX, locationY-1, locationZ); //Below + surroundingBlocks[2] = worldObj.getBlock(locationX+1, locationY, locationZ); + surroundingBlocks[3] = worldObj.getBlock(locationX-1, locationY, locationZ); + surroundingBlocks[4] = worldObj.getBlock(locationX, locationY, locationZ+1); + surroundingBlocks[5] = worldObj.getBlock(locationX, locationY, locationZ-1); + int waterCount = 0; + for (Block checkBlock : surroundingBlocks){ + if (checkBlock == Blocks.water || checkBlock == Blocks.flowing_water){ + waterCount++; + } + } + if (waterCount >= 5){ + return true; + } + return false; + } + return false; + } + + @Override + public void updateEntity(){ + //if (anyPlayerInRange()){ + this.tickCount += 1; + if (this.worldObj.isRemote){ + this.isInWater = isSurroundedByWater(); + + if (this.isInWater){ + //Add Loot + } + //Add some Loot + } + //} + } + + public boolean anyPlayerInRange(){ + return this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, 32) != null; + } + + public UUID getOwnerUUID() { + return ownerUUID; + } + + public void setOwnerUUID(UUID ownerUUID) { + this.ownerUUID = ownerUUID; + markDirty(); + } + + public NBTTagCompound getTag(NBTTagCompound nbt, String tag){ + if(!nbt.hasKey(tag)){ + nbt.setTag(tag, new NBTTagCompound()); + } + return nbt.getCompoundTag(tag); + } + + + @Override + public void writeToNBT(NBTTagCompound tagCompound) { + super.writeToNBT(tagCompound); + inventoryChest.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); + + inventoryChest.readFromNBT(tagCompound.getCompoundTag("ContentsChest")); + setOwnerUUID(new UUID(tagCompound.getLong("OwnerUUIDMost"), tagCompound.getLong("OwnerUUIDLeast"))); + } + +} |