Jump to content

Recommended Posts

Posted

I followed a tutorial on how to modify the grass loot table and add my modded item but my loot is not generated

here is my loot class:

package net.meme2001.farmsimmod.loot;

import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraftforge.common.data.GlobalLootModifierProvider;
import net.minecraftforge.common.loot.IGlobalLootModifier;
import net.minecraftforge.common.loot.LootModifier;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.registries.ForgeRegistries;
import org.jetbrains.annotations.NotNull;

import static net.meme2001.farmsimmod.Farmsimmod.MODID;

public class DeleteItemModifier extends LootModifier {
public static final Supplier<Codec<DeleteItemModifier>> CODEC = Suppliers.memoize(()
-> RecordCodecBuilder.create(inst -> codecStart(inst).and(ForgeRegistries.ITEMS.getCodec()
.fieldOf("item").forGetter(m -> m.item)).apply(inst,DeleteItemModifier::new)));
private final Item item;






protected DeleteItemModifier(LootItemCondition[] conditionsIn ,Item item) {
super(conditionsIn);

this.item=item;


}

@Override
protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
if (context.getRandom().nextFloat() >= 0.2) {
generatedLoot.add(new ItemStack(item));
}




return generatedLoot;
}


@Override
public Codec<? extends IGlobalLootModifier> codec() {
return CODEC.get();
}


}

 

and here is my first JSON file:

{
"type": "farmsimmod:delete_item",
"conditions": [
{
"condition": "block_state_property",
"block": "minecraft:grass"
}
],
"item": "framsimmod:tomateo_seed"

}

and my second JSON file

{
"replace": false,
"entries": [
"farmsimmod:remove_loot_from_grass"
]
}

Posted

Don't post snippits in the forum. and what you posted is horribly formatted.

It also gives no clue to where those json files are located, what they are called or show all the necessary code (like the registration process).

Put your code  on github where we can see everything in context.

 

Here's one I  made a while ago, explaining all the steps: https://forums.minecraftforge.net/topic/113816-1182-method-for-iterating-over-blocks-belonging-to-a-tag/#comment-505993

although the part about the "block tag loot item condition" is optional unless you want to use block tags.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted (edited)

Look in your logs/debug.log

Quote

[11:49:25] [Render thread/WARN] [ne.mi.co.lo.LootModifierManager/]: Could not decode GlobalLootModifier with json id farmsimmod:remove_loot_from_grass - error: Unknown registry key in ResourceKey[minecraft:root / minecraft:item]: framsimmod:tomateo_seed

You misspelt farm. 🙂

https://github.com/meme2023/my_mod/blob/838b11405464e28ac3d4f46b9f06adf159b95e40/src/main/resources/data/farmsimmod/loot_modifiers/remove_loot_from_grass.json#L9

Edited by warjort
  • Thanks 1

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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



×
×
  • Create New...

Important Information

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