Advertisement
Lisenochek

Untitled

Sep 28th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public static void commonCrate(Location loc, Block block, Player p) {
  2.  
  3. int x = r.nextInt(2);
  4. int z = r.nextInt(2);
  5.  
  6. Location locBlock = loc.add(x, 0, z);
  7.  
  8. int y = p.getWorld().getHighestBlockYAt(locBlock.getBlockX(), locBlock.getBlockZ());
  9. locBlock.setY(y);
  10.  
  11. block.setType(Material.CHEST);
  12. Chest chest = (Chest) block.getState();
  13.  
  14. try {
  15.  
  16. Field inventoryField = chest.getClass().getDeclaredField("chest");
  17. inventoryField.setAccessible(true);
  18. TileEntityChest teChest = ((TileEntityChest) inventoryField.get(chest));
  19. teChest.a(ChatColor.DARK_GREEN + ChatColor.BOLD.toString() + "Realistic_crate");
  20. } catch (Exception e) {
  21. e.printStackTrace();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement