mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 04:09:40 +00:00
Update forge, fully fix loot generation
This commit is contained in:
10 files changed
+84
-36
No files matched your search
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user