@Override public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { TileEntity te = world.getTileEntity(pos); if (te instanceof CustomTileEntity) { CustomTileEntity cte = (CustomTileEntity) te; Vec3d vec = revRotate(new Vec3d(hitX - .5, hitY - .5, hitZ - .5), side).addVector(.5, .5, .5); IUnlistedProperty<Integer> property = properties[side.ordinal()]; Integer value = cte.getState().getValue(property); if (value == null) value = 0; value ^= (1 << (cubeSize * ((int) (vec.xCoord * (cubeSize - .0001))) + ((int) (vec.zCoord * (cubeSize - .0001))))); cte.setState(cte.getState().withProperty(property, value)); world.markBlockRangeForRenderUpdate(pos, pos); } return true; }
@Override public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) { TileEntity te = world.getTileEntity(pos); if (te instanceof CustomTileEntity) { CustomTileEntity cte = (CustomTileEntity) te; return cte.getState(); } return state; }