Jump to content

Generate items in chests


Hamster_Furtif

Recommended Posts

Hey !

 

I need to generate items in chests, but it's not working. Here is what I've done:

 

 public void chestLoots()
    {
    	ChestGenHooks mineshaft = ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR);
	ChestGenHooks nether = ChestGenHooks.getInfo(ChestGenHooks.NETHER_FORTRESS);
	ChestGenHooks sh_couloir = ChestGenHooks.getInfo(ChestGenHooks.STRONGHOLD_CORRIDOR);
	ItemStack ame_loot = new ItemStack(ame);

	//	addItem(Item, min, max, chances)
	//	NB:Les chances de spawn du pain sont de 100

	mineshaft.addItem(new WeightedRandomChestContent(ame_loot, 1, 1, 1));
	nether.addItem(new WeightedRandomChestContent(ame_loot , 1, 10, 9001));
	sh_couloir.addItem(new WeightedRandomChestContent(ame_loot, 1, 1, 20));
    }

 

and :

 

@EventHandler
    public void init(FMLInitializationEvent event)
    {
	chestLoots();
    }

 

But it's not generating. You can see the chances are over 9000 in the nether, so this is not the problem.

 

Thank you for your help !

 

Link to comment
Share on other sites

Simply

ChestGenHooks.getInfo(ChestGenHooks.BONUS_CHEST).addItem(new WeightedRandomChestContent(new ItemStack(ItemsHandler.InfiniteFruit), 1,1,20));

 

Works for me.

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

Ho, yeah, should have precised. I'm using forge 1.8.

 

I'm using the version 1.8-11.14.1.1402, but I just saw the version Build 1.8-11.14.1.1404 added

 

Initialized the Nether Fortress chest loot

 

Forced the nether fortress chest loot to initialize in ChestGenHooks

like the other types.

 

Changed tabs to spaces. Silly Eclipse.

 

Maybe I should use the latest version. Is there any way to do it easily ?

Link to comment
Share on other sites

download it, extract it, gradle it and throw your old code inside the src

Don't do it that way! It is much easier! Open your
build.gradle

file and change the version number. Then rerun

gradlew setupDecompWorkspace eclipse

. This is the intended way to update Forge.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.