still no grass is found; source.isBuiltin seems not to be true

This commit is contained in:
Jottyfan
2025-12-24 14:01:08 +01:00
parent 5f1ec39715
commit 20d2adffc7

View File

@@ -9,13 +9,12 @@ import de.jottyfan.minecraft.item.QuicklyItems;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.loot.v3.LootTableEvents; import net.fabricmc.fabric.api.loot.v3.LootTableEvents;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.minecraft.world.item.Items; import net.minecraft.resources.Identifier;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.storage.loot.LootPool; import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.entries.LootItem; import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue; import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
/** /**
* *
* @author jotty * @author jotty
@@ -34,11 +33,13 @@ public class Quickly implements ModInitializer {
private void registerLootTableChanges() { private void registerLootTableChanges() {
LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> { LootTableEvents.MODIFY.register((key, tableBuilder, source, registries) -> {
if (source.isBuiltin()) { if (source.isBuiltin()) {
if (Blocks.SHORT_GRASS.getLootTable().equals(key)) { Identifier grass = Identifier.fromNamespaceAndPath("minecraft", "blocks/grass");
Quickly.LOGGER.info("key {} ?=? grass {}", key.identifier(), grass);
if (key.identifier().equals(grass)) {
LootPool.Builder poolBuilder = LootPool.lootPool() LootPool.Builder poolBuilder = LootPool.lootPool()
.setRolls(ConstantValue.exactly(1f)) .setRolls(ConstantValue.exactly(1f))
.add(LootItem.lootTableItem(Items.AIR).setWeight(4)) .when(LootItemRandomChanceCondition.randomChance(0.1f))
.add(LootItem.lootTableItem(QuicklyItems.COTTONSEED).setWeight(1)); .add(LootItem.lootTableItem(QuicklyItems.COTTONSEED));
tableBuilder.withPool(poolBuilder); tableBuilder.withPool(poolBuilder);
} else if (Blocks.TALL_GRASS.getLootTable().equals(key)) { } else if (Blocks.TALL_GRASS.getLootTable().equals(key)) {
// for the canola loot table block later // for the canola loot table block later