From 6f72d2da0f09a05ca0d51d3be56acb87d47259ff Mon Sep 17 00:00:00 2001 From: Benjamin Konrad Dawkins Date: Sun, 8 Dec 2024 23:50:06 +0100 Subject: [PATCH] Fix Bugged Helix Tree Leaf drops --- .../loot_table/blocks/helix_tree_leaves.json | 119 +++++++++++++++++- .../blocks/HelixTreeLeavesBlock.java | 12 ++ 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/src/main/generated/data/betterend/loot_table/blocks/helix_tree_leaves.json b/src/main/generated/data/betterend/loot_table/blocks/helix_tree_leaves.json index 5bb760abf..8023d818a 100644 --- a/src/main/generated/data/betterend/loot_table/blocks/helix_tree_leaves.json +++ b/src/main/generated/data/betterend/loot_table/blocks/helix_tree_leaves.json @@ -1,17 +1,132 @@ { "type": "minecraft:block", "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": "minecraft:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ] + } + ], + "name": "betterend:helix_tree_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "name": "betterend:helix_tree_sapling" + } + ] + } + ], + "rolls": 1.0 + }, { "bonus_rolls": 0.0, "conditions": [ { - "condition": "minecraft:survives_explosion" + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:any_of", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "items": "minecraft:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "predicates": { + "minecraft:enchantments": [ + { + "enchantments": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + } + ] + } } ], "entries": [ { "type": "minecraft:item", - "name": "betterend:helix_tree_leaves" + "conditions": [ + { + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ], + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune" + } + ], + "functions": [ + { + "add": false, + "count": { + "type": "minecraft:uniform", + "max": 2.0, + "min": 1.0 + }, + "function": "minecraft:set_count" + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" } ], "rolls": 1.0 diff --git a/src/main/java/org/betterx/betterend/blocks/HelixTreeLeavesBlock.java b/src/main/java/org/betterx/betterend/blocks/HelixTreeLeavesBlock.java index a32898a50..3fdd4ca03 100644 --- a/src/main/java/org/betterx/betterend/blocks/HelixTreeLeavesBlock.java +++ b/src/main/java/org/betterx/betterend/blocks/HelixTreeLeavesBlock.java @@ -1,5 +1,7 @@ package org.betterx.betterend.blocks; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.storage.loot.LootTable; import org.betterx.bclib.behaviours.BehaviourBuilders; import org.betterx.bclib.behaviours.interfaces.BehaviourLeaves; import org.betterx.bclib.blocks.BaseBlock; @@ -9,6 +11,7 @@ import org.betterx.betterend.noise.OpenSimplexNoise; import org.betterx.ui.ColorUtil; import org.betterx.wover.block.api.BlockTagProvider; +import org.betterx.wover.loot.api.LootLookupProvider; import org.betterx.wover.tag.api.event.context.TagBootstrapContext; import net.minecraft.client.color.block.BlockColor; @@ -23,6 +26,9 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.IntegerProperty; import net.minecraft.world.level.material.MapColor; +import org.jetbrains.annotations.NotNull; + +import static org.betterx.betterend.registry.EndBlocks.HELIX_TREE_SAPLING; public class HelixTreeLeavesBlock extends BaseBlock implements BehaviourLeaves, CustomColorProvider, AddMineableShears, BlockTagProvider { public static final IntegerProperty COLOR = EndBlockProperties.COLOR; @@ -67,4 +73,10 @@ private int getGreen(int color) { public void registerBlockTags(ResourceLocation location, TagBootstrapContext context) { context.add(this, BlockTags.LEAVES); } + + @Override + public LootTable.Builder registerBlockLoot(@NotNull ResourceLocation location, @NotNull LootLookupProvider provider, @NotNull ResourceKey tableKey) + { + return provider.dropLeaves(this, HELIX_TREE_SAPLING); + } }