diff --git a/build.gradle b/build.gradle index 52046dd53..d316a3919 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,10 @@ buildscript { classpath 'net.minecraftforge.gradle:ForgeGradle:3.+' } } +plugins { + // must use gradle v3.0+ for this version of shadow (2.0.1). Update gradle-wrapper.properties + id "com.github.johnrengelman.shadow" version "4.0.4" +} apply plugin: 'net.minecraftforge.gradle' //Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. diff --git a/gradle.properties b/gradle.properties index 4d9f05dbc..4f0f700de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ mc_version=1.12.2 forge_version=14.23.5.2854 mappings_version=20171003-1.12 gottschcore_version=1.14.0 -gottschcore_forge_version=14.23.5.2768 +gottschcore_forge_version=14.23.5.2854 patchouli_version=1.0-20.108 # paths diff --git a/src/main/java/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java b/src/main/java/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java index 0833aaba4..85d0c837d 100644 --- a/src/main/java/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java +++ b/src/main/java/com/someguyssoftware/treasure2/eventhandler/WorldEventHandler.java @@ -3,6 +3,8 @@ */ package com.someguyssoftware.treasure2.eventhandler; +import static com.someguyssoftware.treasure2.Treasure.logger; + import java.util.Map.Entry; import com.someguyssoftware.gottschcore.mod.IMod; @@ -14,7 +16,16 @@ import com.someguyssoftware.treasure2.registry.ChestRegistry; import com.someguyssoftware.treasure2.worldgen.ITreasureWorldGenerator; +import net.minecraft.util.ResourceLocation; import net.minecraft.world.WorldServer; +import net.minecraft.world.storage.loot.LootEntry; +import net.minecraft.world.storage.loot.LootEntryTable; +import net.minecraft.world.storage.loot.LootPool; +import net.minecraft.world.storage.loot.LootTable; +import net.minecraft.world.storage.loot.LootTableList; +import net.minecraft.world.storage.loot.RandomValueRange; +import net.minecraft.world.storage.loot.conditions.LootCondition; +import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -27,7 +38,7 @@ public class WorldEventHandler { // reference to the mod. private IMod mod; - + /** * */ @@ -38,44 +49,56 @@ public WorldEventHandler(IMod mod) { @SubscribeEvent(priority = EventPriority.HIGH) public void onWorldLoad(WorldEvent.Load event) { Treasure.logger.debug("In world load event for dimension {}", event.getWorld().provider.getDimension()); - + /* * On load of dimension 0 (overworld), initialize the loot table's context and other static loot tables */ if (WorldInfo.isServerSide(event.getWorld()) && event.getWorld().provider.getDimension() == 0) { -// Treasure.logger.debug("server event"); + // Treasure.logger.debug("server event"); WorldServer world = (WorldServer) event.getWorld(); // called once to initiate world-level properties in the LootTableMaster Treasure.LOOT_TABLE_MASTER.init(world); - + // register mod's loot tables TreasureLootTableRegistry.register(mod.getId()); - + // register files with their respective managers Treasure.META_MANAGER.register(getMod().getId()); Treasure.TEMPLATE_MANAGER.register(getMod().getId()); Treasure.DECAY_MANAGER.register(getMod().getId()); - + /* * clear the current World Gens values and reload */ for (Entry worldGenEntry : Treasure.WORLD_GENERATORS.entrySet()) { worldGenEntry.getValue().init(); } - + /* * un-load the chest registry */ Treasure.logger.debug("Chest registry size BEFORE cleaning -> {}", ChestRegistry.getInstance().getValues().size()); ChestRegistry.getInstance().clear(); Treasure.logger.debug("Chest registry size AFTER cleaning -> {}", ChestRegistry.getInstance().getValues().size()); - + GenDataPersistence.get(world); Treasure.logger.debug("Chest registry size after world event load -> {}", ChestRegistry.getInstance().getValues().size()); } } - + + @SubscribeEvent + public void lootLoad(LootTableLoadEvent event) { + if (event.getName().toString().equals(LootTableList.CHESTS_SIMPLE_DUNGEON.toString()/*"minecraft:chests/simple_dungeon"*/)) { + + // load a loot table + ResourceLocation location = new ResourceLocation(Treasure.MODID, "pools/treasure/scarce"); + LootEntry entry = new LootEntryTable(location, 1, 1, new LootCondition[] {}, "treasure"); + LootPool pool = new LootPool(new LootEntry[] {entry}, new LootCondition[] {}, new RandomValueRange(1), new RandomValueRange(1), "treasure"); + event.getTable().addPool(pool); + } + } + /** * @return the mod */ diff --git a/src/main/resources/loot_tables/treasure2/pools/treasure/rare.json b/src/main/resources/loot_tables/treasure2/pools/treasure/rare.json index 907850337..f78c59722 100644 --- a/src/main/resources/loot_tables/treasure2/pools/treasure/rare.json +++ b/src/main/resources/loot_tables/treasure2/pools/treasure/rare.json @@ -10,7 +10,7 @@ "type": "item", "name": "treasure2:lightning_key", "weight": 10 - }, + }, { "entryName": "metallurgists_key", "type": "item", @@ -168,12 +168,6 @@ ] } ] - }, - { - "name": "rare_charms", - "rolls": 1, - "entries": [ - ] } ] } diff --git a/src/main/resources/loot_tables/treasure2/pools/treasure/uncommon.json b/src/main/resources/loot_tables/treasure2/pools/treasure/uncommon.json index f195c8087..8448db990 100644 --- a/src/main/resources/loot_tables/treasure2/pools/treasure/uncommon.json +++ b/src/main/resources/loot_tables/treasure2/pools/treasure/uncommon.json @@ -18,7 +18,7 @@ "max": 2 } } - ] + ] }, { "entryName": "stone_key", @@ -33,7 +33,7 @@ "max": 2 } } - ] + ] }, { "entryName": "pilferers_lock_pick", @@ -63,7 +63,7 @@ "max": 2 } } - ] + ] }, { "entryName": "thiefs_lock_pick", @@ -78,7 +78,7 @@ "max": 2 } } - ] + ] }, { "entryName": "ember_key", @@ -91,7 +91,7 @@ "type": "item", "name": "treasure2:leaf_key", "weight": 15 - }, + }, { "entryName": "gold_key", "type": "item", @@ -103,7 +103,7 @@ "type": "item", "name": "treasure2:spider_key", "weight": 10 - } + } ] }, { @@ -141,12 +141,6 @@ ] } ] - }, - { - "name": "uncommon_charms", - "rolls": 1, - "entries": [ - ] - } + } ] -} \ No newline at end of file +} diff --git a/update.json b/update.json index d5126b503..2786ff3fc 100644 --- a/update.json +++ b/update.json @@ -43,6 +43,6 @@ "1.13.0": "Added Ember Lock and Key.\nAdded Leaf Lock and Key.\nAdded Lightning Key.\nAdded ability to merge Keys on anvil.\nAdded Volcano Pit.\nAdded Blackstone Block (from mc1.16).\nIncreased Key success rate to 95%.\nIncreased Pilferer's Lock Pick success rate to 32%.\nIncreased Thief's Lock Pick success rate to 48%.\nUpdated loot tables to include Ember, Leaf and Lightning Keys.\nUpdated Chinese lang file.\n", "1.13.1": "Fixed the large number of TileEntities created because of Gravestones. (Note, this is only for newly generated chunks).\nReduced likihood of Bound Soul gravestone to 30%.\nFixed the versioning.\n", "1.13.2": "Fixed duplication bug on Harvesting Charms.\nFixed some loot tables with item spelling errors.Tweaked the epic charmed loot table.", - "1.14.0": "Revamped Loot Table management system - uses vanilla with tweaks.\nAdded Cardboard Box, Milk Crate and Crystal Skull chests.\nAdded -facing, -chest, -locked and -sealed arguments to SpawnChestCommand.\nAdded Enchantment glow to Charmed Coins/Gems and updated images.\nUpdated to Forge 1.12.2-14.23.5.2854.\n" + "1.14.0": "Revamped Loot Table management system - uses vanilla with tweaks.\nAdded Cardboard Box, Milk Crate and Crystal Skull chests.\nRegistered treasure loot tables with vanilla dungeon chests.\nAdded -facing, -chest, -locked and -sealed arguments to SpawnChestCommand.\nAdded Enchantment glow to Charmed Coins/Gems and updated images.\nUpdated to Forge 1.12.2-14.23.5.2854.\n" } }