Search in sources :

Example 1 with ModerateHouseConfiguration

use of com.wuest.prefab.Config.Structures.ModerateHouseConfiguration in project MC-Prefab by Brian-Wuest.

the class StructureModerateHouse 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) {
    ModerateHouseConfiguration houseConfig = (ModerateHouseConfiguration) configuration;
    EntityPlayerConfiguration playerConfig = EntityPlayerConfiguration.loadFromEntityData((EntityPlayerMP) player);
    if (this.furnacePosition != null) {
        for (BlockPos furnacePos : this.furnacePosition) {
            // Fill the furnace.
            TileEntity tileEntity = world.getTileEntity(furnacePos);
            if (tileEntity instanceof TileEntityFurnace) {
                TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
                furnaceTile.setInventorySlotContents(1, new ItemStack(Items.COAL, 20));
            }
        }
    }
    if (this.chestPosition != null && !playerConfig.builtStarterHouse && houseConfig.addChestContents) {
        // Fill the chest if the player hasn't generated the starting house yet.
        StructureModerateHouse.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);
    }
    // Make sure to set this value so the player cannot fill the chest a second time.
    playerConfig.builtStarterHouse = true;
    playerConfig.saveToPlayer(player);
}
Also used : ModerateHouseConfiguration(com.wuest.prefab.Config.Structures.ModerateHouseConfiguration) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerConfiguration(com.wuest.prefab.Config.EntityPlayerConfiguration) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntityPlayerConfiguration (com.wuest.prefab.Config.EntityPlayerConfiguration)1 ModerateHouseConfiguration (com.wuest.prefab.Config.Structures.ModerateHouseConfiguration)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityFurnace (net.minecraft.tileentity.TileEntityFurnace)1 BlockPos (net.minecraft.util.math.BlockPos)1