diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentJamHouse.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentJamHouse.java index 2ce2f0e6e..87fc0c632 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentJamHouse.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/VillageComponentJamHouse.java @@ -10,10 +10,14 @@ package de.ellpeck.actuallyadditions.mod.gen; +import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import net.minecraft.block.*; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.gen.structure.StructureComponent; @@ -182,12 +186,7 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{ this.fillWithBlocks(world, sbb, 3, 1, 4, 4, 1, 6, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false); //Loot Chest - this.setBlockState(world, Blocks.CHEST.getDefaultState(), 8, 1, 6, sbb); - //TileEntity chest = world.getTileEntity(new BlockPos(this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6))); - //TODO Chest content - /*if(chest != null && chest instanceof TileEntityChest){ - WeightedRandomChestContent.generateChestContents(rand, ChestGenHooks.getItems(InitVillager.JAM_HOUSE_CHEST_NAME, rand), (TileEntityChest)chest, ChestGenHooks.getCount(InitVillager.JAM_HOUSE_CHEST_NAME, rand)); - }*/ + this.generateChest(world, this.boundingBox, rand, 8, 1, 6, DungeonLoot.JAM_HOUSE); //Torches this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 6, 2, 0, sbb); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java index 67151bcd0..2c7310e87 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/gen/WorldGenLushCaves.java @@ -10,13 +10,21 @@ package de.ellpeck.actuallyadditions.mod.gen; +import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; +import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot; import net.minecraft.block.Block; +import net.minecraft.block.BlockLeaves; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; +import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; -import net.minecraft.world.gen.feature.*; +import net.minecraft.world.gen.feature.WorldGenAbstractTree; +import net.minecraft.world.gen.feature.WorldGenBigTree; +import net.minecraft.world.gen.feature.WorldGenShrub; +import net.minecraft.world.gen.feature.WorldGenTrees; import net.minecraft.world.gen.structure.StructureBoundingBox; import net.minecraft.world.storage.loot.ILootContainer; @@ -55,10 +63,7 @@ public class WorldGenLushCaves{ for(double z = -radius; z < radius; z++){ if(rand.nextDouble() >= 0.5D){ BlockPos pos = center.add(x, y, z); - if(!box.isVecInside(pos)) { - continue; - } - if(world.getBlockState(pos).getBlock() == Blocks.GRASS){ + if(box.isVecInside(pos) && world.getBlockState(pos).getBlock() == Blocks.GRASS){ possiblePoses.add(pos); } } @@ -67,12 +72,44 @@ public class WorldGenLushCaves{ } if(!possiblePoses.isEmpty()){ + boolean chestGenDone = false; + for(int i = 0; i <= amount; i++){ Collections.shuffle(possiblePoses); BlockPos pos = possiblePoses.get(0); if(rand.nextBoolean()){ - WorldGenAbstractTree trees = rand.nextBoolean() ? (rand.nextBoolean() ? new WorldGenBigTree(false) : new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState())) : new WorldGenTrees(false); + boolean genChest = false; + + WorldGenAbstractTree trees; + if(rand.nextBoolean()){ + if(rand.nextBoolean()){ + trees = new WorldGenBigTree(false); + } + else{ + trees = new WorldGenShrub(Blocks.LOG.getDefaultState(), Blocks.LEAVES.getDefaultState()); + genChest = true; + } + } + else{ + trees = new WorldGenTrees(false); + } trees.generate(world, rand, pos.up()); + + if(!chestGenDone && genChest){ + BlockPos chestPos = pos.add(MathHelper.getRandomIntegerInRange(rand, -2, 2), MathHelper.getRandomIntegerInRange(rand, 3, 8), MathHelper.getRandomIntegerInRange(rand, -2, 2)); + + IBlockState state = world.getBlockState(chestPos); + if(state != null && state.getBlock().isLeaves(state, world, chestPos)){ + world.setBlockState(chestPos, Blocks.CHEST.getDefaultState()); + + TileEntity chest = world.getTileEntity(chestPos); + if(chest instanceof TileEntityChest){ + ((TileEntityChest)chest).setLootTable(DungeonLoot.LUSH_CAVES, rand.nextLong()); + } + } + + chestGenDone = true; + } } else{ Blocks.GRASS.grow(world, rand, pos, world.getBlockState(pos)); @@ -100,15 +137,14 @@ public class WorldGenLushCaves{ for(double z = -radius; z < radius; z++){ for(double y = -radius; y <= -3; y++){ BlockPos pos = center.add(x, y, z); - if(!boundingBox.isVecInside(pos)) { - continue; - } - IBlockState state = world.getBlockState(pos); - BlockPos posUp = pos.up(); - IBlockState stateUp = world.getBlockState(posUp); - if(!this.checkIndestructable(world, pos) && !this.checkIndestructable(world, posUp)){ - if(!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)){ - world.setBlockState(pos, Blocks.GRASS.getDefaultState()); + if(boundingBox.isVecInside(pos)){ + IBlockState state = world.getBlockState(pos); + BlockPos posUp = pos.up(); + IBlockState stateUp = world.getBlockState(posUp); + if(!this.checkIndestructable(world, pos) && !this.checkIndestructable(world, posUp)){ + if(!state.getBlock().isAir(state, world, pos) && stateUp.getBlock().isAir(stateUp, world, posUp)){ + world.setBlockState(pos, Blocks.GRASS.getDefaultState()); + } } } } @@ -127,7 +163,7 @@ public class WorldGenLushCaves{ if(state != null){ Block block = state.getBlock(); //check if it's tree or grass that is generated here - if(block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS) { + if(block == Blocks.LOG || block == Blocks.LEAVES || block == Blocks.TALLGRASS){ return true; } if(block != null && (block.isAir(state, world, pos) || block.getHarvestLevel(state) >= 0F)){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java index 9129e0f5e..56b1864f2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/misc/DungeonLoot.java @@ -14,25 +14,43 @@ import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; +import de.ellpeck.actuallyadditions.mod.items.metalists.TheJams; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.util.ModUtil; +import net.minecraft.init.Items; 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.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.storage.loot.*; 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; import net.minecraft.world.storage.loot.functions.SetMetadata; import net.minecraftforge.event.LootTableLoadEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class DungeonLoot{ + public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "jamHouse"); + public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ModUtil.MOD_ID, "lushCaves"); + + public DungeonLoot(){ + LootTableList.register(JAM_HOUSE); + LootTableList.register(LUSH_CAVES); + } + @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); + } + boolean addCrystals = false; boolean addDrillCore = false; boolean addQuartz = false; @@ -51,7 +69,6 @@ public class DungeonLoot{ 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())){ @@ -61,41 +78,70 @@ public class DungeonLoot{ else if(LootTableList.CHESTS_IGLOO_CHEST.equals(event.getName())){ addBatWings = true; } + else if(LootTableList.CHESTS_DESERT_PYRAMID.equals(event.getName())){ + addDrillCore = true; + addBatWings = 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(1, 8)); + pool.addEntry(new LootEntryItem(InitItems.itemJams, 2, 0, new LootFunction[]{jamDamage, jamAmount}, noCondition, ModUtil.MOD_ID+":jams")); - LootPool pool = event.getTable().getPool("main"); - if(pool != null){ - LootCondition[] noCondition = new LootCondition[0]; + LootFunction glassAmount = new SetCount(noCondition, new RandomValueRange(1, 5)); + 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; - 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(Items.BOOK, 90, 0, new LootFunction[0], noCondition, ModUtil.MOD_ID+":book")); - 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")); + LootFunction bonesAmount = new SetCount(noCondition, new RandomValueRange(1, 12)); + pool.addEntry(new LootEntryItem(Items.BONE, 150, 0, new LootFunction[]{bonesAmount}, noCondition, ModUtil.MOD_ID+":bones")); + + 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)); } - 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")); + 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], 70, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i)); } + } - 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(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}; - 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")); - } + 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(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")); - } + 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")); + } + + 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")); } } } diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index e9590db51..6e137f0da 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -984,7 +984,7 @@ booklet.actuallyadditions.chapter.banners.name=Additional Banners booklet.actuallyadditions.chapter.banners.text.1=For special items in Actually Additions, there is also special Banner patterns. All of these just require the item next to the banner in the crafting grid with, optionally, a color. You can also combine them with a Shield like normal. The items that have a banner pattern are: The Actually Additions Manual The Phantom Connector The Leaf Blower (not the advanced version) The Drill (only the white one works due to the way banners work) booklet.actuallyadditions.chapter.lushCaves.name=Lush Caves -booklet.actuallyadditions.chapter.lushCaves.text.1=If you have ever done any Cave exploration, you will have probably noticed some caves that have trees and grass inside of them. These can be found at any height underground all over the world, and they can be very valuable when needing wood for torches and tools at some point. If you didn't ever see one before, look on the next page for a picture! +booklet.actuallyadditions.chapter.lushCaves.text.1=If you have ever done any Cave exploration, you will have probably noticed some caves that have trees and grass inside of them. These can be found at any height underground all over the world, and they can be very valuable when needing wood for torches and tools at some point. Sometimes, there might also be some treasure hidden in the trees! If you didn't ever see one before, look on the next page for a picture! booklet.actuallyadditions.chapter.waterBowl.name=Bowl of Water booklet.actuallyadditions.chapter.waterBowl.text.1=The Bowl of Water can be obtained by right-cliking a bowl on water anywhere in the world. When the Bowl of Water is then right-clicked onto a block, the water will be placed, much like a Bucket. This can be used, for example, for early game farms. diff --git a/src/main/resources/assets/actuallyadditions/loot_tables/jamHouse.json b/src/main/resources/assets/actuallyadditions/loot_tables/jamHouse.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/loot_tables/jamHouse.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/src/main/resources/assets/actuallyadditions/loot_tables/lushCaves.json b/src/main/resources/assets/actuallyadditions/loot_tables/lushCaves.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/src/main/resources/assets/actuallyadditions/loot_tables/lushCaves.json @@ -0,0 +1 @@ +{} \ No newline at end of file