Search in sources :

Example 1 with HouseConfiguration

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!");
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntitySign(net.minecraft.tileentity.TileEntitySign) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) HouseConfiguration(com.wuest.prefab.Config.Structures.HouseConfiguration) ItemStack(net.minecraft.item.ItemStack) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with HouseConfiguration

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;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) BlockChest(net.minecraft.block.BlockChest) BlockWorkbench(net.minecraft.block.BlockWorkbench) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) BlockStandingSign(net.minecraft.block.BlockStandingSign) BlockBed(net.minecraft.block.BlockBed) HouseConfiguration(com.wuest.prefab.Config.Structures.HouseConfiguration) BlockTorch(net.minecraft.block.BlockTorch)

Aggregations

HouseConfiguration (com.wuest.prefab.Config.Structures.HouseConfiguration)2 BlockBed (net.minecraft.block.BlockBed)1 BlockChest (net.minecraft.block.BlockChest)1 BlockFurnace (net.minecraft.block.BlockFurnace)1 BlockStandingSign (net.minecraft.block.BlockStandingSign)1 BlockTorch (net.minecraft.block.BlockTorch)1 BlockTrapDoor (net.minecraft.block.BlockTrapDoor)1 BlockWorkbench (net.minecraft.block.BlockWorkbench)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityFurnace (net.minecraft.tileentity.TileEntityFurnace)1 TileEntitySign (net.minecraft.tileentity.TileEntitySign)1 TextComponentString (net.minecraft.util.text.TextComponentString)1