Advertisement
TechMage66

TileEntityElementalExtractor

May 12th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.50 KB | None | 0 0
  1. package com.techmage.magetech.tileentity;
  2.  
  3. import com.techmage.magetech.init.ModBlocks;
  4. import com.techmage.magetech.utility.LogHelper;
  5. import net.minecraft.nbt.NBTTagCompound;
  6.  
  7. public class TileEntityElementalExtractor extends TileEntityMageTech
  8. {
  9.     public int productionTime = 0;
  10.     public int CurrentEssence = 0;
  11.  
  12.     public TileEntityElementalExtractor() { }
  13.  
  14.     @Override
  15.     public void writeToNBT(NBTTagCompound nbtTagCompound)
  16.     {
  17.         super.writeToNBT(nbtTagCompound);
  18.         nbtTagCompound.setShort("CurrentEssence", (short)this.CurrentEssence);
  19.     }
  20.  
  21.     @Override
  22.     public void readFromNBT(NBTTagCompound nbtTagCompound)
  23.     {
  24.         super.readFromNBT(nbtTagCompound);
  25.         this.CurrentEssence = nbtTagCompound.getShort("CurrentEssence");
  26.     }
  27.  
  28.     @Override
  29.     public void updateEntity()
  30.     {
  31.  
  32.         if (!worldObj.isRemote)
  33.         {
  34.  
  35.             if (productionTime > 100)
  36.             {
  37.                 this.CurrentEssence += getValidClusters();
  38.                 productionTime = 0;
  39.  
  40.                 if (worldObj.getBlock(this.xCoord + 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
  41.                 {
  42.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 3, this.yCoord, this.zCoord);
  43.                     if (cluster.getEssenceLeft() >= 1)
  44.                         cluster.collectEssence();
  45.                 }
  46.  
  47.                 if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
  48.                 {
  49.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
  50.                     if (cluster.getEssenceLeft() >= 1)
  51.                         cluster.collectEssence();
  52.                 }
  53.  
  54.                 if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
  55.                 {
  56.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
  57.                     if (cluster.getEssenceLeft() >= 1)
  58.                         cluster.collectEssence();
  59.                 }
  60.  
  61.  
  62.                 if (worldObj.getBlock(this.xCoord - 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
  63.                 {
  64.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 3, this.yCoord, this.zCoord);
  65.                     if (cluster.getEssenceLeft() >= 1)
  66.                         cluster.collectEssence();
  67.                 }
  68.  
  69.                 if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
  70.                 {
  71.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord + 2);
  72.                     if (cluster.getEssenceLeft() >= 1)
  73.                         cluster.collectEssence();
  74.                 }
  75.  
  76.                 if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
  77.                 {
  78.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord - 2);
  79.                     if (cluster.getEssenceLeft() >= 1)
  80.                         cluster.collectEssence();
  81.                 }
  82.  
  83.  
  84.                 if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord + 3) == ModBlocks.crystalCluster)
  85.                 {
  86.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 3);
  87.                     LogHelper.info(cluster.getEssenceLeft());
  88.                     if (cluster.getEssenceLeft() >= 1)
  89.                         cluster.collectEssence();
  90.                 }
  91.  
  92.                 if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 3) == ModBlocks.crystalCluster)
  93.                 {
  94.                     TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 3);
  95.                     if (cluster.getEssenceLeft() >= 1)
  96.                         cluster.collectEssence();
  97.                 }
  98.  
  99.             } else
  100.                 productionTime++;
  101.         }
  102.     }
  103.  
  104.     public int getValidClusters() {
  105.  
  106.         if (!worldObj.isRemote)
  107.         {
  108.             int Clusters = 0;
  109.  
  110.             if (worldObj.getBlock(this.xCoord + 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
  111.             {
  112.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 3, this.yCoord, this.zCoord);
  113.                 if (cluster.getEssenceLeft() >= 1)
  114.                     Clusters++;
  115.             }
  116.  
  117.             if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
  118.             {
  119.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord + 2);
  120.                 if (cluster.getEssenceLeft() >= 1)
  121.                     Clusters++;
  122.             }
  123.  
  124.             if (worldObj.getBlock(this.xCoord + 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
  125.             {
  126.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord + 2, this.yCoord, this.zCoord - 2);
  127.                 if (cluster.getEssenceLeft() >= 1)
  128.                     Clusters++;
  129.             }
  130.  
  131.  
  132.             if (worldObj.getBlock(this.xCoord - 3, this.yCoord, this.zCoord) == ModBlocks.crystalCluster)
  133.             {
  134.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 3, this.yCoord, this.zCoord);
  135.                 if (cluster.getEssenceLeft() >= 1)
  136.                     Clusters++;
  137.             }
  138.  
  139.             if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord + 2) == ModBlocks.crystalCluster)
  140.             {
  141.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord + 2);
  142.                 if (cluster.getEssenceLeft() >= 1)
  143.                     Clusters++;
  144.             }
  145.  
  146.             if (worldObj.getBlock(this.xCoord - 2, this.yCoord, this.zCoord - 2) == ModBlocks.crystalCluster)
  147.             {
  148.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord - 2, this.yCoord, this.zCoord - 2);
  149.                 if (cluster.getEssenceLeft() >= 1)
  150.                     Clusters++;
  151.             }
  152.  
  153.  
  154.             if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord + 3) == ModBlocks.crystalCluster)
  155.             {
  156.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord + 3);
  157.                 if (cluster.getEssenceLeft() >= 1)
  158.                     Clusters++;
  159.             }
  160.  
  161.             if (worldObj.getBlock(this.xCoord, this.yCoord, this.zCoord - 3) == ModBlocks.crystalCluster)
  162.             {
  163.                 TileEntityCrystalCluster cluster = (TileEntityCrystalCluster) worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord - 3);
  164.                 if (cluster.getEssenceLeft() >= 1)
  165.                     Clusters++;
  166.             }
  167.  
  168.             return Clusters;
  169.         }
  170.  
  171.         return 0;
  172.  
  173.     }
  174. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement