Add engineer chest dungeon loot, fix some stuff

This commit is contained in:
Ellpeck 2016-11-21 18:56:28 +01:00
parent 9708a9a767
commit de2b6a8bef
4 changed files with 45 additions and 20 deletions

View file

@ -19,6 +19,7 @@ import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager; import de.ellpeck.actuallyadditions.mod.gen.village.InitVillager;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
import de.ellpeck.actuallyadditions.mod.tile.*; import de.ellpeck.actuallyadditions.mod.tile.*;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -41,7 +42,6 @@ import net.minecraft.world.gen.structure.template.Template;
import net.minecraft.world.gen.structure.template.TemplateManager; import net.minecraft.world.gen.structure.template.TemplateManager;
import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.registry.VillagerRegistry;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
import java.util.List; import java.util.List;
@ -83,7 +83,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR); this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR);
this.spawnActualHouse(world, sbb); this.spawnActualHouse(world, sbb);
this.fillHouse(world); this.fillHouse(world, sbb);
for(int i = 0; i < X_SIZE; i++){ for(int i = 0; i < X_SIZE; i++){
for(int j = 0; j < Z_SIZE; j++){ for(int j = 0; j < Z_SIZE; j++){
@ -101,21 +101,21 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false); this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
} }
private void fillHouse(World world){ private void fillHouse(World world, StructureBoundingBox sbb){
if(world.rand.nextBoolean()){ if(world.rand.nextBoolean()){
TileEntity compost = this.getTileAtPos(world, 6, 1, 2); TileEntity compost = this.getTileAtPos(world, 6, 1, 2, sbb);
if(compost instanceof TileEntityCompost){ if(compost instanceof TileEntityCompost){
((TileEntityCompost)compost).setInventorySlotContents(0, new ItemStack(InitItems.itemFertilizer, 10)); ((TileEntityCompost)compost).setInventorySlotContents(0, new ItemStack(InitItems.itemFertilizer, 10));
} }
} }
TileEntity ferment = this.getTileAtPos(world, 11, 1, 0); TileEntity ferment = this.getTileAtPos(world, 11, 1, 0, sbb);
if(ferment instanceof TileEntityFermentingBarrel){ if(ferment instanceof TileEntityFermentingBarrel){
TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel)ferment; TileEntityFermentingBarrel tile = (TileEntityFermentingBarrel)ferment;
tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500)+200)); tile.canolaTank.setFluid(new FluidStack(InitFluids.fluidCanolaOil, world.rand.nextInt(1500)+200));
} }
TileEntity coffee = this.getTileAtPos(world, 4, 2, 6); TileEntity coffee = this.getTileAtPos(world, 4, 2, 6, sbb);
if(coffee instanceof TileEntityCoffeeMachine){ if(coffee instanceof TileEntityCoffeeMachine){
TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine)coffee; TileEntityCoffeeMachine tile = (TileEntityCoffeeMachine)coffee;
tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000)+500)); tile.tank.setFluid(new FluidStack(FluidRegistry.WATER, world.rand.nextInt(3000)+500));
@ -123,36 +123,37 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2)); tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
} }
TileEntity press = this.getTileAtPos(world, 2, 1, 5); TileEntity press = this.getTileAtPos(world, 2, 1, 5, sbb);
if(press instanceof TileEntityCanolaPress){ if(press instanceof TileEntityCanolaPress){
TileEntityCanolaPress tile = (TileEntityCanolaPress)press; TileEntityCanolaPress tile = (TileEntityCanolaPress)press;
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3)); tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3));
tile.setInventorySlotContents(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal())); tile.setInventorySlotContents(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal()));
} }
TileEntity crusher = this.getTileAtPos(world, 2, 1, 6); TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
if(crusher instanceof TileEntityGrinder){ if(crusher instanceof TileEntityGrinder){
TileEntityGrinder tile = (TileEntityGrinder)crusher; TileEntityGrinder tile = (TileEntityGrinder)crusher;
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2)); tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
if(world.rand.nextBoolean()){ if(world.rand.nextFloat() >= 0.25F){
tile.setInventorySlotContents(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal())); tile.setInventorySlotContents(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
} }
} }
TileEntity coal = this.getTileAtPos(world, 5, 5, 6); TileEntity coal = this.getTileAtPos(world, 5, 5, 6, sbb);
if(coal instanceof TileEntityCoalGenerator){ if(coal instanceof TileEntityCoalGenerator){
((TileEntityCoalGenerator)coal).setInventorySlotContents(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1)); ((TileEntityCoalGenerator)coal).setInventorySlotContents(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1));
} }
TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6); TileEntity firstRelay = this.getTileAtPos(world, 6, 5, 6, sbb);
TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3); TileEntity secondRelay = this.getTileAtPos(world, 8, 5, 3, sbb);
if(firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy){ if(firstRelay instanceof TileEntityLaserRelayEnergy && secondRelay instanceof TileEntityLaserRelayEnergy){
ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world); ActuallyAdditionsAPI.connectionHandler.addConnection(firstRelay.getPos(), secondRelay.getPos(), LaserType.ENERGY, world);
} }
BlockPos lamp = new BlockPos(this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6));
int meta = world.rand.nextInt(TheColoredLampColors.values().length); int meta = world.rand.nextInt(TheColoredLampColors.values().length);
world.setBlockState(lamp, InitBlocks.blockColoredLamp.getStateFromMeta(meta)); this.setBlockState(world, InitBlocks.blockColoredLampOn.getStateFromMeta(meta), 8, 1, 6, sbb);
VillageComponentJamHouse.generateCrate(world, sbb, this.getXWithOffset(6, 4), this.getYWithOffset(4), this.getZWithOffset(6, 4), DungeonLoot.ENGINEER_HOUSE);
} }
private void spawnActualHouse(World world, StructureBoundingBox sbb){ private void spawnActualHouse(World world, StructureBoundingBox sbb){
@ -190,9 +191,14 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
} }
} }
private TileEntity getTileAtPos(World world, int x, int y, int z){ private TileEntity getTileAtPos(World world, int x, int y, int z, StructureBoundingBox sbb){
BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
return world.getTileEntity(pos); if(sbb.isVecInside(pos)){
return world.getTileEntity(pos);
}
else{
return null;
}
} }
@Override @Override

