mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-12-22 19:39:24 +01:00
Added back jam house loot and added lush caves loot
This commit is contained in:
parent
2afc7ba124
commit
020adc97b2
6 changed files with 137 additions and 54 deletions
|
@ -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);
|
||||
|
|
|
@ -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)){
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -984,7 +984,7 @@ booklet.actuallyadditions.chapter.banners.name=Additional Banners
|
|||
booklet.actuallyadditions.chapter.banners.text.1=For <imp>special items<r> in <imp>Actually Additions<r>, there is also special <item>Banner<r> patterns. All of these just require the <imp>item next to the banner<r> in the crafting grid with, optionally, a <imp>color<r>. You can also combine them with a <item>Shield<r> like normal. <n>The items that have a banner pattern are: <n>The <item>Actually Additions Manual<r> <n>The <item>Phantom Connector<r> <n>The <item>Leaf Blower<r> (not the advanced version) <n>The <item>Drill<r> (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 <imp>Cave exploration<r>, you will have probably noticed some <imp>caves<r> that have <imp>trees and grass<r> inside of them. <n>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. <n><n>If you didn't ever see one before, look on the <imp>next page<r> for a <imp>picture<r>!
|
||||
booklet.actuallyadditions.chapter.lushCaves.text.1=If you have ever done any <imp>Cave exploration<r>, you will have probably noticed some <imp>caves<r> that have <imp>trees and grass<r> inside of them. <n>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 <imp>treasure hidden in the trees<r>! <n><n>If you didn't ever see one before, look on the <imp>next page<r> for a <imp>picture<r>!
|
||||
|
||||
booklet.actuallyadditions.chapter.waterBowl.name=Bowl of Water
|
||||
booklet.actuallyadditions.chapter.waterBowl.text.1=The <item>Bowl of Water<r> can be obtained by <imp>right-cliking a bowl on water<r> anywhere in the world. When the <item>Bowl of Water<r> is then right-clicked onto a block, the water will be placed, much like a <item>Bucket<r>. <n><n>This can be used, for example, for early game farms.
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{}
|
|
@ -0,0 +1 @@
|
|||
{}
|
Loading…
Reference in a new issue