From 469527890f9d62d79c5fa7066b423e55763239f1 Mon Sep 17 00:00:00 2001 From: Yanny Date: Thu, 25 Jun 2020 18:31:09 +0200 Subject: [PATCH] Replace explicit shears reference in vanilla loot tables with tag for modded shears. (#6765) --- .../data/forge/tags/items/shears.json | 6 + .../loot_tables/blocks/acacia_leaves.json | 128 ++++++++++++ .../loot_tables/blocks/birch_leaves.json | 128 ++++++++++++ .../minecraft/loot_tables/blocks/cobweb.json | 54 ++++++ .../loot_tables/blocks/dark_oak_leaves.json | 182 +++++++++++++++++ .../loot_tables/blocks/dead_bush.json | 44 +++++ .../minecraft/loot_tables/blocks/fern.json | 50 +++++ .../minecraft/loot_tables/blocks/grass.json | 50 +++++ .../loot_tables/blocks/jungle_leaves.json | 129 ++++++++++++ .../loot_tables/blocks/large_fern.json | 47 +++++ .../loot_tables/blocks/oak_leaves.json | 182 +++++++++++++++++ .../loot_tables/blocks/seagrass.json | 22 +++ .../loot_tables/blocks/spruce_leaves.json | 128 ++++++++++++ .../loot_tables/blocks/tall_grass.json | 47 +++++ .../loot_tables/blocks/tall_seagrass.json | 22 +++ .../minecraft/loot_tables/blocks/vine.json | 22 +++ .../net/minecraftforge/common/ForgeMod.java | 2 + .../java/net/minecraftforge/common/Tags.java | 41 ++-- .../common/data/ForgeItemTagsProvider.java | 183 +++++++++--------- .../common/data/ForgeLootTableProvider.java | 174 +++++++++++++++++ 20 files changed, 1530 insertions(+), 111 deletions(-) create mode 100644 src/generated/resources/data/forge/tags/items/shears.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/fern.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/grass.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json create mode 100644 src/generated/resources/data/minecraft/loot_tables/blocks/vine.json create mode 100644 src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java diff --git a/src/generated/resources/data/forge/tags/items/shears.json b/src/generated/resources/data/forge/tags/items/shears.json new file mode 100644 index 000000000..7aeb6cb47 --- /dev/null +++ b/src/generated/resources/data/forge/tags/items/shears.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "minecraft:shears" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json new file mode 100644 index 000000000..88edef372 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/acacia_leaves.json @@ -0,0 +1,128 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:acacia_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:acacia_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json new file mode 100644 index 000000000..0a36f451b --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/birch_leaves.json @@ -0,0 +1,128 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:birch_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:birch_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json b/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json new file mode 100644 index 000000000..f805a361e --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/cobweb.json @@ -0,0 +1,54 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:cobweb" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ], + "name": "minecraft:string" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json new file mode 100644 index 000000000..9c6889187 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/dark_oak_leaves.json @@ -0,0 +1,182 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:dark_oak_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:dark_oak_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.005, + 0.0055555557, + 0.00625, + 0.008333334, + 0.025 + ] + } + ], + "name": "minecraft:apple" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json b/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json new file mode 100644 index 000000000..050ffda4b --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/dead_bush.json @@ -0,0 +1,44 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "name": "minecraft:dead_bush" + }, + { + "type": "minecraft:item", + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 0.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json b/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json new file mode 100644 index 000000000..941e6af61 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/fern.json @@ -0,0 +1,50 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "name": "minecraft:fern" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:random_chance", + "chance": 0.125 + } + ], + "functions": [ + { + "function": "minecraft:apply_bonus", + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "parameters": { + "bonusMultiplier": 2 + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:wheat_seeds" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json new file mode 100644 index 000000000..dd232ebab --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/grass.json @@ -0,0 +1,50 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "name": "minecraft:grass" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:random_chance", + "chance": 0.125 + } + ], + "functions": [ + { + "function": "minecraft:apply_bonus", + "enchantment": "minecraft:fortune", + "formula": "minecraft:uniform_bonus_count", + "parameters": { + "bonusMultiplier": 2 + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:wheat_seeds" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json new file mode 100644 index 000000000..181c7d7aa --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/jungle_leaves.json @@ -0,0 +1,129 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:jungle_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.025, + 0.027777778, + 0.03125, + 0.041666668, + 0.1 + ] + } + ], + "name": "minecraft:jungle_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json b/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json new file mode 100644 index 000000000..2eac85591 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/large_fern.json @@ -0,0 +1,47 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "name": "minecraft:fern" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:block_state_property", + "block": "minecraft:large_fern", + "properties": { + "half": "lower" + } + }, + { + "condition": "minecraft:random_chance", + "chance": 0.125 + } + ], + "name": "minecraft:wheat_seeds" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json new file mode 100644 index 000000000..29827e48b --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/oak_leaves.json @@ -0,0 +1,182 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:oak_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:oak_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.005, + 0.0055555557, + 0.00625, + 0.008333334, + 0.025 + ] + } + ], + "name": "minecraft:apple" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json new file mode 100644 index 000000000..ebc23c36e --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/seagrass.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:seagrass" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json b/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json new file mode 100644 index 000000000..e9c5c6e54 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/spruce_leaves.json @@ -0,0 +1,128 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + ], + "name": "minecraft:spruce_leaves" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, + 0.0625, + 0.083333336, + 0.1 + ] + } + ], + "name": "minecraft:spruce_sapling" + } + ] + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.02, + 0.022222223, + 0.025, + 0.033333335, + 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "minecraft:stick" + } + ], + "conditions": [ + { + "condition": "minecraft:inverted", + "term": { + "condition": "minecraft:alternative", + "terms": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + }, + { + "condition": "minecraft:match_tool", + "predicate": { + "enchantments": [ + { + "enchantment": "minecraft:silk_touch", + "levels": { + "min": 1 + } + } + ] + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json new file mode 100644 index 000000000..797b68267 --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_grass.json @@ -0,0 +1,47 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:alternatives", + "children": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ], + "name": "minecraft:grass" + }, + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:survives_explosion" + }, + { + "condition": "minecraft:block_state_property", + "block": "minecraft:tall_grass", + "properties": { + "half": "lower" + } + }, + { + "condition": "minecraft:random_chance", + "chance": 0.125 + } + ], + "name": "minecraft:wheat_seeds" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json new file mode 100644 index 000000000..ebc23c36e --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/tall_seagrass.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:seagrass" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json b/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json new file mode 100644 index 000000000..fc7fa0d6f --- /dev/null +++ b/src/generated/resources/data/minecraft/loot_tables/blocks/vine.json @@ -0,0 +1,22 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:vine" + } + ], + "conditions": [ + { + "condition": "minecraft:match_tool", + "predicate": { + "tag": "forge:shears" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/net/minecraftforge/common/ForgeMod.java b/src/main/java/net/minecraftforge/common/ForgeMod.java index 19447b9ae..0c1f938b4 100644 --- a/src/main/java/net/minecraftforge/common/ForgeMod.java +++ b/src/main/java/net/minecraftforge/common/ForgeMod.java @@ -61,6 +61,7 @@ import net.minecraftforge.common.crafting.conditions.TagEmptyCondition; import net.minecraftforge.common.crafting.conditions.TrueCondition; import net.minecraftforge.common.data.ForgeBlockTagsProvider; import net.minecraftforge.common.data.ForgeItemTagsProvider; +import net.minecraftforge.common.data.ForgeLootTableProvider; import net.minecraftforge.common.data.ForgeRecipeProvider; import net.minecraftforge.common.model.animation.CapabilityAnimation; import net.minecraftforge.energy.CapabilityEnergy; @@ -180,6 +181,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook gen.addProvider(new ForgeBlockTagsProvider(gen)); gen.addProvider(new ForgeItemTagsProvider(gen)); gen.addProvider(new ForgeRecipeProvider(gen)); + gen.addProvider(new ForgeLootTableProvider(gen)); } } diff --git a/src/main/java/net/minecraftforge/common/Tags.java b/src/main/java/net/minecraftforge/common/Tags.java index e0a094511..9f3b0820a 100644 --- a/src/main/java/net/minecraftforge/common/Tags.java +++ b/src/main/java/net/minecraftforge/common/Tags.java @@ -246,26 +246,27 @@ public class Tags public static final Tag SAND_COLORLESS = tag("sand/colorless"); public static final Tag SAND_RED = tag("sand/red"); - public static final Tag SANDSTONE = tag("sandstone"); - public static final Tag SEEDS = tag("seeds"); - public static final Tag SEEDS_BEETROOT = tag("seeds/beetroot"); - public static final Tag SEEDS_MELON = tag("seeds/melon"); - public static final Tag SEEDS_PUMPKIN = tag("seeds/pumpkin"); - public static final Tag SEEDS_WHEAT = tag("seeds/wheat"); - public static final Tag SLIMEBALLS = tag("slimeballs"); - public static final Tag STAINED_GLASS = tag("stained_glass"); - public static final Tag STAINED_GLASS_PANES = tag("stained_glass_panes"); - public static final Tag STONE = tag("stone"); - public static final Tag STORAGE_BLOCKS = tag("storage_blocks"); - public static final Tag STORAGE_BLOCKS_COAL = tag("storage_blocks/coal"); - public static final Tag STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond"); - public static final Tag STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald"); - public static final Tag STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold"); - public static final Tag STORAGE_BLOCKS_IRON = tag("storage_blocks/iron"); - public static final Tag STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis"); - public static final Tag STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz"); - public static final Tag STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone"); - public static final Tag STRING = tag("string"); + public static final ITag.INamedTag SANDSTONE = tag("sandstone"); + public static final ITag.INamedTag SEEDS = tag("seeds"); + public static final ITag.INamedTag SEEDS_BEETROOT = tag("seeds/beetroot"); + public static final ITag.INamedTag SEEDS_MELON = tag("seeds/melon"); + public static final ITag.INamedTag SEEDS_PUMPKIN = tag("seeds/pumpkin"); + public static final ITag.INamedTag SEEDS_WHEAT = tag("seeds/wheat"); + public static final ITag.INamedTag SHEARS = tag("shears"); + public static final ITag.INamedTag SLIMEBALLS = tag("slimeballs"); + public static final ITag.INamedTag STAINED_GLASS = tag("stained_glass"); + public static final ITag.INamedTag STAINED_GLASS_PANES = tag("stained_glass_panes"); + public static final ITag.INamedTag STONE = tag("stone"); + public static final ITag.INamedTag STORAGE_BLOCKS = tag("storage_blocks"); + public static final ITag.INamedTag STORAGE_BLOCKS_COAL = tag("storage_blocks/coal"); + public static final ITag.INamedTag STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond"); + public static final ITag.INamedTag STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald"); + public static final ITag.INamedTag STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold"); + public static final ITag.INamedTag STORAGE_BLOCKS_IRON = tag("storage_blocks/iron"); + public static final ITag.INamedTag STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis"); + public static final ITag.INamedTag STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz"); + public static final ITag.INamedTag STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone"); + public static final ITag.INamedTag STRING = tag("string"); private static Tag tag(String name) { diff --git a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java index f8ca6bc80..071360803 100644 --- a/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java +++ b/src/main/java/net/minecraftforge/common/data/ForgeItemTagsProvider.java @@ -51,97 +51,98 @@ public class ForgeItemTagsProvider extends ItemTagsProvider super.registerTags(); filter = this.tagToBuilder.entrySet().stream().map(e -> e.getKey().getId()).collect(Collectors.toSet()); - getBuilder(Tags.Items.ARROWS).add(Items.ARROW, Items.TIPPED_ARROW, Items.SPECTRAL_ARROW); - getBuilder(Tags.Items.BEACON_PAYMENT).add(Items.EMERALD, Items.DIAMOND, Items.GOLD_INGOT, Items.IRON_INGOT); - getBuilder(Tags.Items.BONES).add(Items.BONE); - getBuilder(Tags.Items.BOOKSHELVES).add(Items.BOOKSHELF); - copy(Tags.Blocks.CHESTS, Tags.Items.CHESTS); - copy(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER); - copy(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED); - copy(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN); - copy(Tags.Blocks.COBBLESTONE, Tags.Items.COBBLESTONE); - getBuilder(Tags.Items.CROPS).add(Tags.Items.CROPS_BEETROOT, Tags.Items.CROPS_CARROT, Tags.Items.CROPS_NETHER_WART, Tags.Items.CROPS_POTATO, Tags.Items.CROPS_WHEAT); - getBuilder(Tags.Items.CROPS_BEETROOT).add(Items.BEETROOT); - getBuilder(Tags.Items.CROPS_CARROT).add(Items.CARROT); - getBuilder(Tags.Items.CROPS_NETHER_WART).add(Items.NETHER_WART); - getBuilder(Tags.Items.CROPS_POTATO).add(Items.POTATO); - getBuilder(Tags.Items.CROPS_WHEAT).add(Items.WHEAT); - getBuilder(Tags.Items.DUSTS).add(Tags.Items.DUSTS_GLOWSTONE, Tags.Items.DUSTS_PRISMARINE, Tags.Items.DUSTS_REDSTONE); - getBuilder(Tags.Items.DUSTS_GLOWSTONE).add(Items.GLOWSTONE_DUST); - getBuilder(Tags.Items.DUSTS_PRISMARINE).add(Items.PRISMARINE_SHARD); - getBuilder(Tags.Items.DUSTS_REDSTONE).add(Items.REDSTONE); - addColored(getBuilder(Tags.Items.DYES)::add, Tags.Items.DYES, "{color}_dye"); - getBuilder(Tags.Items.EGGS).add(Items.EGG); - copy(Tags.Blocks.END_STONES, Tags.Items.END_STONES); - getBuilder(Tags.Items.ENDER_PEARLS).add(Items.ENDER_PEARL); - getBuilder(Tags.Items.FEATHERS).add(Items.FEATHER); - copy(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES); - copy(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN); - copy(Tags.Blocks.FENCES, Tags.Items.FENCES); - copy(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK); - copy(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN); - getBuilder(Tags.Items.GEMS).add(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_EMERALD, Tags.Items.GEMS_LAPIS, Tags.Items.GEMS_PRISMARINE, Tags.Items.GEMS_QUARTZ); - getBuilder(Tags.Items.GEMS_DIAMOND).add(Items.DIAMOND); - getBuilder(Tags.Items.GEMS_EMERALD).add(Items.EMERALD); - getBuilder(Tags.Items.GEMS_LAPIS).add(Items.LAPIS_LAZULI); - getBuilder(Tags.Items.GEMS_PRISMARINE).add(Items.PRISMARINE_CRYSTALS); - getBuilder(Tags.Items.GEMS_QUARTZ).add(Items.QUARTZ); - copy(Tags.Blocks.GLASS, Tags.Items.GLASS); - copyColored(Tags.Blocks.GLASS, Tags.Items.GLASS); - copy(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); - copyColored(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); - copy(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL); - getBuilder(Tags.Items.GUNPOWDER).add(Items.GUNPOWDER); - getBuilder(Tags.Items.HEADS).add(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD); - getBuilder(Tags.Items.INGOTS).add(Tags.Items.INGOTS_IRON, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_BRICK, Tags.Items.INGOTS_NETHER_BRICK); - getBuilder(Tags.Items.INGOTS_BRICK).add(Items.BRICK); - getBuilder(Tags.Items.INGOTS_GOLD).add(Items.GOLD_INGOT); - getBuilder(Tags.Items.INGOTS_IRON).add(Items.IRON_INGOT); - getBuilder(Tags.Items.INGOTS_NETHER_BRICK).add(Items.NETHER_BRICK); - getBuilder(Tags.Items.LEATHER).add(Items.LEATHER); - getBuilder(Tags.Items.MUSHROOMS).add(Items.BROWN_MUSHROOM, Items.RED_MUSHROOM); - getBuilder(Tags.Items.MUSIC_DISCS).add(Items.MUSIC_DISC_13, Items.MUSIC_DISC_CAT, Items.MUSIC_DISC_BLOCKS, Items.MUSIC_DISC_CHIRP, Items.MUSIC_DISC_FAR, Items.MUSIC_DISC_MALL, Items.MUSIC_DISC_MELLOHI, Items.MUSIC_DISC_STAL, Items.MUSIC_DISC_STRAD, Items.MUSIC_DISC_WARD, Items.MUSIC_DISC_11, Items.MUSIC_DISC_WAIT); - getBuilder(Tags.Items.NETHER_STARS).add(Items.NETHER_STAR); - copy(Tags.Blocks.NETHERRACK, Tags.Items.NETHERRACK); - getBuilder(Tags.Items.NUGGETS).add(Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD); - getBuilder(Tags.Items.NUGGETS_IRON).add(Items.IRON_NUGGET); - getBuilder(Tags.Items.NUGGETS_GOLD).add(Items.GOLD_NUGGET); - copy(Tags.Blocks.OBSIDIAN, Tags.Items.OBSIDIAN); - copy(Tags.Blocks.ORES, Tags.Items.ORES); - copy(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL); - copy(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND); - copy(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD); - copy(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD); - copy(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON); - copy(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS); - copy(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ); - copy(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE); - getBuilder(Tags.Items.RODS).add(Tags.Items.RODS_BLAZE, Tags.Items.RODS_WOODEN); - getBuilder(Tags.Items.RODS_BLAZE).add(Items.BLAZE_ROD); - getBuilder(Tags.Items.RODS_WOODEN).add(Items.STICK); - copy(Tags.Blocks.SAND, Tags.Items.SAND); - copy(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS); - copy(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED); - copy(Tags.Blocks.SANDSTONE, Tags.Items.SANDSTONE); - getBuilder(Tags.Items.SEEDS).add(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT); - getBuilder(Tags.Items.SEEDS_BEETROOT).add(Items.BEETROOT_SEEDS); - getBuilder(Tags.Items.SEEDS_MELON).add(Items.MELON_SEEDS); - getBuilder(Tags.Items.SEEDS_PUMPKIN).add(Items.PUMPKIN_SEEDS); - getBuilder(Tags.Items.SEEDS_WHEAT).add(Items.WHEAT_SEEDS); - getBuilder(Tags.Items.SLIMEBALLS).add(Items.SLIME_BALL); - copy(Tags.Blocks.STAINED_GLASS, Tags.Items.STAINED_GLASS); - copy(Tags.Blocks.STAINED_GLASS_PANES, Tags.Items.STAINED_GLASS_PANES); - copy(Tags.Blocks.STONE, Tags.Items.STONE); - copy(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS); - copy(Tags.Blocks.STORAGE_BLOCKS_COAL, Tags.Items.STORAGE_BLOCKS_COAL); - copy(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND); - copy(Tags.Blocks.STORAGE_BLOCKS_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD); - copy(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD); - copy(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON); - copy(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS); - copy(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ); - copy(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE); - getBuilder(Tags.Items.STRING).add(Items.STRING); + func_240522_a_(Tags.Items.ARROWS).func_240534_a_(Items.ARROW, Items.TIPPED_ARROW, Items.SPECTRAL_ARROW); + func_240522_a_(Tags.Items.BEACON_PAYMENT).func_240534_a_(Items.EMERALD, Items.DIAMOND, Items.GOLD_INGOT, Items.IRON_INGOT); + func_240522_a_(Tags.Items.BONES).func_240534_a_(Items.BONE); + func_240522_a_(Tags.Items.BOOKSHELVES).func_240534_a_(Items.BOOKSHELF); + func_240521_a_(Tags.Blocks.CHESTS, Tags.Items.CHESTS); + func_240521_a_(Tags.Blocks.CHESTS_ENDER, Tags.Items.CHESTS_ENDER); + func_240521_a_(Tags.Blocks.CHESTS_TRAPPED, Tags.Items.CHESTS_TRAPPED); + func_240521_a_(Tags.Blocks.CHESTS_WOODEN, Tags.Items.CHESTS_WOODEN); + func_240521_a_(Tags.Blocks.COBBLESTONE, Tags.Items.COBBLESTONE); + func_240522_a_(Tags.Items.CROPS).addTags(Tags.Items.CROPS_BEETROOT, Tags.Items.CROPS_CARROT, Tags.Items.CROPS_NETHER_WART, Tags.Items.CROPS_POTATO, Tags.Items.CROPS_WHEAT); + func_240522_a_(Tags.Items.CROPS_BEETROOT).func_240534_a_(Items.BEETROOT); + func_240522_a_(Tags.Items.CROPS_CARROT).func_240534_a_(Items.CARROT); + func_240522_a_(Tags.Items.CROPS_NETHER_WART).func_240534_a_(Items.NETHER_WART); + func_240522_a_(Tags.Items.CROPS_POTATO).func_240534_a_(Items.POTATO); + func_240522_a_(Tags.Items.CROPS_WHEAT).func_240534_a_(Items.WHEAT); + func_240522_a_(Tags.Items.DUSTS).addTags(Tags.Items.DUSTS_GLOWSTONE, Tags.Items.DUSTS_PRISMARINE, Tags.Items.DUSTS_REDSTONE); + func_240522_a_(Tags.Items.DUSTS_GLOWSTONE).func_240534_a_(Items.GLOWSTONE_DUST); + func_240522_a_(Tags.Items.DUSTS_PRISMARINE).func_240534_a_(Items.PRISMARINE_SHARD); + func_240522_a_(Tags.Items.DUSTS_REDSTONE).func_240534_a_(Items.REDSTONE); + addColored(func_240522_a_(Tags.Items.DYES)::addTags, Tags.Items.DYES, "{color}_dye"); + func_240522_a_(Tags.Items.EGGS).func_240534_a_(Items.EGG); + func_240521_a_(Tags.Blocks.END_STONES, Tags.Items.END_STONES); + func_240522_a_(Tags.Items.ENDER_PEARLS).func_240534_a_(Items.ENDER_PEARL); + func_240522_a_(Tags.Items.FEATHERS).func_240534_a_(Items.FEATHER); + func_240521_a_(Tags.Blocks.FENCE_GATES, Tags.Items.FENCE_GATES); + func_240521_a_(Tags.Blocks.FENCE_GATES_WOODEN, Tags.Items.FENCE_GATES_WOODEN); + func_240521_a_(Tags.Blocks.FENCES, Tags.Items.FENCES); + func_240521_a_(Tags.Blocks.FENCES_NETHER_BRICK, Tags.Items.FENCES_NETHER_BRICK); + func_240521_a_(Tags.Blocks.FENCES_WOODEN, Tags.Items.FENCES_WOODEN); + func_240522_a_(Tags.Items.GEMS).addTags(Tags.Items.GEMS_DIAMOND, Tags.Items.GEMS_EMERALD, Tags.Items.GEMS_LAPIS, Tags.Items.GEMS_PRISMARINE, Tags.Items.GEMS_QUARTZ); + func_240522_a_(Tags.Items.GEMS_DIAMOND).func_240534_a_(Items.DIAMOND); + func_240522_a_(Tags.Items.GEMS_EMERALD).func_240534_a_(Items.EMERALD); + func_240522_a_(Tags.Items.GEMS_LAPIS).func_240534_a_(Items.LAPIS_LAZULI); + func_240522_a_(Tags.Items.GEMS_PRISMARINE).func_240534_a_(Items.PRISMARINE_CRYSTALS); + func_240522_a_(Tags.Items.GEMS_QUARTZ).func_240534_a_(Items.QUARTZ); + func_240521_a_(Tags.Blocks.GLASS, Tags.Items.GLASS); + func_240521_a_Colored(Tags.Blocks.GLASS, Tags.Items.GLASS); + func_240521_a_(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); + func_240521_a_Colored(Tags.Blocks.GLASS_PANES, Tags.Items.GLASS_PANES); + func_240521_a_(Tags.Blocks.GRAVEL, Tags.Items.GRAVEL); + func_240522_a_(Tags.Items.GUNPOWDER).func_240534_a_(Items.GUNPOWDER); + func_240522_a_(Tags.Items.HEADS).func_240534_a_(Items.CREEPER_HEAD, Items.DRAGON_HEAD, Items.PLAYER_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL, Items.ZOMBIE_HEAD); + func_240522_a_(Tags.Items.INGOTS).addTags(Tags.Items.INGOTS_IRON, Tags.Items.INGOTS_GOLD, Tags.Items.INGOTS_BRICK, Tags.Items.INGOTS_NETHER_BRICK); + func_240522_a_(Tags.Items.INGOTS_BRICK).func_240534_a_(Items.BRICK); + func_240522_a_(Tags.Items.INGOTS_GOLD).func_240534_a_(Items.GOLD_INGOT); + func_240522_a_(Tags.Items.INGOTS_IRON).func_240534_a_(Items.IRON_INGOT); + func_240522_a_(Tags.Items.INGOTS_NETHER_BRICK).func_240534_a_(Items.NETHER_BRICK); + func_240522_a_(Tags.Items.LEATHER).func_240534_a_(Items.LEATHER); + func_240522_a_(Tags.Items.MUSHROOMS).func_240534_a_(Items.BROWN_MUSHROOM, Items.RED_MUSHROOM); + func_240522_a_(Tags.Items.MUSIC_DISCS).func_240534_a_(Items.MUSIC_DISC_13, Items.MUSIC_DISC_CAT, Items.MUSIC_DISC_BLOCKS, Items.MUSIC_DISC_CHIRP, Items.MUSIC_DISC_FAR, Items.MUSIC_DISC_MALL, Items.MUSIC_DISC_MELLOHI, Items.MUSIC_DISC_STAL, Items.MUSIC_DISC_STRAD, Items.MUSIC_DISC_WARD, Items.MUSIC_DISC_11, Items.MUSIC_DISC_WAIT); + func_240522_a_(Tags.Items.NETHER_STARS).func_240534_a_(Items.NETHER_STAR); + func_240521_a_(Tags.Blocks.NETHERRACK, Tags.Items.NETHERRACK); + func_240522_a_(Tags.Items.NUGGETS).addTags(Tags.Items.NUGGETS_IRON, Tags.Items.NUGGETS_GOLD); + func_240522_a_(Tags.Items.NUGGETS_IRON).func_240534_a_(Items.IRON_NUGGET); + func_240522_a_(Tags.Items.NUGGETS_GOLD).func_240534_a_(Items.GOLD_NUGGET); + func_240521_a_(Tags.Blocks.OBSIDIAN, Tags.Items.OBSIDIAN); + func_240521_a_(Tags.Blocks.ORES, Tags.Items.ORES); + func_240521_a_(Tags.Blocks.ORES_COAL, Tags.Items.ORES_COAL); + func_240521_a_(Tags.Blocks.ORES_DIAMOND, Tags.Items.ORES_DIAMOND); + func_240521_a_(Tags.Blocks.ORES_EMERALD, Tags.Items.ORES_EMERALD); + func_240521_a_(Tags.Blocks.ORES_GOLD, Tags.Items.ORES_GOLD); + func_240521_a_(Tags.Blocks.ORES_IRON, Tags.Items.ORES_IRON); + func_240521_a_(Tags.Blocks.ORES_LAPIS, Tags.Items.ORES_LAPIS); + func_240521_a_(Tags.Blocks.ORES_QUARTZ, Tags.Items.ORES_QUARTZ); + func_240521_a_(Tags.Blocks.ORES_REDSTONE, Tags.Items.ORES_REDSTONE); + func_240522_a_(Tags.Items.RODS).addTags(Tags.Items.RODS_BLAZE, Tags.Items.RODS_WOODEN); + func_240522_a_(Tags.Items.RODS_BLAZE).func_240534_a_(Items.BLAZE_ROD); + func_240522_a_(Tags.Items.RODS_WOODEN).func_240534_a_(Items.STICK); + func_240521_a_(Tags.Blocks.SAND, Tags.Items.SAND); + func_240521_a_(Tags.Blocks.SAND_COLORLESS, Tags.Items.SAND_COLORLESS); + func_240521_a_(Tags.Blocks.SAND_RED, Tags.Items.SAND_RED); + func_240521_a_(Tags.Blocks.SANDSTONE, Tags.Items.SANDSTONE); + func_240522_a_(Tags.Items.SEEDS).addTags(Tags.Items.SEEDS_BEETROOT, Tags.Items.SEEDS_MELON, Tags.Items.SEEDS_PUMPKIN, Tags.Items.SEEDS_WHEAT); + func_240522_a_(Tags.Items.SEEDS_BEETROOT).func_240534_a_(Items.BEETROOT_SEEDS); + func_240522_a_(Tags.Items.SEEDS_MELON).func_240534_a_(Items.MELON_SEEDS); + func_240522_a_(Tags.Items.SEEDS_PUMPKIN).func_240534_a_(Items.PUMPKIN_SEEDS); + func_240522_a_(Tags.Items.SEEDS_WHEAT).func_240534_a_(Items.WHEAT_SEEDS); + func_240522_a_(Tags.Items.SHEARS).func_240534_a_(Items.SHEARS); + func_240522_a_(Tags.Items.SLIMEBALLS).func_240534_a_(Items.SLIME_BALL); + func_240521_a_(Tags.Blocks.STAINED_GLASS, Tags.Items.STAINED_GLASS); + func_240521_a_(Tags.Blocks.STAINED_GLASS_PANES, Tags.Items.STAINED_GLASS_PANES); + func_240521_a_(Tags.Blocks.STONE, Tags.Items.STONE); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS, Tags.Items.STORAGE_BLOCKS); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_COAL, Tags.Items.STORAGE_BLOCKS_COAL); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_DIAMOND, Tags.Items.STORAGE_BLOCKS_DIAMOND); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_EMERALD, Tags.Items.STORAGE_BLOCKS_EMERALD); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_GOLD, Tags.Items.STORAGE_BLOCKS_GOLD); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_IRON, Tags.Items.STORAGE_BLOCKS_IRON); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_LAPIS, Tags.Items.STORAGE_BLOCKS_LAPIS); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_QUARTZ, Tags.Items.STORAGE_BLOCKS_QUARTZ); + func_240521_a_(Tags.Blocks.STORAGE_BLOCKS_REDSTONE, Tags.Items.STORAGE_BLOCKS_REDSTONE); + func_240522_a_(Tags.Items.STRING).func_240534_a_(Items.STRING); } private void addColored(Consumer> consumer, Tag group, String pattern) diff --git a/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java new file mode 100644 index 000000000..18c0d769e --- /dev/null +++ b/src/main/java/net/minecraftforge/common/data/ForgeLootTableProvider.java @@ -0,0 +1,174 @@ +package net.minecraftforge.common.data; + +import com.mojang.datafixers.util.Pair; +import net.minecraft.advancements.criterion.ItemPredicate; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.LootTableProvider; +import net.minecraft.item.Item; +import net.minecraft.item.Items; +import net.minecraft.tags.Tag; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.loot.*; +import net.minecraft.world.storage.loot.conditions.Alternative; +import net.minecraft.world.storage.loot.conditions.ILootCondition; +import net.minecraft.world.storage.loot.conditions.Inverted; +import net.minecraft.world.storage.loot.conditions.MatchTool; +import net.minecraftforge.common.Tags; +import net.minecraftforge.fml.common.ObfuscationReflectionHelper; + +import java.util.List; +import java.util.Map; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +/** + * Currently used only for replacing shears item to shears tag + */ +public class ForgeLootTableProvider extends LootTableProvider { + + public ForgeLootTableProvider(DataGenerator gen) { + super(gen); + } + + @Override + protected void validate(Map map, ValidationTracker validationtracker) { + // do not validate against all registered loot tables + } + + @Override + protected List>>, LootParameterSet>> getTables() { + return super.getTables().stream().map(pair -> { + // provides new consumer with filtering only changed loot tables and replacing condition item to condition tag + return new Pair>>, LootParameterSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond()); + }).collect(Collectors.toList()); + } + + private Consumer> replaceAndFilterChangesOnly(Consumer> consumer) { + return (newConsumer) -> consumer.accept((resourceLocation, builder) -> { + if (findAndReplaceInLootTableBuilder(builder, Items.SHEARS, Tags.Items.SHEARS)) { + newConsumer.accept(resourceLocation, builder); + } + }); + } + + private boolean findAndReplaceInLootTableBuilder(LootTable.Builder builder, Item from, Tag to) { + List lootPools = ObfuscationReflectionHelper.getPrivateValue(LootTable.Builder.class, builder, "field_216041_a"); + boolean found = false; + + if (lootPools == null) { + throw new IllegalStateException(LootTable.Builder.class.getName() + " is missing field field_216041_a"); + } + + for (LootPool lootPool : lootPools) { + if (findAndReplaceInLootPool(lootPool, from, to)) { + found = true; + } + } + + return found; + } + + private boolean findAndReplaceInLootPool(LootPool lootPool, Item from, Tag to) { + List lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186453_a"); + List lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186454_b"); + boolean found = false; + + if (lootEntries == null) { + throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186453_a"); + } + + for (LootEntry lootEntry : lootEntries) { + if (lootEntry instanceof ParentedLootEntry) { + if (findAndReplaceInParentedLootEntry((ParentedLootEntry) lootEntry, from, to)) { + found = true; + } + } + } + + if (lootConditions == null) { + throw new IllegalStateException(LootPool.class.getName() + " is missing field field_186454_b"); + } + + for (int i = 0; i < lootConditions.size(); i++) { + ILootCondition lootCondition = lootConditions.get(i); + if (lootCondition instanceof MatchTool && checkMatchTool((MatchTool) lootCondition, from)) { + lootConditions.set(i, MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build()); + found = true; + } else if (lootCondition instanceof Inverted) { + ILootCondition invLootCondition = ObfuscationReflectionHelper.getPrivateValue(Inverted.class, (Inverted) lootCondition, "field_215981_a"); + + if (invLootCondition instanceof MatchTool && checkMatchTool((MatchTool) invLootCondition, from)) { + lootConditions.set(i, Inverted.builder(MatchTool.builder(ItemPredicate.Builder.create().tag(to))).build()); + found = true; + } else if (invLootCondition instanceof Alternative && findAndReplaceInAlternative((Alternative) invLootCondition, from, to)) { + found = true; + } + } + } + + return found; + } + + private boolean findAndReplaceInParentedLootEntry(ParentedLootEntry entry, Item from, Tag to) { + LootEntry[] lootEntries = ObfuscationReflectionHelper.getPrivateValue(ParentedLootEntry.class, entry, "field_216147_c"); + boolean found = false; + + if (lootEntries == null) { + throw new IllegalStateException(ParentedLootEntry.class.getName() + " is missing field field_216147_c"); + } + + for (LootEntry lootEntry : lootEntries) { + if (findAndReplaceInLootEntry(lootEntry, from, to)) { + found = true; + } + } + + return found; + } + + private boolean findAndReplaceInLootEntry(LootEntry entry, Item from, Tag to) { + ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(LootEntry.class, entry, "field_216144_d"); + boolean found = false; + + if (lootConditions == null) { + throw new IllegalStateException(LootEntry.class.getName() + " is missing field field_216144_d"); + } + + for (int i = 0; i < lootConditions.length; i++) { + if (lootConditions[i] instanceof Alternative && findAndReplaceInAlternative((Alternative) lootConditions[i], from, to)) { + found = true; + } else if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) { + lootConditions[i] = MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build(); + found = true; + } + } + + return found; + } + + private boolean findAndReplaceInAlternative(Alternative alternative, Item from, Tag to) { + ILootCondition[] lootConditions = ObfuscationReflectionHelper.getPrivateValue(Alternative.class, alternative, "field_215962_a"); + boolean found = false; + + if (lootConditions == null) { + throw new IllegalStateException(Alternative.class.getName() + " is missing field field_215962_a"); + } + + for (int i = 0; i < lootConditions.length; i++) { + if (lootConditions[i] instanceof MatchTool && checkMatchTool((MatchTool) lootConditions[i], from)) { + lootConditions[i] = MatchTool.builder(ItemPredicate.Builder.create().tag(to)).build(); + found = true; + } + } + + return found; + } + + private boolean checkMatchTool(MatchTool lootCondition, Item expected) { + ItemPredicate predicate = ObfuscationReflectionHelper.getPrivateValue(MatchTool.class, lootCondition, "field_216014_a"); + Item item = ObfuscationReflectionHelper.getPrivateValue(ItemPredicate.class, predicate, "field_192496_b"); + return item != null && item.equals(expected); + } +}