@Override public void onBlockAdded(World world, int x, int y, int z) { TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { TileEntityReactorRedstonePort rp = (TileEntityReactorRedstonePort) te; rp.onBlockAdded(world, x, y, z); } }
@Override public void onInputChanged( World world, int x, int y, int z, ForgeDirection side, int inputValue) { TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort) te; port.onRedNetUpdate(inputValue); } }
// IConnectableRedNet - for pretty cable connections @Override public RedNetConnectionType getConnectionType( World world, int x, int y, int z, ForgeDirection side) { TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort) te; if (port.isConnected()) { return RedNetConnectionType.CableSingle; } } return RedNetConnectionType.None; }
@Override public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { if (side == 0 || side == 1) { return REDSTONE_VALUE_OFF; } TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort) te; if (port.isOutput()) return port.isRedstoneActive() ? REDSTONE_VALUE_ON : REDSTONE_VALUE_OFF; else return REDSTONE_VALUE_OFF; } return REDSTONE_VALUE_OFF; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (player.isSneaking()) { return false; } TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { if (!((TileEntityReactorRedstonePort) te).isConnected()) { return false; } if (!world.isRemote) ((TileEntityReactorRedstonePort) te).sendRedstoneUpdate(); if (!world.isRemote) { player.openGui(BRLoader.instance, 0, world, x, y, z); } return true; } return false; }
@Override public void onNeighborBlockChange(World world, int x, int y, int z, int neighborBlockID) { super.onNeighborBlockChange(world, x, y, z, neighborBlockID); TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { ((TileEntityReactorRedstonePort) te).onNeighborBlockChange(x, y, z, neighborBlockID); } }
/** A randomly called display update to be able to add particles or other items for display */ @SideOnly(Side.CLIENT) public void randomDisplayTick(World world, int x, int y, int z, Random par5Random) { TileEntity te = world.getBlockTileEntity(x, y, z); if (te instanceof TileEntityReactorRedstonePort) { TileEntityReactorRedstonePort port = (TileEntityReactorRedstonePort) te; if (port.isRedstoneActive()) { ForgeDirection out = port.getOutwardsDirection(); double particleX, particleY, particleZ; particleY = y + 0.45D + par5Random.nextFloat() * 0.1D; if (out.offsetX > 0) particleX = x + par5Random.nextFloat() * 0.1D + 1.1D; else particleX = x + 0.45D + par5Random.nextFloat() * 0.1D; if (out.offsetZ > 0) particleZ = z + par5Random.nextFloat() * 0.1D + 1.1D; else particleZ = z + 0.45D + par5Random.nextFloat() * 0.1D; world.spawnParticle( "reddust", particleX, particleY, particleZ, 0.0D, par5Random.nextFloat() * 0.1D, 0.0D); } } }