corrected loot table for grass crop drops
Some checks failed
build / build (21) (push) Has been cancelled

This commit is contained in:
Jörg Henke 2024-11-27 22:32:15 +01:00
parent 4fc53e92d1
commit c5c4c4d8a6
2 changed files with 9 additions and 48 deletions

View File

@ -16,12 +16,11 @@ import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.loot.LootPool;
import net.minecraft.loot.condition.SurvivesExplosionLootCondition;
import net.minecraft.loot.entry.ItemEntry;
import net.minecraft.loot.entry.LeafEntry.Builder;
/**
*
@ -40,15 +39,17 @@ public class Quickiemod implements ModInitializer {
}
private void registerLootTableChanges() {
// does not work yet right
LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> {
if (source.isBuiltin()) {
if (Blocks.SHORT_GRASS.getLootTableKey().get().getRegistry().equals(key.getRegistry())) {
tableBuilder.pool(LootPool.builder().with(ItemEntry.builder(ModItems.ITEM_COTTONSEED))
if ("minecraft:blocks/short_grass".equals(key.getValue().toString())) {
tableBuilder.pool(LootPool.builder()
.with(ItemEntry.builder(ModItems.ITEM_COTTONSEED).weight(1))
.with(ItemEntry.builder(Items.AIR).weight(4))
.conditionally(SurvivesExplosionLootCondition.builder()));
}
if (Blocks.TALL_GRASS.getLootTableKey().get().getRegistry().equals(key.getRegistry())) {
tableBuilder.pool(LootPool.builder().with(ItemEntry.builder(ModItems.ITEM_CANOLASEED))
} else if ("minecraft:blocks/tall_grass".equals(key.getValue().toString())) {
tableBuilder.pool(LootPool.builder()
.with(ItemEntry.builder(ModItems.ITEM_CANOLASEED).weight(1))
.with(ItemEntry.builder(Items.AIR).weight(7))
.conditionally(SurvivesExplosionLootCondition.builder()));
}
}

View File

@ -1,40 +0,0 @@
{
"type": "minecraft:chest",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"add": false,
"count": {
"type": "minecraft:uniform",
"max": 9.0,
"min": 1.0
},
"function": "minecraft:set_count"
}
],
"name": "quickiemod:canolaseed"
},
{
"type": "minecraft:item",
"functions": [
{
"add": false,
"count": {
"type": "minecraft:uniform",
"max": 9.0,
"min": 1.0
},
"function": "minecraft:set_count"
}
],
"name": "quickiemod:cottonseed"
}
]
}
]
}