Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.95 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import java.util.Random;
  4.  
  5. public class AutoFertilizerBlock extends Block implements IAutoFert {
  6.     private int modelID;
  7.     protected AutoFertilizerBlock(int i, int j,int modelid)
  8.     {
  9.         super(i, Material.circuits);
  10.         blockIndexInTexture = j;
  11.         setTickOnLoad(true);
  12.         modelID = modelid;
  13.     }
  14.  
  15.     public void onBlockPlaced(World world, int i, int j, int k, int l)
  16.     {
  17.         world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
  18.  
  19.         int i1 = 0;
  20.         if(l == 1 && world.isBlockOpaqueCube(i, j - 1, k))
  21.         {
  22.             i1 = 5;
  23.         }
  24.         if(l == 2 && world.isBlockOpaqueCube(i, j, k + 1))
  25.         {
  26.             i1 = 4;
  27.         }
  28.         if(l == 3 && world.isBlockOpaqueCube(i, j, k - 1))
  29.         {
  30.             i1 = 3;
  31.         }
  32.         if(l == 4 && world.isBlockOpaqueCube(i + 1, j, k))
  33.         {
  34.             i1 = 2;
  35.         }
  36.         if(l == 5 && world.isBlockOpaqueCube(i - 1, j, k))
  37.         {
  38.             i1 = 1;
  39.         }
  40.         world.setBlockMetadataWithNotify(i, j, k, mod_AutoFertilizer.BitSetDirection(world.getBlockMetadata(i, j, k), i1));
  41.  
  42.         switch (i1)
  43.         {
  44.         case 1:
  45.             setBlockBounds(0.0F, 0.2F, 0.25F, 0.5F, 1F, 0.75F);
  46.             break;
  47.         case 2:
  48.             setBlockBounds(0.5f, 0.2F, 0.25f, 1.0F, 1F, 0.75F);
  49.             break;
  50.         case 3:
  51.             setBlockBounds(0.25f, 0.2F, 0.0F, 0.75F, 1F, 0.5f);
  52.             break;
  53.         case 4:
  54.             setBlockBounds(0.25f, 0.2F, 0.5F, 0.75F, 1F, 1.0F);
  55.             break;
  56.         case 0:
  57.         default:
  58.             setBlockBounds(0.25f, 0.0F, 0.25f, 0.75F, 0.8F, 0.75F);
  59.             break;
  60.         }
  61.     }
  62.  
  63.     public void updateTick(World world, int i, int j, int k, Random random)
  64.     {
  65.         if(mod_AutoFertilizer.GetFertBlockNeedsPower() ? world.isBlockIndirectlyGettingPowered(i, j, k) : !mod_AutoFertilizer.BitGetOn(world.getBlockMetadata(i, j, k)))
  66.         {
  67.             mod_AutoFertilizer.Fert(world, i + 1, j + 1, k + 1,this,2,3);
  68.             world.spawnParticle("splash", (i + 0.5) + ((random.nextDouble() - 0.5D) * 0.4), (j + 0.7), (k + 0.5) + ((random.nextDouble() - 0.5D) * 0.4), (random.nextDouble() - 0.5D) * 20.0D, 20D, (random.nextDouble() - 0.5D) * 20.0D);
  69.         }
  70.         world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
  71.     }
  72.  
  73.     public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
  74.     {
  75.         if(mod_AutoFertilizer.GetFertBlockNeedsPower())
  76.             return false;
  77.         int metadata = world.getBlockMetadata(i, j, k);
  78.         world.setBlockMetadataWithNotify(i, j, k, mod_AutoFertilizer.BitSetOn(metadata, !mod_AutoFertilizer.BitGetOn(metadata)));
  79.         return true;
  80.     }
  81.  
  82.     public void onNeighborBlockChange(World world, int i, int j, int k, int l)
  83.     {
  84.         if(!canBlockStay(world, i, j, k))
  85.         {
  86.             dropBlockAsItem(world, i, j, k,blockID);
  87.             world.setBlockWithNotify(i, j, k, 0);
  88.         }
  89.     }
  90.  
  91.     public boolean canBlockStay(World world, int i, int j, int k)
  92.     {
  93.         return canPlaceBlockAt(world,i,j,k);
  94.     }
  95.  
  96.     public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int i, int j, int k)
  97.     {
  98.         return null;
  99.     }
  100.  
  101.     public boolean isOpaqueCube()
  102.     {
  103.         return false;
  104.     }
  105.  
  106.     public boolean renderAsNormalBlock()
  107.     {
  108.         return false;
  109.     }
  110.  
  111.     public int getRenderType()
  112.     {
  113.         return modelID;
  114.     }
  115.  
  116.     @Override
  117.     public int GetWater() {
  118.         return GetMaxWater();
  119.     }
  120.  
  121.     @Override
  122.     public int GetBoneMeal() {
  123.         return GetMaxBoneMeal();
  124.     }
  125.  
  126.     @Override
  127.     public void SetWater(int water) {
  128.         //currentwater = water;
  129.     }
  130.  
  131.     @Override
  132.     public void SetBoneMeal(int bonemeal) {
  133.         //currentbonemeal = bonemeal;
  134.     }
  135.  
  136.     @Override
  137.     public int GetMaxWater() {
  138.         return 200;
  139.     }
  140.  
  141.     @Override
  142.     public int GetMaxBoneMeal() {
  143.         return 200;
  144.     }
  145.  
  146.     @Override
  147.     public int GetTickRate() {
  148.         return mod_AutoFertilizer.GetFertBlockTicksPerSecond();
  149.     }
  150.  
  151.     public int tickRate()
  152.     {
  153.         return 21 - GetTickRate();
  154.     }
  155.  
  156.     public boolean canPlaceBlockAt(World world, int i, int j, int k)
  157.     {
  158.         if(world.isBlockOpaqueCube(i - 1, j, k))
  159.         {
  160.             return true;
  161.         }
  162.         if(world.isBlockOpaqueCube(i + 1, j, k))
  163.         {
  164.             return true;
  165.         }
  166.         if(world.isBlockOpaqueCube(i, j, k - 1))
  167.         {
  168.             return true;
  169.         }
  170.         if(world.isBlockOpaqueCube(i, j, k + 1))
  171.         {
  172.             return true;
  173.         }
  174.         return world.isBlockOpaqueCube(i, j - 1, k);
  175.     }
  176.  
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement