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
|
|
|
|
2018-05-10 11:38:58 +02:00
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
2016-10-30 20:28:02 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
2016-11-21 18:56:28 +01:00
|
|
|
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;
|
2016-10-30 23:08:40 +01:00
|
|
|
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-10-30 23:08:40 +01:00
|
|
|
import net.minecraft.init.Items;
|
2016-10-30 20:28:02 +01:00
|
|
|
import net.minecraft.item.Item;
|
2016-10-30 23:08:40 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-05-02 09:10:29 +02:00
|
|
|
import net.minecraft.world.storage.loot.LootEntry;
|
|
|
|
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;
|
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;
|
2016-10-30 23:08:40 +01:00
|
|
|
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
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class DungeonLoot {
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2018-05-10 11:38:58 +02:00
|
|
|
public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "jam_house");
|
|
|
|
public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ActuallyAdditions.MODID, "lush_caves");
|
|
|
|
public static final ResourceLocation ENGINEER_HOUSE = new ResourceLocation(ActuallyAdditions.MODID, "engineer_house");
|
2016-10-30 23:08:40 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public DungeonLoot() {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootTableList.register(JAM_HOUSE);
|
|
|
|
LootTableList.register(LUSH_CAVES);
|
2016-11-21 18:56:28 +01:00
|
|
|
LootTableList.register(ENGINEER_HOUSE);
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
@SubscribeEvent
|
2019-05-02 09:10:29 +02:00
|
|
|
public void onLootTableLoad(LootTableLoadEvent event) {
|
|
|
|
if (event.getName() != null && event.getTable() != null) {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootCondition[] noCondition = new LootCondition[0];
|
|
|
|
|
|
|
|
LootPool pool = event.getTable().getPool("main");
|
2019-05-02 09:10:29 +02:00
|
|
|
if (pool == null) {
|
2016-11-20 13:26:36 +01:00
|
|
|
pool = new LootPool(new LootEntry[0], noCondition, new RandomValueRange(5, 10), new RandomValueRange(0), "main");
|
2016-10-30 23:08:40 +01:00
|
|
|
event.getTable().addPool(pool);
|
|
|
|
}
|
|
|
|
|
2016-10-30 20:28:02 +01:00
|
|
|
boolean addCrystals = false;
|
|
|
|
boolean addDrillCore = false;
|
|
|
|
boolean addQuartz = false;
|
|
|
|
boolean addBatWings = false;
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (ConfigBoolValues.DUNGEON_LOOT.isEnabled()) {
|
|
|
|
if (LootTableList.CHESTS_SIMPLE_DUNGEON.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_ABANDONED_MINESHAFT.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_VILLAGE_BLACKSMITH.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_STRONGHOLD_LIBRARY.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addBatWings = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addBatWings = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addDrillCore = true;
|
|
|
|
addBatWings = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_NETHER_BRIDGE.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addBatWings = true;
|
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_END_CITY_TREASURE.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addBatWings = true;
|
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (LootTableList.CHESTS_WOODLAND_MANSION.equals(event.getName())) {
|
2017-03-16 12:01:10 +01:00
|
|
|
addBatWings = true;
|
|
|
|
addCrystals = true;
|
|
|
|
addDrillCore = true;
|
|
|
|
addQuartz = true;
|
|
|
|
}
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
2017-03-16 12:01:10 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (JAM_HOUSE.equals(event.getName())) {
|
|
|
|
LootFunction jamDamage = new SetMetadata(noCondition, new RandomValueRange(0, TheJams.values().length - 1));
|
2016-11-01 20:47:37 +01:00
|
|
|
LootFunction jamAmount = new SetCount(noCondition, new RandomValueRange(3, 5));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[] { jamDamage, jamAmount }, noCondition, ActuallyAdditions.MODID + ":jams"));
|
2016-10-30 20:28:02 +01:00
|
|
|
|
2016-11-01 20:47:37 +01:00
|
|
|
LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(2));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(Items.GLASS_BOTTLE, 1, 0, new LootFunction[] { glassAmount }, noCondition, ActuallyAdditions.MODID + ":bottles"));
|
|
|
|
} else if (LUSH_CAVES.equals(event.getName())) {
|
2016-10-30 23:08:40 +01:00
|
|
|
addQuartz = true;
|
|
|
|
addBatWings = true;
|
2016-11-01 00:12:15 +01:00
|
|
|
addCrystals = true;
|
2016-10-30 20:28:02 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(Items.BOOK, 50, 0, new LootFunction[0], noCondition, ActuallyAdditions.MODID + ":book"));
|
2016-10-30 20:28:02 +01:00
|
|
|
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(Items.BONE, 100, 0, new LootFunction[] { bonesAmount }, noCondition, ActuallyAdditions.MODID + ":bones"));
|
2016-10-30 20:28:02 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
Item[] aiots = new Item[] { InitItems.woodenPaxel, InitItems.stonePaxel, InitItems.quartzPaxel, InitItems.itemPaxelCrystalBlack, InitItems.itemPaxelCrystalWhite };
|
|
|
|
for (int i = 0; i < aiots.length; i++) {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.25F));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(aiots[i], 30 - i * 5, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":aiot" + i));
|
2016-10-30 20:28:02 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02: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++) {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction damage = new SetDamage(noCondition, new RandomValueRange(0F, 0.75F));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":armor" + i));
|
2016-10-30 20:28:02 +01:00
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (ENGINEER_HOUSE.equals(event.getName())) {
|
2016-11-21 18:56:28 +01:00
|
|
|
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()));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[] { woodCaseAmount, woodCaseDamage }, noCondition, ActuallyAdditions.MODID + ":woodenCase"));
|
2016-11-21 18:56:28 +01:00
|
|
|
|
|
|
|
LootFunction ironCaseAmount = new SetCount(noCondition, new RandomValueRange(1, 3));
|
|
|
|
LootFunction ironCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.IRON_CASING.ordinal()));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[] { ironCaseAmount, ironCaseDamage }, noCondition, ActuallyAdditions.MODID + ":ironCase"));
|
2016-11-21 18:56:28 +01:00
|
|
|
}
|
2016-10-30 20:28:02 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (addCrystals) {
|
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length - 1));
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 3));
|
2019-05-02 09:10:29 +02:00
|
|
|
LootFunction[] functions = new LootFunction[] { damage, amount };
|
2015-11-15 19:24:36 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemCrystal, 20, 0, functions, noCondition, ActuallyAdditions.MODID + ":crystalItems"));
|
|
|
|
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockCrystal), 3, 0, functions, noCondition, ActuallyAdditions.MODID + ":crystalBlocks"));
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (addDrillCore) {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.DRILL_CORE.ordinal()));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[] { damage }, noCondition, ActuallyAdditions.MODID + ":drillCore"));
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (addQuartz) {
|
2016-10-30 23:08:40 +01:00
|
|
|
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));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 20, 0, new LootFunction[] { damage, amount }, noCondition, ActuallyAdditions.MODID + ":quartz"));
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (addBatWings) {
|
2016-10-30 23:08:40 +01:00
|
|
|
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(TheMiscItems.BAT_WING.ordinal()));
|
|
|
|
LootFunction amount = new SetCount(noCondition, new RandomValueRange(1, 2));
|
2019-05-02 09:10:29 +02:00
|
|
|
pool.addEntry(new LootEntryItem(InitItems.itemMisc, 5, 0, new LootFunction[] { damage, amount }, noCondition, ActuallyAdditions.MODID + ":batWings"));
|
2016-10-30 23:08:40 +01:00
|
|
|
}
|
2015-11-15 19:24:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|