Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package thaumcraftextras.blocks.tileEntity;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.network.INetworkManager;
- import net.minecraft.network.packet.Packet;
- import net.minecraft.network.packet.Packet132TileEntityData;
- import net.minecraft.tileentity.TileEntity;
- import net.minecraftforge.common.ForgeDirection;
- import thaumcraft.api.aspects.Aspect;
- import thaumcraft.common.tiles.TileJarFillable;
- import thaumcraftextras.main.Config;
- public class TileEntityGenerator extends TileEntity {
- private String am = "amount";
- private static String AMOUNT = "AMOUNT";
- private int ticks;
- int x, y, z;
- public ForgeDirection orientation;
- public TileEntityGenerator()
- {
- orientation.getOrientation(1) ;
- ticks = 10;
- }
- @Override
- public void updateEntity()
- {
- findEssentia();
- TileEntity potentia = super.worldObj.getBlockTileEntity(x, y, z);
- if (potentia != null && (potentia instanceof TileJarFillable)) {
- if (checkJar((TileJarFillable) potentia))
- {
- System.out.print("YEAHHH");
- }
- }
- }
- public void setName(String value)
- {
- am = value;
- }
- public String getName()
- {
- return am;
- }
- @Override
- public void writeToNBT(NBTTagCompound nbt)
- {
- super.writeToNBT(nbt);
- nbt.setString(AMOUNT, am);
- }
- @Override
- public void readFromNBT(NBTTagCompound nbt)
- {
- super.readFromNBT(nbt);
- am = nbt.getString(AMOUNT);
- }
- @Override
- public Packet getDescriptionPacket() {
- NBTTagCompound tagCompound = new NBTTagCompound();
- writeToNBT(tagCompound);
- return new Packet132TileEntityData(xCoord, yCoord, zCoord, -999, tagCompound);
- }
- @Override
- public void onDataPacket(INetworkManager networkManager, Packet132TileEntityData packet) {
- this.readFromNBT(packet.data);
- }
- public void findEssentia()
- {
- if(x != 0x7fffffff)
- {
- TileEntity te = super.worldObj.getBlockTileEntity(x, y, z);
- if(te != null && (te instanceof TileJarFillable))
- {
- if(checkJar((TileJarFillable)te))
- return;
- x = 0x7fffffff;
- }
- }
- int xx = 0;
- int yy = 0;
- int zz = 0;
- for(int y = -5; y <= 5; y++)
- {
- for(int bb = -5; bb <= 5; bb++)
- {
- for(int cc = 1; cc < 6; cc++)
- {
- x = 0;
- y = 0;
- z = 0;
- if(orientation.getOpposite().offsetX == 0)
- {
- x += bb;
- z += cc * orientation.getOpposite().offsetZ;
- } else
- {
- zz += bb;
- xx += cc * orientation.getOpposite().offsetX;
- }
- TileEntity te = super.worldObj.getBlockTileEntity(x, y, z);
- if(te != null && (te instanceof TileJarFillable) && checkJar((TileJarFillable)te))
- return;
- }
- }
- }
- }
- private boolean checkJar(TileJarFillable jar)
- {
- if(jar.doesContainerContainAmount(Aspect.ENTROPY, 1))
- {
- x = ((TileEntity) (jar)).xCoord;
- y = ((TileEntity) (jar)).yCoord;
- z = ((TileEntity) (jar)).zCoord;
- if (!super.worldObj.isRemote)
- {
- jar.takeFromContainer(Aspect.ENTROPY, 1);
- super.worldObj.addBlockEvent(super.xCoord, super.yCoord,
- super.zCoord, Config.generatorId,
- 5, 0);
- }
- return true;
- }
- else
- {
- return false;
- }
- }
- /*
- private boolean checkEssentia(TileJarFillable jar) {
- if (jar.doesContainerContainAmount(Aspect.FIRE, 1)) {
- x = ((TileEntity) (jar)).xCoord;
- y = ((TileEntity) (jar)).yCoord;
- z = ((TileEntity) (jar)).zCoord;
- if (!super.worldObj.isRemote) {
- jar.takeFromContainer(Aspect.FIRE, 1);
- super.worldObj.addBlockEvent(super.xCoord, super.yCoord,
- super.zCoord, Config.generatorId,
- 5, 0);
- }
- return true;
- } else {
- return false;
- }
- }
- public void findEssentia()
- {
- if (x != 0x7fffffff)
- {
- TileEntity ja = super.worldObj.getBlockTileEntity(x, y, z);
- if (ja != null && (ja instanceof TileJarFillable)) {
- if (checkEssentia((TileJarFillable) ja)) {
- return;
- }
- x = 0x7fffffff;
- }
- }
- int xx = 0;
- int yy = 0;
- int zz = 0;
- for (int y = -5; y <= 5; y++) {
- for (int bb = -5; bb <= 5; bb++) {
- for (int cc = 1; cc < 6; cc++) {
- xx = super.xCoord;
- yy = super.yCoord + y;
- zz = super.zCoord;
- if (orientation.getOpposite().offsetX == 0) {
- xx += bb;
- zz += cc * orientation.getOpposite().offsetZ;
- } else {
- zz += bb;
- xx += cc * orientation.getOpposite().offsetX;
- }
- TileEntity te = super.worldObj.getBlockTileEntity(xx, yy,
- zz);
- if (te != null && (te instanceof TileJarFillable)
- && checkEssentia((TileJarFillable) te)) {
- return;
- }
- }
- }
- }
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment