2015-11-15 19:24:36 +01:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("DungeonLoot.java") is part of the Actually Additions mod for Minecraft.
|
2015-11-15 19:24:36 +01:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-11-15 19:24:36 +01:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-11-15 19:24:36 +01:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.misc;
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
2016-10-30 20:28:02 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
|
2016-10-30 20:28:02 +01:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.world.storage.loot.LootEntryItem;
|
|
|
|
import net.minecraft.world.storage.loot.LootPool;
|
|
|
|
import net.minecraft.world.storage.loot.LootTableList;
|
|
|
|
import net.minecraft.world.storage.loot.RandomValueRange;
|
|
|
|
import net.minecraft.world.storage.loot.conditions.LootCondition;
|
|
|
|
import net.minecraft.world.storage.loot.functions.LootFunction;
|
|
|
|
import net.minecraft.world.storage.loot.functions.SetCount;
|
|
|
|
import net.minecraft.world.storage.loot.functions.SetMetadata;
|
|
|
|
import net.minecraftforge.event.LootTableLoadEvent;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
public class DungeonLoot{
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
@SubscribeEvent
|
|
|
|
public void onLootTableLoad(LootTableLoadEvent event){
|
|
|
|
if(ConfigBoolValues.DUNGEON_LOOT.isEnabled() && event.getName() != null && event.getTable() != null){
|
|
|
|
boolean addCrystals = false;
|
|
|
|
boolean addDrillCore = false;
|
|
|
|
boolean addQuartz = false;
|
|
|
|
boolean addBatWings = false;
|
|
|
|
boolean addBook = false;
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
if(LootTableList.CHESTS_SIMPLE_DUNGEON.equals(event.getName())){
|
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
|
|
|
}
|
|
|
|
else if(LootTableList.CHESTS_ABANDONED_MINESHAFT.equals(event.getName())){
|
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
|
|
|
}
|
|
|
|
else if(LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())){
|
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
|
|
|
addBatWings = true;
|
|
|
|
addBook = true;
|
|
|
|
}
|
|
|
|
else if(LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())){
|
|
|
|
addBatWings = true;
|
|
|
|
addBook = true;
|
|
|
|
}
|
|
|
|
else if(LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())){
|
|
|
|
addBatWings = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
LootPool pool = event.getTable().getPool("main");
|
|
|
|
if(pool != null){
|
|
|
|
LootCondition[] noCondition = new LootCondition[0];
|
|
|
|
|
|
|
|
if(addCrystals){
|
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length-1));
|
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 3));
|
|
|
|
LootFunction[] functions = new LootFunction[]{damage, amount};
|
|
|
|
|
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 50, 0, functions, noCondition, ModUtil.MOD_ID+":crystalItems"));
|
|
|
|
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 5, 0, functions, noCondition, ModUtil.MOD_ID+":crystalBlocks"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(addDrillCore){
|
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal()));
|
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 10, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":drillCore"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(addQuartz){
|
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.QUARTZ.ordinal()));
|
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 10));
|
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 80, 0, new LootFunction[]{damage, amount}, noCondition, ModUtil.MOD_ID+":quartz"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(addBatWings){
|
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.BAT_WING.ordinal()));
|
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 2));
|
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[]{damage, amount}, noCondition, ModUtil.MOD_ID+":batWings"));
|
|
|
|
}
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
if(addBook){
|
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1));
|
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemBooklet, 100, 0, new LootFunction[]{amount}, noCondition, ModUtil.MOD_ID+":booklet"));
|
|
|
|
}
|
2015-11-15 19:24:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|