use of com.wuest.prefab.Config.Structures.HouseConfiguration in project MC-Prefab by Brian-Wuest.
the class StructureAlternateStart method AfterBuilding.
/**
* This method is used after the main building is build for any additional
* structures or modifications.
*
* @param configuration The structure configuration.
* @param world The current world.
* @param originalPos The original position clicked on.
* @param assumedNorth The assumed northern direction.
* @param player The player which initiated the construction.
*/
@Override
public void AfterBuilding(StructureConfiguration configuration, World world, BlockPos originalPos, EnumFacing assumedNorth, EntityPlayer player) {
HouseConfiguration houseConfig = (HouseConfiguration) configuration;
if (this.furnacePosition != null) {
// Fill the furnace.
TileEntity tileEntity = world.getTileEntity(this.furnacePosition);
if (tileEntity instanceof TileEntityFurnace) {
TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
furnaceTile.setInventorySlotContents(1, new ItemStack(Items.COAL, 20));
}
}
if (this.chestPosition != null && houseConfig.addChestContents) {
// Fill the chest.
StructureAlternateStart.FillChest(world, this.chestPosition, houseConfig, player);
}
if (this.trapDoorPosition != null && this.trapDoorPosition.getY() > 15 && houseConfig.addMineShaft) {
// Build the mineshaft.
StructureAlternateStart.PlaceMineShaft(world, this.trapDoorPosition.down(), houseConfig.houseFacing, false);
}
if (this.signPosition != null) {
TileEntity tileEntity = world.getTileEntity(this.signPosition);
if (tileEntity instanceof TileEntitySign) {
TileEntitySign signTile = (TileEntitySign) tileEntity;
signTile.signText[0] = new TextComponentString("This is");
if (player.getDisplayNameString().length() >= 15) {
signTile.signText[1] = new TextComponentString(player.getDisplayNameString());
} else {
signTile.signText[1] = new TextComponentString(player.getDisplayNameString() + "'s");
}
signTile.signText[2] = new TextComponentString("house!");
}
}
}
use of com.wuest.prefab.Config.Structures.HouseConfiguration in project MC-Prefab by Brian-Wuest.
the class StructureAlternateStart method CustomBlockProcessingHandled.
@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos, EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player) {
HouseConfiguration houseConfig = (HouseConfiguration) configuration;
if ((!houseConfig.addBed && foundBlock instanceof BlockBed) || (!houseConfig.addChest && foundBlock instanceof BlockChest) || (!houseConfig.addTorches && foundBlock instanceof BlockTorch) || (!houseConfig.addCraftingTable && (foundBlock instanceof BlockWorkbench || foundBlock instanceof BlockFurnace))) {
// "handled"
return true;
}
if (foundBlock instanceof BlockFurnace) {
this.furnacePosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
} else if (foundBlock instanceof BlockTrapDoor && houseConfig.addMineShaft) {
// The trap door will still be added, but the mine shaft may not be
// built.
this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
} else if (foundBlock instanceof BlockChest && this.chestPosition == null) {
this.chestPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
} else if (foundBlock instanceof BlockStandingSign) {
this.signPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
}
if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS.getRegistryName().getResourcePath())) {
blockState = blockState.withProperty(BlockStainedGlass.COLOR, houseConfig.glassColor);
block.setBlockState(blockState);
this.priorityOneBlocks.add(block);
return true;
} else if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourcePath())) {
block.setBlockState(foundBlock.getStateFromMeta(houseConfig.glassColor.getMetadata()));
this.priorityOneBlocks.add(block);
return true;
}
return false;
}
Aggregations