View file

@ -190,7 +190,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); this.fillWithBlocks(world, sbb, 3, 1, 4, 4, 1, 6, Blocks.CARPET.getStateFromMeta(10), Blocks.CARPET.getStateFromMeta(10), false);
//Loot Chest //Loot Chest
this.generateCrate(world, this.boundingBox, 8, 1, 6, DungeonLoot.JAM_HOUSE); generateCrate(world, this.boundingBox, this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6), DungeonLoot.JAM_HOUSE);
//Torches //Torches
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 6, 2, 0, sbb); this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.SOUTH), 6, 2, 0, sbb);
@ -208,10 +208,10 @@ public class VillageComponentJamHouse extends StructureVillagePieces.House1{
return InitVillager.jamProfession; return InitVillager.jamProfession;
} }
protected boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot){ public static boolean generateCrate(World world, StructureBoundingBox box, int x, int y, int z, ResourceLocation loot){
BlockPos pos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); BlockPos pos = new BlockPos(x, y, z);
if(box.isVecInside(pos) && (world.getBlockState(pos).getBlock() != InitBlocks.blockGiantChest)){ if(box.isVecInside(pos)){
world.setBlockState(pos, InitBlocks.blockGiantChest.getDefaultState(), 2); world.setBlockState(pos, InitBlocks.blockGiantChest.getDefaultState(), 2);
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.misc; package de.ellpeck.actuallyadditions.mod.misc;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals; import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
@ -33,10 +34,12 @@ public class DungeonLoot{
public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "jam_house"); public static final ResourceLocation JAM_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "jam_house");
public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ModUtil.MOD_ID, "lush_caves"); public static final ResourceLocation LUSH_CAVES = new ResourceLocation(ModUtil.MOD_ID, "lush_caves");
public static final ResourceLocation ENGINEER_HOUSE = new ResourceLocation(ModUtil.MOD_ID, "engineer_house");
public DungeonLoot(){ public DungeonLoot(){
LootTableList.register(JAM_HOUSE); LootTableList.register(JAM_HOUSE);
LootTableList.register(LUSH_CAVES); LootTableList.register(LUSH_CAVES);
LootTableList.register(ENGINEER_HOUSE);
} }
@SubscribeEvent @SubscribeEvent
@ -131,6 +134,21 @@ public class DungeonLoot{
pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i)); pool.addEntry(new LootEntryItem(armor[i], 50, 0, new LootFunction[]{damage}, noCondition, ModUtil.MOD_ID+":armor"+i));
} }
} }
else if(ENGINEER_HOUSE.equals(event.getName())){
addBook = true;
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()));
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 60, 0, new LootFunction[]{woodCaseAmount, woodCaseDamage}, noCondition, ModUtil.MOD_ID+":woodenCase"));
LootFunction ironCaseAmount = new SetCount(noCondition, new RandomValueRange(1, 3));
LootFunction ironCaseDamage = new SetMetadata(noCondition, new RandomValueRange(TheMiscBlocks.IRON_CASING.ordinal()));
pool.addEntry(new LootEntryItem(Item.getItemFromBlock(InitBlocks.blockMisc), 40, 0, new LootFunction[]{ironCaseAmount, ironCaseDamage}, noCondition, ModUtil.MOD_ID+":ironCase"));
}
if(addCrystals){ if(addCrystals){
LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length-1)); LootFunction damage = new SetMetadata(noCondition, new RandomValueRange(0, TheCrystals.values().length-1));