Chest Generation Hooks
This hook allows us to add items and blocks to chests that are not generated in dungeons. This includes but is not limited to Desert Pyramid chests, Jungle Temple Chests and the Bonus Chest.
To use this even simply add the single line of hook code into the initialization event. This event is located within the @Mod/Core mod file.
ChestGenHooks.getInfo(ChestGenHooks.CATEGORY).addItem(new WeightedRandomChestContent(new ItemStack(YourItem),Min,Max,Rarity));
This hook requires 5 things to function. The first is a Category. The category decides what type of chest the item will spawn in. For a list of the Categories click here.
The second thing we need is the ItemStack. The ItemStack is used to determine exactly what item is going to spawn in the chest. It will look like YourMod.YourItem or YourModItems.YourItem.
The third thing we will need is the minimum. This sets the lowest amount of that item that will be found in a stack. If the value is 2 then all of this item will spawn in stacks of two or higher.
The fourth thing we will need is the maximum. This sets the highest amount of that item that will be found in a stack. If the value is 5 then all of the items will spawn in stacks of 5 or less (not below the minimum) The maximum value must be higher or the same as the lowest value or the game will crash when the chest is opened.
The final value is for the rarity. The higher the value the more common that item will show up. saddles are 100, iron ingots are 100, bread is 100, wheat is 100, redstone is 50, records are 5 and the gold apple is 1.
This is an example of how the hook looks from my mod.
ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(RWItems.rupeeGreen),1,3,065));
To use this even simply add the single line of hook code into the initialization event. This event is located within the @Mod/Core mod file.
ChestGenHooks.getInfo(ChestGenHooks.CATEGORY).addItem(new WeightedRandomChestContent(new ItemStack(YourItem),Min,Max,Rarity));
This hook requires 5 things to function. The first is a Category. The category decides what type of chest the item will spawn in. For a list of the Categories click here.
The second thing we need is the ItemStack. The ItemStack is used to determine exactly what item is going to spawn in the chest. It will look like YourMod.YourItem or YourModItems.YourItem.
The third thing we will need is the minimum. This sets the lowest amount of that item that will be found in a stack. If the value is 2 then all of this item will spawn in stacks of two or higher.
The fourth thing we will need is the maximum. This sets the highest amount of that item that will be found in a stack. If the value is 5 then all of the items will spawn in stacks of 5 or less (not below the minimum) The maximum value must be higher or the same as the lowest value or the game will crash when the chest is opened.
The final value is for the rarity. The higher the value the more common that item will show up. saddles are 100, iron ingots are 100, bread is 100, wheat is 100, redstone is 50, records are 5 and the gold apple is 1.
This is an example of how the hook looks from my mod.
ChestGenHooks.getInfo(ChestGenHooks.PYRAMID_JUNGLE_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(RWItems.rupeeGreen),1,3,065));