Advertisement
yarinch

Untitled

Sep 29th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.52 KB | None | 0 0
  1. package com.yarinch.modularmachines.block;
  2.  
  3. import com.yarinch.modularmachines.ModularMachines;
  4. import com.yarinch.modularmachines.tileentity.TileEntityMachineCore;
  5. import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
  6. import net.minecraft.block.Block;
  7. import net.minecraft.entity.player.EntityPlayer;
  8. import net.minecraft.world.World;
  9.  
  10. public class BlockMachineBase extends BlockMM {
  11.  
  12.     public BlockMachineBase() {
  13.         super();
  14.         this.setBlockName("machineBase");
  15.         this.setBlockTextureName("machineBase");
  16.     }
  17.  
  18.     protected TileEntityMachineCore searchCore(World world, int x, int y, int z) {
  19.         for (int x0 = -1; x0 <= 1; x0++) {
  20.             for (int y0 = -1; y0 <= 1; y0++) {
  21.                 for (int z0 = -1; z0 <= 1; z0++) {
  22.                     if (world.getBlock(x + x0, y + y0, z + z0) instanceof BlockMachineCore) {
  23.                         return (TileEntityMachineCore)world.getTileEntity(x + x0, y + y0, z + z0);
  24.                     }
  25.                 }
  26.             }
  27.         }
  28.         return null;
  29.     }
  30.  
  31.     @Override
  32.     public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
  33.         TileEntityMachineCore te = searchCore(world, x, y, z);
  34.         if (te != null) {
  35.             if (!te.checkBefore) {
  36.                 te.multiblockCheck();
  37.                 te.checkBefore = true;
  38.             }
  39.             if (te.isFormed()) {
  40.                 if (!world.isRemote) {
  41.                     FMLNetworkHandler.openGui(player, ModularMachines.instance, 1, world, te.xCoord, te.yCoord, te.zCoord);
  42.                 }
  43.                 return true;
  44.             }
  45.         }
  46.         return false;
  47.     }
  48.  
  49. //Each components returns the appropriate enum.
  50.     public MachineComponents getMachineType() {
  51.         return MachineComponents.NO_USE;
  52.     }
  53.  
  54.     @Override
  55.     public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
  56.         TileEntityMachineCore te = searchCore(world, x, y, z);
  57.         if (te != null) {
  58.             te.disableForm();
  59.         }
  60.         super.breakBlock(world, x, y, z, block, meta);
  61.     }
  62.  
  63.     /*@Override
  64.     public int onBlockPlaced(World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int meta) {
  65.         TileEntityMachineCore te = searchCore(world, x, y, z);
  66.         if (te != null) {
  67.             te.multiblockCheck();
  68.         }
  69.         return super.onBlockPlaced(world, x, y, z, side, hitX, hitY, hitZ, meta);
  70.     }*/
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement