ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java

186 lines
9.7 KiB
Java
Raw Normal View History

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
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 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;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
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.TheJams;
2016-10-30 20:28:02 +01:00
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.init.Items;
2016-10-30 20:28:02 +01:00
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.*;
2016-10-30 20:28:02 +01:00
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.SetDamage;
2016-10-30 20:28:02 +01:00
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-11-19 23:14:17 +01:00
public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "jam_house");
public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ModUtil.MOD_ID, "lush_caves");
public static final ResourceLocation ENGINEER_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "engineer_house");
public DungeonLoot(){
LootTableList.register(JAM_HOUSE);
LootTableList.register(LUSH_CAVES);
LootTableList.register(ENGINEER_HOUSE);
}
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){
LootCondition[] noCondition = new LootCondition[0];
LootPool pool = event.getTable().getPool("main");
if(pool == null){
pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main");
event.getTable().addPool(pool);
}
2016-10-30 20:28:02 +01:00
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;
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;
}
else if(LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())){
addDrillCore = true;
addBatWings = true;
}
2016-11-18 20:30:49 +01:00
else if(LootTableList.CHESTS_NETHER_BRIDGE.equals(event.getName())){
addBatWings = true;
addCrystals = true;
addDrillCore = true;
addBook = true;
}
else if(LootTableList.CHESTS_END_CITY_TREASURE.equals(event.getName())){
addBatWings = true;
addCrystals = true;
addDrillCore = true;
addQuartz = true;
}
2016-11-26 21:32:27 +01:00
else if(LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())){
addBatWings = true;
addCrystals = true;
addDrillCore = true;
addQuartz = true;
addBook = true;
}
else if(JAM_HOUSE.equals(event.getName())){
LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length-1));
LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(3, 5));
pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[]{jamDamage, jamAmount}, noCondition, ModUtil.MOD_ID+":jams"));
2016-10-30 20:28:02 +01:00
LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(2));
pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[]{glassAmount}, noCondition, ModUtil.MOD_ID+":bottles"));
}
else if(LUSH_CAVES.equals(event.getName())){
addBook = true;
addQuartz = true;
addBatWings = true;
2016-11-01 00:12:15 +01:00
addCrystals = true;
2016-10-30 20:28:02 +01:00
pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ModUtil.MOD_ID+":book"));
2016-10-30 20:28:02 +01:00
LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12));
pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[]{bonesAmount}, noCondition, ModUtil.MOD_ID+":bones"));
2016-10-30 20:28:02 +01:00
Item[] aiots = new Item[]{InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite};
for(int i = 0; i < aiots.length; i++){
LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.25F));
pool.addEntry(new LootEntryItem(aiots[i], 30-i*5, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":aiot"+i));
2016-10-30 20:28:02 +01:00
}
Item[] armor = new Item[]{Items.LEATHER_HELMET, Items.LEATHER_CHESTPLATE, Items.LEATHER_LEGGINGS, Items.LEATHER_BOOTS};
for(int i = 0; i < armor.length; i++){
LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.75F));
pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i));
2016-10-30 20:28:02 +01:00
}
}
else if(ENGINEER_HOUSE.equals(event.getName())){
addBook = true;
addQuartz = true;
addBatWings = true;
addCrystals = true;
addDrillCore = true;
LootFunction woodCaseAmount = new SetCount(noCondition, new RandomValueRange(3, 10));
LootFunction woodCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.WOOD_CASING.ordinal()));
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[]{woodCaseAmount, woodCaseDamage}, noCondition, ModUtil.MOD_ID+":woodenCase"));
LootFunction ironCaseAmount = new SetCount(noCondition, new RandomValueRange(1, 3));
LootFunction ironCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.IRON_CASING.ordinal()));
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[]{ironCaseAmount, ironCaseDamage}, noCondition, ModUtil.MOD_ID+":ironCase"));
}
2016-10-30 20:28:02 +01:00
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};
2015-11-15 19:24:36 +01:00
2016-12-18 14:55:04 +01:00
pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 20, 0, functions, noCondition, ModUtil.MOD_ID+":crystalItems"));
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 3, 0, functions, noCondition, ModUtil.MOD_ID+":crystalBlocks"));
}
if(addDrillCore){
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal()));
2016-12-18 14:55:04 +01:00
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":drillCore"));
}
if(addQuartz){
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.QUARTZ.ordinal()));
2016-12-18 14:55:04 +01:00
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 5));
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 20, 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"));
}
if(addBook){
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1));
2016-12-18 14:55:04 +01:00
pool.addEntry(new LootEntryItem(InitItems.itemBooklet, 10, 0, new LootFunction[]{amount}, noCondition, ModUtil.MOD_ID+":booklet"));
2015-11-15 19:24:36 +01:00
}
}
}
}