Last active
April 7, 2016 00:18
-
-
Save fynntimes/5d84d0aa962d2f6097a133da2e0e478e to your computer and use it in GitHub Desktop.
Chests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CraftChest chest = (CraftChest) block.getState(); //block has to be a chest | |
try | |
{ | |
Field inventoryField = chest.getClass().getDeclaredField("chest"); //This gets the CraftChest variable 'chest' which is the TileEntityChest that is stored within it | |
inventoryField.setAccessible(true); //Allows you to access that field since it's declared as private | |
TileEntityChest teChest = ((TileEntityChest) inventoryField.get(chest)); //obtains the field and casts it to a TileEntityChest | |
teChest.a("Name Goes Here"); //The a(String) method sets the title of the chest | |
} | |
catch (Exception e) //This has to be here as the getDeclaredField(String) throws an exception if the input doesn't exist in the given class | |
{ | |
e.printStackTrace(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment