Replace explicit shears reference in vanilla loot tables with tag for modded shears. (#6765)

This commit is contained in:
Yanny 2020-06-25 18:31:09 +02:00 committed by cpw
parent 2ffdfb9582
commit 469527890f
No known key found for this signature in database
GPG Key ID: 8EB3DF749553B1B7
20 changed files with 1530 additions and 111 deletions

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:shears"
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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"
}
}
]
}
]
}

View File

@ -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
}
}
]
}
}
]
}
}
]
}
]
}

View File

@ -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"
}
]
}
]
}
]
}

View File

@ -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"
}
}
]
}
]
}

View File

@ -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"
}
}
]
}
]
}

View File

@ -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));
}
}

View File

@ -246,26 +246,27 @@ public class Tags
public static final Tag<Item> SAND_COLORLESS = tag("sand/colorless");
public static final Tag<Item> SAND_RED = tag("sand/red");
public static final Tag<Item> SANDSTONE = tag("sandstone");
public static final Tag<Item> SEEDS = tag("seeds");
public static final Tag<Item> SEEDS_BEETROOT = tag("seeds/beetroot");
public static final Tag<Item> SEEDS_MELON = tag("seeds/melon");
public static final Tag<Item> SEEDS_PUMPKIN = tag("seeds/pumpkin");
public static final Tag<Item> SEEDS_WHEAT = tag("seeds/wheat");
public static final Tag<Item> SLIMEBALLS = tag("slimeballs");
public static final Tag<Item> STAINED_GLASS = tag("stained_glass");
public static final Tag<Item> STAINED_GLASS_PANES = tag("stained_glass_panes");
public static final Tag<Item> STONE = tag("stone");
public static final Tag<Item> STORAGE_BLOCKS = tag("storage_blocks");
public static final Tag<Item> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
public static final Tag<Item> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
public static final Tag<Item> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
public static final Tag<Item> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
public static final Tag<Item> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
public static final Tag<Item> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
public static final Tag<Item> STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz");
public static final Tag<Item> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
public static final Tag<Item> STRING = tag("string");
public static final ITag.INamedTag<Item> SANDSTONE = tag("sandstone");
public static final ITag.INamedTag<Item> SEEDS = tag("seeds");
public static final ITag.INamedTag<Item> SEEDS_BEETROOT = tag("seeds/beetroot");
public static final ITag.INamedTag<Item> SEEDS_MELON = tag("seeds/melon");
public static final ITag.INamedTag<Item> SEEDS_PUMPKIN = tag("seeds/pumpkin");
public static final ITag.INamedTag<Item> SEEDS_WHEAT = tag("seeds/wheat");
public static final ITag.INamedTag<Item> SHEARS = tag("shears");
public static final ITag.INamedTag<Item> SLIMEBALLS = tag("slimeballs");
public static final ITag.INamedTag<Item> STAINED_GLASS = tag("stained_glass");
public static final ITag.INamedTag<Item> STAINED_GLASS_PANES = tag("stained_glass_panes");
public static final ITag.INamedTag<Item> STONE = tag("stone");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS = tag("storage_blocks");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_COAL = tag("storage_blocks/coal");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_DIAMOND = tag("storage_blocks/diamond");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_EMERALD = tag("storage_blocks/emerald");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_GOLD = tag("storage_blocks/gold");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_IRON = tag("storage_blocks/iron");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_LAPIS = tag("storage_blocks/lapis");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_QUARTZ = tag("storage_blocks/quartz");
public static final ITag.INamedTag<Item> STORAGE_BLOCKS_REDSTONE = tag("storage_blocks/redstone");
public static final ITag.INamedTag<Item> STRING = tag("string");
private static Tag<Item> tag(String name)
{

View File

@ -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<Tag<Item>> consumer, Tag<Item> group, String pattern)

View File

@ -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<ResourceLocation, LootTable> map, ValidationTracker validationtracker) {
// do not validate against all registered loot tables
}
@Override
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, 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<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootParameterSet>(() -> replaceAndFilterChangesOnly(pair.getFirst().get()), pair.getSecond());
}).collect(Collectors.toList());
}
private Consumer<BiConsumer<ResourceLocation, LootTable.Builder>> replaceAndFilterChangesOnly(Consumer<BiConsumer<ResourceLocation, LootTable.Builder>> 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<Item> to) {
List<LootPool> 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<Item> to) {
List<LootEntry> lootEntries = ObfuscationReflectionHelper.getPrivateValue(LootPool.class, lootPool, "field_186453_a");
List<ILootCondition> 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<Item> 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<Item> 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<Item> 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);
}
}