Advertisement
MsGamerHD

Untitled

Jun 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. void switchLamp(Block b, boolean lighting) throws Exception {
  2.         World w = (World) ((CraftWorld) b.getWorld()).getHandle();
  3.         if (lighting) {
  4.             setWorldStatic(w, true);
  5.             b.setType(Material.REDSTONE_LAMP_ON);
  6.             setWorldStatic(w, false);
  7.         } else {
  8.             b.setType(Material.REDSTONE_LAMP_OFF);
  9.         }
  10.     }
  11.      
  12.     private static void setWorldStatic(World world, boolean static_boolean) throws Exception {
  13.         Field static_field = World.class.getDeclaredField("isClientSide");
  14.  
  15.         static_field.setAccessible(true);
  16.         static_field.set(world, Boolean.valueOf(static_boolean));
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement