Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.techmage.magetech.tileentity;
- import com.techmage.magetech.init.ModBlocks;
- import com.techmage.magetech.utility.LogHelper;
- import net.minecraft.nbt.NBTTagCompound;
- public class TileEntityElementalExtractor extends TileEntityMageTech
- {
- public int productionTime = 0;
- public int CurrentEssence = 0;
- public TileEntityElementalExtractor() { }
- @Override
- public void writeToNBT(NBTTagCompound nbtTagCompound)
- {
- super.writeToNBT(nbtTagCompound);
- nbtTagCompound.setShort("CurrentEssence", (short)this.CurrentEssence);
- }
- @Override
- public void readFromNBT(NBTTagCompound nbtTagCompound)
- {
- super.readFromNBT(nbtTagCompound);
- this.CurrentEssence = nbtTagCompound.getShort("CurrentEssence");
- }
- @Override
- public void updateEntity()
- {
- if (!worldObj.isRemote)
- {
- if (productionTime > 100)
- {
- this.CurrentEssence += getValidClusters();
- productionTime = 0;
- if (worldObj.getBlock(this.xCoord + 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 3, this.yCoord, this.zCoord);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord - 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 3, this.yCoord, this.zCoord);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord + 2);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord - 2);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord + 3) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 3);
- LogHelper.info(cluster.getEssenceLeft());
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 3) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 3);
- if (cluster.getEssenceLeft() >= 1)
- cluster.collectEssence();
- }
- } else
- productionTime++;
- }
- }
- public int getValidClusters() {
- if (!worldObj.isRemote)
- {
- int Clusters = 0;
- if (worldObj.getBlock(this.xCoord + 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 3, this.yCoord, this.zCoord);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord - 2);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord - 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 3, this.yCoord, this.zCoord);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord + 2);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord - 2);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord + 3) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 3);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 3) == ModBlocks.crystalCluster)
- {
- TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 3);
- if (cluster.getEssenceLeft() >= 1)
- Clusters++;
- }
- return Clusters;
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement