From 6a5e37b632d578b1fa483526fea879776eea9636 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 11 May 2016 11:50:06 -0500 Subject: [PATCH] Update forge, fully fix loot generation --- build.properties | 2 +- .../botania/common/core/loot/LootHandler.java | 41 ++++++++++++++----- .../botania/loot_tables/gaia_guardian_2.json | 2 - .../inject/abandoned_mineshaft.json | 10 +++-- .../loot_tables/inject/desert_pyramid.json | 10 +++-- .../loot_tables/inject/jungle_temple.json | 10 +++-- .../loot_tables/inject/simple_dungeon.json | 14 ++++--- .../loot_tables/inject/spawn_bonus_chest.json | 10 +++-- .../inject/stronghold_corridor.json | 12 ++++-- .../inject/village_blacksmith.json | 9 +++- 10 files changed, 84 insertions(+), 36 deletions(-) diff --git a/build.properties b/build.properties index 9c5002334..1d7aedc52 100644 --- a/build.properties +++ b/build.properties @@ -4,6 +4,6 @@ version=r1.8 dir_output=../Build Output/Botania/ dir_repo=./ mc_version=1.9 -forge_version=12.16.1.1898 +forge_version=12.16.1.1901 build_number=305 mod_name=Botania diff --git a/src/main/java/vazkii/botania/common/core/loot/LootHandler.java b/src/main/java/vazkii/botania/common/core/loot/LootHandler.java index 98995349d..45f7d8d30 100644 --- a/src/main/java/vazkii/botania/common/core/loot/LootHandler.java +++ b/src/main/java/vazkii/botania/common/core/loot/LootHandler.java @@ -1,6 +1,7 @@ package vazkii.botania.common.core.loot; import com.google.common.collect.ImmutableList; +import net.minecraft.entity.item.EntityMinecartChest; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootEntry; import net.minecraft.world.storage.loot.LootEntryTable; @@ -11,6 +12,7 @@ import net.minecraft.world.storage.loot.conditions.LootCondition; import net.minecraft.world.storage.loot.conditions.LootConditionManager; import net.minecraft.world.storage.loot.functions.LootFunctionManager; import net.minecraftforge.event.LootTableLoadEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import vazkii.botania.common.lib.LibMisc; @@ -38,19 +40,38 @@ public final class LootHandler { @SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { - switch (evt.getName().toString()) { - case "minecraft:chests/spawn_bonus_chest": break; - case "minecraft:chests/stronghold_corridor": break; - case "minecraft:chests/simple_dungeon": break; - case "minecraft:chests/desert_pyramid": break; - case "minecraft:chests/abandoned_mineshaft": break; - case "minecraft:chests/jungle_temple": break; - case "minecraft:chests/village_blacksmith": break; + String prefix = "minecraft:chests/"; + String name = evt.getName().toString(); + + if (name.startsWith(prefix)) { + String file = name.substring(name.indexOf(prefix) + prefix.length()); + switch (file) { + case "abandoned_mineshaft": + case "desert_pyramid": + case "jungle_temple": + case "simple_dungeon": + case "spawn_bonus_chest": + case "stronghold_corridor": + case "village_blacksmith": evt.getTable().addPool(getInjectPool(file)); break; + default: break; + } } } - private LootEntryTable getInjectEntry(String name) { - return new LootEntryTable(new ResourceLocation(LibMisc.MOD_ID, "inject/" + name), 1, 0, new LootCondition[0], "botania_inject"); + @SubscribeEvent + public void lootTest(PlayerInteractEvent.EntityInteract evt) { + if (!evt.getWorld().isRemote && evt.getTarget() instanceof EntityMinecartChest) { + ((EntityMinecartChest) evt.getTarget()).clear(); + ((EntityMinecartChest) evt.getTarget()).setLootTable(new ResourceLocation("minecraft", "chests/village_blacksmith"), evt.getTarget().worldObj.rand.nextLong()); + } + } + + private LootPool getInjectPool(String entryName) { + return new LootPool(new LootEntry[] { getInjectEntry(entryName, 1) }, new LootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "botania_inject_pool"); + } + + private LootEntryTable getInjectEntry(String name, int weight) { + return new LootEntryTable(new ResourceLocation(LibMisc.MOD_ID, "inject/" + name), weight, 0, new LootCondition[0], "botania_inject_entry"); } } diff --git a/src/main/resources/assets/botania/loot_tables/gaia_guardian_2.json b/src/main/resources/assets/botania/loot_tables/gaia_guardian_2.json index bcce6bebb..98e512975 100644 --- a/src/main/resources/assets/botania/loot_tables/gaia_guardian_2.json +++ b/src/main/resources/assets/botania/loot_tables/gaia_guardian_2.json @@ -29,7 +29,6 @@ { "type": "item", "entryName": "superBlackLotus", - "EntryName": "superBlackLotus", "name": "botania:blackLotus", "weight": 3, "quality": 1, @@ -40,7 +39,6 @@ }, { "type": "item", - "EntryName": "normalBlackLotus", "entryName": "normalBlackLotus", "name": "botania:blackLotus", "weight": 7, diff --git a/src/main/resources/assets/botania/loot_tables/inject/abandoned_mineshaft.json b/src/main/resources/assets/botania/loot_tables/inject/abandoned_mineshaft.json index 8f144da13..76e33d585 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/abandoned_mineshaft.json +++ b/src/main/resources/assets/botania/loot_tables/inject/abandoned_mineshaft.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/abandoned_mineshaft", + "__comment": "This table is injected as its own pool into minecraft:chests/abandoned_mineshaft", "pools": [{ "name": "main", "rolls": 1, @@ -7,12 +7,16 @@ { "type": "item", "name": "botania:blackLotus", - "weight": 6 + "weight": 35 }, { "type": "item", "name": "botania:overgrowthSeed", - "weight": 2 + "weight": 5 + }, + { + "type": "empty", + "weight": 60 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/desert_pyramid.json b/src/main/resources/assets/botania/loot_tables/inject/desert_pyramid.json index eba4a58e3..68b7e2f1d 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/desert_pyramid.json +++ b/src/main/resources/assets/botania/loot_tables/inject/desert_pyramid.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/desert_pyramid", + "__comment": "This table is injected as its own pool into minecraft:chests/desert_pyramid", "pools": [{ "name": "main", "rolls": 1, @@ -7,12 +7,16 @@ { "type": "item", "name": "botania:blackLotus", - "weight": 6 + "weight": 35 }, { "type": "item", "name": "botania:overgrowthSeed", - "weight": 2 + "weight": 5 + }, + { + "type": "empty", + "weight": 60 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/jungle_temple.json b/src/main/resources/assets/botania/loot_tables/inject/jungle_temple.json index 904bfe874..02c18574d 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/jungle_temple.json +++ b/src/main/resources/assets/botania/loot_tables/inject/jungle_temple.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/jungle_temple", + "__comment": "This table is injected as its own pool into minecraft:chests/jungle_temple", "pools": [{ "name": "main", "rolls": 1, @@ -7,12 +7,16 @@ { "type": "item", "name": "botania:blackLotus", - "weight": 6 + "weight": 25 }, { "type": "item", "name": "botania:overgrowthSeed", - "weight": 2 + "weight": 5 + }, + { + "type": "empty", + "weight": 70 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/simple_dungeon.json b/src/main/resources/assets/botania/loot_tables/inject/simple_dungeon.json index b5763ed6b..63cc6d111 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/simple_dungeon.json +++ b/src/main/resources/assets/botania/loot_tables/inject/simple_dungeon.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/simple_dungeon", + "__comment": "This table is injected as its own pool into minecraft:chests/simple_dungeon", "pools": [{ "name": "main", "rolls": 1, @@ -7,28 +7,32 @@ { "type": "item", "name": "botania:manaResource", - "weight": 9, + "weight": 50, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 5 } }] }, { "type": "item", "name": "botania:lexicon", - "weight": 6 + "weight": 20 }, { "type": "item", "name": "botania:manaBottle", - "weight": 5 + "weight": 10 }, { "type": "item", "name": "botania:blackLotus", - "weight": 6 + "weight": 5 }, { "type": "item", "name": "botania:overgrowthSeed", "weight": 2 + }, + { + "type": "empty", + "weight": 13 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/spawn_bonus_chest.json b/src/main/resources/assets/botania/loot_tables/inject/spawn_bonus_chest.json index ed91190c3..a06aeb93b 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/spawn_bonus_chest.json +++ b/src/main/resources/assets/botania/loot_tables/inject/spawn_bonus_chest.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/spawn_bonus_chest", + "__comment": "This table is injected as its own pool into minecraft:chests/spawn_bonus_chest", "pools": [{ "name": "main", "rolls": 1, @@ -7,12 +7,16 @@ { "type": "item", "name": "botania:lexicon", - "weight": 7 + "weight": 80 }, { "type": "item", "name": "botania:blackLotus", - "weight": 1 + "weight": 10 + }, + { + "type": "empty", + "weight": 10 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/stronghold_corridor.json b/src/main/resources/assets/botania/loot_tables/inject/stronghold_corridor.json index 64f59ca43..06b7256b4 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/stronghold_corridor.json +++ b/src/main/resources/assets/botania/loot_tables/inject/stronghold_corridor.json @@ -1,5 +1,5 @@ { - "__comment": "This table is injected into minecraft:chests/stronghold_corridor", + "__comment": "This table is injected as its own pool into minecraft:chests/stronghold_corridor", "pools": [{ "name": "main", "rolls": 1, @@ -7,18 +7,22 @@ { "type": "item", "name": "botania:manaResource", - "weight": 10, + "weight": 45, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 3 } }] }, { "type": "item", "name": "botania:blackLotus", - "weight": 6 + "weight": 10 }, { "type": "item", "name": "botania:overgrowthSeed", - "weight": 2 + "weight": 5 + }, + { + "type": "empty", + "weight": 40 } ] }] diff --git a/src/main/resources/assets/botania/loot_tables/inject/village_blacksmith.json b/src/main/resources/assets/botania/loot_tables/inject/village_blacksmith.json index dd71a90d8..02c5198bb 100644 --- a/src/main/resources/assets/botania/loot_tables/inject/village_blacksmith.json +++ b/src/main/resources/assets/botania/loot_tables/inject/village_blacksmith.json @@ -1,12 +1,17 @@ { - "__comment": "This table is injected into minecraft:chests/village_blacksmith", + "__comment": "This table is injected as its own pool into minecraft:chests/village_blacksmith", "pools": [{ "name": "main", "rolls": 1, "entries": [ { "type": "item", - "name": "botania:blackLotus" + "name": "botania:blackLotus", + "weight": 10 + }, + { + "type": "empty", + "weight": 90 } ] }]