Advertisement
Naitenne

onActivated

Jan 26th, 2017
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1. @Override
  2.     public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ){
  3.         if(!world.isRemote){
  4.             TilePointer tile = (TilePointer) world.getTileEntity(pos);
  5.             if(tile != null){
  6.                 int[] d = RotationHelper.rotateXZByDir(-2, 1, tile.direction.getIndex());
  7.                 BlockPos p = pos.add(d[0], 0, d[1]);
  8.                 if(world.getBlockState(p).getBlock() instanceof BlockTrackSWNE){
  9.                     TileTrackSWNE track = (TileTrackSWNE) world.getTileEntity(p);
  10.                     if(track != null){
  11.                         track.activated = !track.activated;
  12.                         world.notifyBlockUpdate(pos, state, world.getBlockState(p), 3);
  13.                         return true;
  14.                     }
  15.                 }
  16.             }
  17.         }
  18.         return true;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement