Jump to content

Recommended Posts

Posted

My problem is pretty simple. Seeing as the item methods in DungeonHooks are deprecated, that means that they will be eventually removed, so I want to port to ChestGenHooks, but I'm having trouble.

 

This is my current method:

    public static void addDungeonItems() {
        ChestGenHooks chestGenHooksDungeon = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);
        
        // Mega Adamant Blocks in dungeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.megaAdamant), 55, 1, 3));

        // Tomatoes and Peppers in dugeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.tomato), 95, 3, 4));
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.pepper), 95, 3, 4));

        // Adamant in dungeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.adamant), 30, 3, 5));
    }

Using this, the game crashes when it generates a dungeon. Crash report

 

I also found that I can use this (bold part is what's changed from previous method):

    public static void addDungeonItems() {
        ChestGenHooks chestGenHooksDungeon = new ChestGenHooks(ChestGenHooks.DUNGEON_CHEST); // Changed line, note from OP
        
        // Mega Adamant Blocks in dungeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.megaAdamant), 55, 1, 3));

        // Tomatoes and Peppers in dugeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.tomato), 95, 3, 4));
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.pepper), 95, 3, 4));

        // Adamant in dungeons
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(TelicraftMain.adamant), 30, 3, 5));
    }

Using this, the game doesn't crash but no items get generated. Can somebody explain to me how to use ChestGenHooks? Thanks in advance!

 

-Telinc1

Posted

If you'd actually look into what you're doing you'll understand why the 2nd is wrong. OFC it wont use your NEW instance -.- You have to add it to the one you're looking for.

 

Also If you look at the construtor for WeightedRandomChestContent:

new WeightedRandomChestContent(new ItemStack(TelicraftMain.megaAdamant), 55, 1, 3)
    public WeightedRandomChestContent(ItemStack par1ItemStack, int par2, int par3, int par4)
    {
        super(par4);
        this.theItemId = par1ItemStack;
        this.theMinimumChanceToGenerateItem = par2;
        this.theMaximumChanceToGenerateItem = par3;
    }

Essentially you're saying you want the minimum amount to be 55, the max amount to be 1 .....

Thats kinda retarded....

Check your arguments.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • 1 month later...
Posted

Hello,

 

I'd like to add dragon eggs to dungeon and mineshaft chests. However, I'm not sure if I get the Wight Number right. In dungeons it should have the same probability as saddles, and in mineshafts the same probability as gold ingots. The stack should always consist of 1 dragon egg.

 

import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;

public class ChestLoot {

public static void addChestItems() {
	ChestGenHooks chestGenHooksDungeon = ChestGenHooks.getInfo(ChestGenHooks.DUNGEON_CHEST);       
        chestGenHooksDungeon.addItem(new WeightedRandomChestContent(new ItemStack(Block.dragonEgg), 1, 1, 100));

        ChestGenHooks chestGenHooksMineshaft = ChestGenHooks.getInfo(ChestGenHooks.MINESHAFT_CORRIDOR);       
        chestGenHooksMineshaft.addItem(new WeightedRandomChestContent(new ItemStack(Block.dragonEgg), 1, 1, 5));        
    }

}

 

Is this alright?

 

Regards,

Thaliviel

  • 1 month later...
Posted

I don't know if that will work, but I use this method in the @Init method in my base class, and it works perfectly:

ChestGenHooks.getInfo(ChestGenHooks.chestType).addItem(new WeightedRandomChestContent(new ItemStack(yourItem), rarity, min, max));

The italics are arguments, explained here:

chestType: what type of chest will it spawn in? The full list of chest types is in the ChestGenHooks class, in net.minecraftforge.common. You can use dungeon chests, bonus chests, temple chests, etc.

yourItem: Your item.

rarity: rarity of the item, 1 is rarest, and bread is 100, so very common. but you can go over 100(or over 9,000, for that matter)

min: minimum amount of the item spawned in that specific stack.

max: maximum amount of the item spawned in that specific stack.

 

Hope that this was helpful to both you, and others with the same problem, because I had that problem...

Posted

I don't know if that will work, but I use this method in the @Init method in my base class, and it works perfectly:

ChestGenHooks.getInfo(ChestGenHooks.chestType).addItem(new WeightedRandomChestContent(new ItemStack(yourItem), rarity, min, max));

The italics are arguments, explained here:

chestType: what type of chest will it spawn in? The full list of chest types is in the ChestGenHooks class, in net.minecraftforge.common. You can use dungeon chests, bonus chests, temple chests, etc.

yourItem: Your item.

rarity: rarity of the item, 1 is rarest, and bread is 100, so very common. but you can go over 100(or over 9,000, for that matter)

min: minimum amount of the item spawned in that specific stack.

max: maximum amount of the item spawned in that specific stack.

 

Hope that this was helpful to both you, and others with the same problem, because I had that problem...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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