From 6daa914cada830a3fdff2b030bb99ed8989473ea Mon Sep 17 00:00:00 2001 From: Forstride Date: Mon, 8 Aug 2016 21:39:48 -0400 Subject: [PATCH] Allowed villages to generate in Coniferous Forests, Season Forests, and Woodlands. Added loot table modifier, started working on village material replacement --- .../overworld/BiomeGenConiferousForest.java | 2 +- .../overworld/BiomeGenSeasonalForest.java | 2 +- .../biome/overworld/BiomeGenWoodland.java | 2 +- .../common/handler/LootTableEventHandler.java | 45 +++++++++++++++++++ .../handler/VillageMaterialEventHandler.java | 42 +++++++++++++++++ .../common/init/ModHandlers.java | 2 + 6 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 src/main/java/biomesoplenty/common/handler/LootTableEventHandler.java create mode 100644 src/main/java/biomesoplenty/common/handler/VillageMaterialEventHandler.java diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenConiferousForest.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenConiferousForest.java index e67ac2ef7..4862426c8 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenConiferousForest.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenConiferousForest.java @@ -38,7 +38,7 @@ public class BiomeGenConiferousForest extends BOPBiome // terrain this.terrainSettings.avgHeight(68).heightVariation(10, 20); - this.canGenerateVillages = false; + this.canGenerateVillages = true; if (BOPBiomes.gravel_beach.isPresent()) { diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenSeasonalForest.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenSeasonalForest.java index 397086509..8070693ae 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenSeasonalForest.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenSeasonalForest.java @@ -37,7 +37,7 @@ public class BiomeGenSeasonalForest extends BOPBiome this.addWeight(BOPClimates.COOL_TEMPERATE, 7); - this.canGenerateVillages = false; + this.canGenerateVillages = true; if (BOPBiomes.gravel_beach.isPresent()) { diff --git a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWoodland.java b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWoodland.java index cd93e0bd2..16332a4b8 100644 --- a/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWoodland.java +++ b/src/main/java/biomesoplenty/common/biome/overworld/BiomeGenWoodland.java @@ -42,7 +42,7 @@ public class BiomeGenWoodland extends BOPBiome // terrain this.terrainSettings.avgHeight(64).heightVariation(6, 25); - this.canGenerateVillages = false; + this.canGenerateVillages = true; this.addWeight(BOPClimates.WARM_TEMPERATE, 10); diff --git a/src/main/java/biomesoplenty/common/handler/LootTableEventHandler.java b/src/main/java/biomesoplenty/common/handler/LootTableEventHandler.java new file mode 100644 index 000000000..48e955702 --- /dev/null +++ b/src/main/java/biomesoplenty/common/handler/LootTableEventHandler.java @@ -0,0 +1,45 @@ +package biomesoplenty.common.handler; + +import biomesoplenty.api.item.BOPItems; +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.conditions.LootCondition; +import net.minecraft.world.storage.loot.functions.LootFunction; +import net.minecraftforge.event.LootTableLoadEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class LootTableEventHandler +{ + @SubscribeEvent + public void onLootTableLoad(LootTableLoadEvent event) + { + if (event.getName().equals(LootTableList.CHESTS_NETHER_BRIDGE)) + { + LootPool main = event.getTable().getPool("main"); + if (main != null) + { + main.addEntry(new LootEntryItem(BOPItems.ash, 3, 6, new LootFunction[0], new LootCondition[0], "biomesoplenty:ash")); + main.addEntry(new LootEntryItem(BOPItems.fleshchunk, 5, 5, new LootFunction[0], new LootCondition[0], "biomesoplenty:fleshchunk")); + } + } + if (event.getName().equals(LootTableList.CHESTS_SPAWN_BONUS_CHEST)) + { + LootPool main = event.getTable().getPool("main"); + if (main != null) + { + main.addEntry(new LootEntryItem(BOPItems.pear, 4, 2, new LootFunction[0], new LootCondition[0], "biomesoplenty:pear")); + main.addEntry(new LootEntryItem(BOPItems.peach, 4, 2, new LootFunction[0], new LootCondition[0], "biomesoplenty:peach")); + } + } + if (event.getName().equals(LootTableList.CHESTS_VILLAGE_BLACKSMITH)) + { + LootPool main = event.getTable().getPool("main"); + if (main != null) + { + main.addEntry(new LootEntryItem(BOPItems.flippers, 2, 1, new LootFunction[0], new LootCondition[0], "biomesoplenty:flippers")); + main.addEntry(new LootEntryItem(BOPItems.wading_boots, 2, 1, new LootFunction[0], new LootCondition[0], "biomesoplenty:wading_boots")); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/biomesoplenty/common/handler/VillageMaterialEventHandler.java b/src/main/java/biomesoplenty/common/handler/VillageMaterialEventHandler.java new file mode 100644 index 000000000..26c6c8f75 --- /dev/null +++ b/src/main/java/biomesoplenty/common/handler/VillageMaterialEventHandler.java @@ -0,0 +1,42 @@ +package biomesoplenty.common.handler; + +import biomesoplenty.api.biome.BOPBiomes; +import biomesoplenty.common.block.BlockBOPLog; +import biomesoplenty.common.block.BlockBOPPlanks; +import biomesoplenty.common.block.BlockBOPWoodStairs; +import biomesoplenty.common.enums.BOPWoods; +import net.minecraft.block.BlockStairs; +import net.minecraft.init.Blocks; +import net.minecraftforge.event.terraingen.BiomeEvent; +import net.minecraftforge.fml.common.eventhandler.Event.Result; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; + +public class VillageMaterialEventHandler +{ + @SubscribeEvent + public void getVillageBlockID(BiomeEvent.GetVillageBlockID event) + { + //Coniferous Forest + if (event.getBiome() == BOPBiomes.coniferous_forest.get()) + { + //Planks + if (event.getOriginal().getBlock() == Blocks.PLANKS) + { + event.setReplacement(BlockBOPPlanks.paging.getVariantState(BOPWoods.FIR)); + event.setResult(Result.DENY); + } + //Logs + if (event.getOriginal().getBlock() == Blocks.LOG) + { + event.setReplacement(BlockBOPLog.paging.getVariantState(BOPWoods.FIR)); + event.setResult(Result.DENY); + } + if (event.getOriginal().getBlock() == Blocks.OAK_STAIRS) + { + int meta = BlockStairs.getStateId(event.getOriginal()); + event.setReplacement(BlockBOPWoodStairs.getBlock(BOPWoods.FIR).getStateFromMeta(meta)); + event.setResult(Result.DENY); + } + } + } +} diff --git a/src/main/java/biomesoplenty/common/init/ModHandlers.java b/src/main/java/biomesoplenty/common/init/ModHandlers.java index 04d09e534..f6ac2a589 100644 --- a/src/main/java/biomesoplenty/common/init/ModHandlers.java +++ b/src/main/java/biomesoplenty/common/init/ModHandlers.java @@ -27,6 +27,7 @@ public class ModHandlers DecorateBiomeEventHandler decorateBiomeHandler = new DecorateBiomeEventHandler(); MinecraftForge.EVENT_BUS.register(decorateBiomeHandler); MinecraftForge.TERRAIN_GEN_BUS.register(decorateBiomeHandler); + //MinecraftForge.TERRAIN_GEN_BUS.register(new VillageMaterialEventHandler()); MinecraftForge.ORE_GEN_BUS.register(decorateBiomeHandler); MinecraftForge.EVENT_BUS.register(new DyeEventHandler()); MinecraftForge.EVENT_BUS.register(new FlippersEventHandler()); @@ -38,6 +39,7 @@ public class ModHandlers MinecraftForge.EVENT_BUS.register(new AchievementEventHandler()); MinecraftForge.EVENT_BUS.register(new GrassPathEventHandler()); MinecraftForge.EVENT_BUS.register(new SheepEventHandler()); + MinecraftForge.EVENT_BUS.register(new LootTableEventHandler()); if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {