2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("VillageComponentJamHouse.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2016-05-16 22:54:42 +02:00
|
|
|
* © 2015-2016 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.gen;
|
2015-04-06 15:51:59 +02:00
|
|
|
|
2016-05-07 12:55:59 +02:00
|
|
|
import net.minecraft.block.*;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
|
|
|
import net.minecraft.world.gen.structure.StructureComponent;
|
2015-04-06 15:51:59 +02:00
|
|
|
import net.minecraft.world.gen.structure.StructureVillagePieces;
|
|
|
|
|
2016-05-07 12:55:59 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2015-04-06 15:51:59 +02:00
|
|
|
public class VillageComponentJamHouse extends StructureVillagePieces.House1{
|
|
|
|
|
2016-06-17 23:50:38 +02:00
|
|
|
private static final int X_SIZE = 11;
|
|
|
|
private static final int Y_SIZE = 8;
|
|
|
|
private static final int Z_SIZE = 12;
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
private int averageGroundLevel = -1;
|
|
|
|
|
|
|
|
public VillageComponentJamHouse(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-07 12:55:59 +02:00
|
|
|
public VillageComponentJamHouse(StructureBoundingBox boundingBox, EnumFacing par5){
|
|
|
|
this.setCoordBaseMode(par5);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.boundingBox = boundingBox;
|
|
|
|
}
|
|
|
|
|
2016-05-07 12:55:59 +02:00
|
|
|
public static VillageComponentJamHouse buildComponent(List pieces, int p1, int p2, int p3, EnumFacing p4){
|
2016-06-17 23:50:38 +02:00
|
|
|
StructureBoundingBox boundingBox = StructureBoundingBox.getComponentToAddBoundingBox(p1, p2, p3, 0, 0, 0, X_SIZE, Y_SIZE, Z_SIZE, p4);
|
2015-04-06 15:51:59 +02:00
|
|
|
return canVillageGoDeeper(boundingBox) && StructureComponent.findIntersecting(pieces, boundingBox) == null ? new VillageComponentJamHouse(boundingBox, p4) : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-05-29 23:49:35 +02:00
|
|
|
public boolean addComponentParts(World world, Random rand, StructureBoundingBox sbb){
|
2015-04-06 15:51:59 +02:00
|
|
|
if(this.averageGroundLevel < 0){
|
|
|
|
this.averageGroundLevel = this.getAverageGroundLevel(world, sbb);
|
2015-10-03 10:16:18 +02:00
|
|
|
if(this.averageGroundLevel < 0){
|
|
|
|
return true;
|
|
|
|
}
|
2016-06-17 23:50:38 +02:00
|
|
|
this.boundingBox.offset(0, this.averageGroundLevel-this.boundingBox.maxY+Y_SIZE-1, 0);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
2016-06-17 23:50:38 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 0, 0, 0, X_SIZE-1, Y_SIZE-1, Z_SIZE-1, Blocks.AIR);
|
2015-04-06 15:51:59 +02:00
|
|
|
this.spawnActualHouse(world, rand, sbb);
|
|
|
|
|
2016-06-17 23:50:38 +02:00
|
|
|
for(int i = 0; i < X_SIZE; i++){
|
|
|
|
for(int j = 0; j < Z_SIZE; j++){
|
|
|
|
this.clearCurrentPositionBlocksUpwards(world, i, Y_SIZE, j, sbb);
|
2016-05-07 12:55:59 +02:00
|
|
|
this.replaceAirAndLiquidDownwards(world, Blocks.COBBLESTONE.getDefaultState(), i, -1, j, sbb);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.spawnVillagers(world, sbb, 3, 1, 3, 1);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-03 10:19:40 +02:00
|
|
|
public void fillWithBlocks(World world, StructureBoundingBox sbb, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block){
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, minX, minY, minZ, maxX, maxY, maxZ, block.getDefaultState(), block.getDefaultState(), false);
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
|
|
|
|
2015-04-06 15:51:59 +02:00
|
|
|
public void spawnActualHouse(World world, Random rand, StructureBoundingBox sbb){
|
|
|
|
//Base
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 1, 0, 8, 9, 0, 10, Blocks.GRASS);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 0, 0, 1, 0, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 2, 0, 0, 4, 0, 1, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 9, 0, 0, 10, 0, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 0, 0, 8, 0, 1, Blocks.COBBLESTONE);
|
|
|
|
this.setBlockState(world, Blocks.STONE_STAIRS.getStateFromMeta(3), 5, 0, 0, sbb);
|
|
|
|
this.fillWithBlocks(world, sbb, 2, 0, 7, 3, 0, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 0, 7, 8, 0, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 10, 0, 8, 10, 0, 11, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 0, 8, 0, 0, 11, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 0, 11, 10, 0, 11, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 2, 0, 2, 8, 0, 6, Blocks.PLANKS.getStateFromMeta(1), Blocks.PLANKS.getStateFromMeta(1), false);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 5, 0, 1, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(1), 4, 0, 7, sbb);
|
|
|
|
|
|
|
|
//Garden FENCE
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 1, 11, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 1, 11, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 1, 1, 11, 9, 1, 11, Blocks.OAK_FENCE);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Side Walls
|
|
|
|
for(int i = 0; i < 2; i++){
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 1, 1, 1+i*8, 1, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 1, 1, 1+i*8, 4, 1, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 1, 7, 1+i*8, 4, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 4, 2, 1+i*8, 5, 6, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 3, 2, 1+i*8, 3, 6, Blocks.PLANKS);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1+i*8, 2, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 1+i*8, 2, 6, sbb);
|
|
|
|
this.fillWithBlocks(world, sbb, 1+i*8, 2, 3, 1+i*8, 2, 5, Blocks.GLASS_PANE);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Front Wall
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 7, 1, 1, 8, 4, 1, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 2, 1, 1, 3, 4, 1, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 4, 4, 1, 7, 4, 1, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 1, 1, 6, 3, 1, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 4, 1, 1, 4, 3, 1, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 3, 1, 5, 3, 1, Blocks.PLANKS);
|
|
|
|
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState(), 5, 1, 1, sbb);
|
|
|
|
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 5, 2, 1, sbb);
|
|
|
|
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Back Wall
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 2, 1, 7, 2, 4, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 3, 1, 7, 3, 3, 7, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 4, 3, 7, 8, 3, 7, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 3, 4, 7, 8, 4, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 1, 7, 5, 2, 7, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 1, 7, 8, 1, 7, Blocks.COBBLESTONE);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 2, 7, 7, 2, 7, Blocks.GLASS_PANE);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getStateFromMeta(0), 8, 2, 7, sbb);
|
|
|
|
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, EnumFacing.SOUTH), 4, 1, 7, sbb);
|
|
|
|
this.setBlockState(world, Blocks.SPRUCE_DOOR.getDefaultState().withProperty(BlockDoor.FACING, EnumFacing.SOUTH).withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 4, 2, 7, sbb);
|
|
|
|
|
|
|
|
//FENCE Supports
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 1, 8, 0, 3, 8, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 10, 1, 8, 10, 3, 8, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 1, 0, 0, 3, 0, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 10, 1, 0, 10, 3, 0, Blocks.OAK_FENCE);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Roof
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 1, 6, 3, 9, 6, 5, Blocks.PLANKS);
|
|
|
|
IBlockState stairSouth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.SOUTH);
|
|
|
|
IBlockState stairNorth = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 4, 0, 10, 4, 0, stairNorth, stairNorth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 5, 1, 10, 5, 1, stairNorth, stairNorth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 6, 2, 10, 6, 2, stairNorth, stairNorth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 4, 8, 10, 4, 8, stairSouth, stairSouth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 5, 7, 10, 5, 7, stairSouth, stairSouth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 6, 6, 10, 6, 6, stairSouth, stairSouth, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 7, 3, 10, 7, 5, Blocks.WOODEN_SLAB);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Roof Gadgets
|
2016-05-07 12:55:59 +02:00
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 1, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 1, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 4, 7, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 0, 5, 6, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 4, 7, sbb);
|
|
|
|
this.setBlockState(world, Blocks.PLANKS.getDefaultState(), 10, 5, 6, sbb);
|
|
|
|
this.fillWithBlocks(world, sbb, 0, 6, 3, 0, 6, 5, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 10, 6, 3, 10, 6, 5, Blocks.PLANKS);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Counter
|
2016-05-07 12:55:59 +02:00
|
|
|
this.fillWithBlocks(world, sbb, 6, 3, 2, 6, 3, 4, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 3, 4, 5, 3, 6, Blocks.WOODEN_SLAB.getStateFromMeta(8), Blocks.WOODEN_SLAB.getStateFromMeta(8), false);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 1, 2, 6, 1, 4, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 1, 4, 5, 1, 5, Blocks.PLANKS);
|
|
|
|
this.fillWithBlocks(world, sbb, 6, 4, 2, 6, 5, 2, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 4, 4, 5, 5, 4, Blocks.OAK_FENCE);
|
|
|
|
this.fillWithBlocks(world, sbb, 5, 4, 6, 5, 5, 6, Blocks.OAK_FENCE);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Decoration
|
2016-05-07 12:55:59 +02:00
|
|
|
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 8, 1, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 8, 2, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.OAK_FENCE.getDefaultState(), 2, 1, 6, sbb);
|
|
|
|
this.setBlockState(world, Blocks.LEAVES.getDefaultState().withProperty(BlockLeaves.DECAYABLE, false), 2, 2, 6, sbb);
|
|
|
|
IBlockState stairWest = Blocks.OAK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.WEST);
|
|
|
|
this.fillWithBlocks(world, sbb, 2, 1, 3, 2, 1, 5, stairWest, stairWest, false);
|
|
|
|
this.fillWithBlocks(world, sbb, 3, 1, 2, 5, 1, 3, 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);
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Loot Chest
|
2016-05-07 12:55:59 +02:00
|
|
|
this.setBlockState(world, Blocks.CHEST.getDefaultState(), 8, 1, 6, sbb);
|
2016-05-19 20:05:12 +02:00
|
|
|
//TileEntity chest = world.getTileEntity(new BlockPos(this.getXWithOffset(8, 6), this.getYWithOffset(1), this.getZWithOffset(8, 6)));
|
2016-05-07 12:55:59 +02:00
|
|
|
//TODO Chest content
|
|
|
|
/*if(chest != null && chest instanceof TileEntityChest){
|
2015-06-28 03:12:32 +02:00
|
|
|
WeightedRandomChestContent.generateChestContents(rand, ChestGenHooks.getItems(InitVillager.JAM_HOUSE_CHEST_NAME, rand), (TileEntityChest)chest, ChestGenHooks.getCount(InitVillager.JAM_HOUSE_CHEST_NAME, rand));
|
2016-05-07 12:55:59 +02:00
|
|
|
}*/
|
2015-04-06 15:51:59 +02:00
|
|
|
|
|
|
|
//Torches
|
2016-05-07 12:55:59 +02:00
|
|
|
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), 4, 2, 0, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 5, 2, 8, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.NORTH), 3, 2, 8, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.EAST), 2, 3, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.EAST), 2, 3, 6, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 2, sbb);
|
|
|
|
this.setBlockState(world, Blocks.TORCH.getDefaultState().withProperty(BlockTorch.FACING, EnumFacing.WEST), 8, 3, 6, sbb);
|
2015-04-06 15:51:59 +02:00
|
|
|
}
|
|
|
|
}
|