Search in sources :

Example 6 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project MC-Prefab by Brian-Wuest.

the class HouseConfiguration method PlaceAndFillCraftingMachines.

private static void PlaceAndFillCraftingMachines(EntityPlayer player, World world, BlockPos cornerPosition, EnumFacing facing, boolean addCraftingTable, boolean addFurnace) {
    BlockPos itemPosition = cornerPosition.offset(facing.rotateY()).offset(facing).down();
    if (addCraftingTable) {
        BuildingMethods.ReplaceBlock(world, itemPosition, Blocks.CRAFTING_TABLE);
    }
    // Place a furnace next to the crafting table and fill it with 20 coal.
    if (addFurnace) {
        itemPosition = itemPosition.offset(facing.rotateY());
        BuildingMethods.ReplaceBlock(world, itemPosition, Blocks.FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, facing));
        TileEntity tileEntity = world.getTileEntity(itemPosition);
        if (tileEntity instanceof TileEntityFurnace) {
            TileEntityFurnace furnaceTile = (TileEntityFurnace) tileEntity;
            furnaceTile.setInventorySlotContents(1, new ItemStack(Items.COAL, 20));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 7 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project MC-Prefab by Brian-Wuest.

the class Structure method ScanStructure.

public static void ScanStructure(World world, BlockPos originalPos, BlockPos cornerPos1, BlockPos cornerPos2, String fileLocation, BuildClear clearedSpace, EnumFacing playerFacing, boolean includeAir, boolean excludeWater) {
    Structure scannedStructure = new Structure();
    scannedStructure.setClearSpace(clearedSpace);
    for (BlockPos currentPos : BlockPos.getAllInBox(cornerPos1, cornerPos2)) {
        if (world.isAirBlock(currentPos) && !includeAir) {
            continue;
        }
        IBlockState currentState = world.getBlockState(currentPos);
        Block currentBlock = currentState.getBlock();
        if (currentState.getMaterial() == Material.WATER && excludeWater) {
            continue;
        }
        BuildBlock buildBlock = Structure.createBuildBlockFromBlockState(currentState, currentBlock, currentPos, originalPos);
        if (currentBlock instanceof BlockDoor) {
            EnumDoorHalf blockHalf = currentState.getValue(BlockDoor.HALF);
            if (blockHalf == EnumDoorHalf.LOWER) {
                IBlockState upperHalfState = world.getBlockState(currentPos.up());
                if (upperHalfState != null && upperHalfState.getBlock() instanceof BlockDoor) {
                    Block upperBlock = upperHalfState.getBlock();
                    BuildBlock upperHalf = Structure.createBuildBlockFromBlockState(upperHalfState, upperBlock, currentPos.up(), originalPos);
                    buildBlock.setSubBlock(upperHalf);
                }
            } else {
                // Don't process upper door halves. These were already done.
                continue;
            }
        } else if (currentBlock instanceof BlockBed) {
            EnumPartType bedPart = currentState.getValue(BlockBed.PART);
            if (bedPart == EnumPartType.HEAD) {
                IBlockState bedFoot = null;
                boolean foundFoot = false;
                EnumFacing facing = EnumFacing.NORTH;
                while (foundFoot == false) {
                    bedFoot = world.getBlockState(currentPos.offset(facing));
                    if (bedFoot.getBlock() instanceof BlockBed && bedFoot.getValue(BlockBed.PART) == EnumPartType.FOOT) {
                        foundFoot = true;
                        break;
                    }
                    facing = facing.rotateY();
                    if (facing == EnumFacing.NORTH) {
                        // Got back to north, break out to avoid infinite loop.
                        break;
                    }
                }
                if (foundFoot) {
                    Block footBedBlock = bedFoot.getBlock();
                    BuildBlock bed = Structure.createBuildBlockFromBlockState(bedFoot, footBedBlock, currentPos.offset(facing), originalPos);
                    buildBlock.setSubBlock(bed);
                }
            } else {
                // Don't process foot of bed, it was already done.
                continue;
            }
        }
        scannedStructure.getBlocks().add(buildBlock);
        TileEntity tileEntity = world.getTileEntity(currentPos);
        if (tileEntity != null) {
            // Don't write data for empty tile entities.
            if ((tileEntity instanceof TileEntityChest && ((TileEntityChest) tileEntity).isEmpty()) || (tileEntity instanceof TileEntityFurnace && ((TileEntityFurnace) tileEntity).isEmpty())) {
                continue;
            }
            ResourceLocation resourceLocation = TileEntity.getKey(tileEntity.getClass());
            NBTTagCompound tagCompound = new NBTTagCompound();
            tileEntity.writeToNBT(tagCompound);
            BuildTileEntity buildTileEntity = new BuildTileEntity();
            buildTileEntity.setEntityDomain(resourceLocation.getResourceDomain());
            buildTileEntity.setEntityName(resourceLocation.getResourcePath());
            buildTileEntity.setStartingPosition(Structure.getStartingPositionFromOriginalAndCurrentPosition(currentPos, originalPos));
            buildTileEntity.setEntityNBTData(tagCompound);
            scannedStructure.tileEntities.add(buildTileEntity);
        }
    }
    int x_radiusRangeBegin = cornerPos1.getX() < cornerPos2.getX() ? cornerPos1.getX() : cornerPos2.getX();
    int x_radiusRangeEnd = cornerPos1.getX() < cornerPos2.getX() ? cornerPos2.getX() : cornerPos1.getX();
    int y_radiusRangeBegin = cornerPos1.getY() < cornerPos2.getY() ? cornerPos1.getY() : cornerPos2.getY();
    int y_radiusRangeEnd = cornerPos1.getY() < cornerPos2.getY() ? cornerPos2.getY() : cornerPos1.getY();
    int z_radiusRangeBegin = cornerPos1.getZ() < cornerPos2.getZ() ? cornerPos1.getZ() : cornerPos2.getZ();
    int z_radiusRangeEnd = cornerPos1.getZ() < cornerPos2.getZ() ? cornerPos2.getZ() : cornerPos1.getZ();
    for (Entity entity : world.getLoadedEntityList()) {
        BlockPos entityPos = entity.getPosition();
        if (entityPos.getX() >= x_radiusRangeBegin && entityPos.getX() <= x_radiusRangeEnd && entityPos.getZ() >= z_radiusRangeBegin && entityPos.getZ() <= z_radiusRangeEnd && entityPos.getY() >= y_radiusRangeBegin && entityPos.getY() <= y_radiusRangeEnd) {
            BuildEntity buildEntity = new BuildEntity();
            buildEntity.setEntityId(EntityList.getID(entity.getClass()));
            buildEntity.setEntityResourceString(EntityList.getKey(entity));
            buildEntity.setStartingPosition(Structure.getStartingPositionFromOriginalAndCurrentPosition(entityPos, originalPos));
            buildEntity.entityXAxisOffset = entityPos.getX() - entity.posX;
            buildEntity.entityYAxisOffset = entityPos.getY() - entity.posY;
            buildEntity.entityZAxisOffset = entityPos.getZ() - entity.posZ;
            if (entity instanceof EntityItemFrame) {
                buildEntity.entityYAxisOffset = buildEntity.entityYAxisOffset * -1;
            }
            NBTTagCompound entityTagCompound = new NBTTagCompound();
            entity.writeToNBT(entityTagCompound);
            buildEntity.setEntityNBTData(entityTagCompound);
            scannedStructure.entities.add(buildEntity);
        }
    }
    Structure.CreateStructureFile(scannedStructure, fileLocation);
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChest(net.minecraft.tileentity.TileEntityChest) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EnumPartType(net.minecraft.block.BlockBed.EnumPartType) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) TileEntity(net.minecraft.tileentity.TileEntity) EnumDoorHalf(net.minecraft.block.BlockDoor.EnumDoorHalf) ResourceLocation(net.minecraft.util.ResourceLocation) BlockPos(net.minecraft.util.math.BlockPos)

Example 8 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project PneumaticCraft by MineMaarten.

the class HeatBehaviourFurnace method update.

@Override
public void update() {
    TileEntityFurnace furnace = getTileEntity();
    if (getHeatExchanger().getTemperature() > 373) {
        if (furnace.furnaceBurnTime < 190 && furnace.getStackInSlot(0) != null) {
            if (furnace.furnaceBurnTime == 0)
                BlockFurnace.updateFurnaceBlockState(true, furnace.getWorldObj(), furnace.xCoord, furnace.yCoord, furnace.zCoord);
            furnace.currentItemBurnTime = 200;
            furnace.furnaceBurnTime += 10;
            getHeatExchanger().addHeat(-1);
        }
        if (furnace.furnaceCookTime > 0) {
            // Easy performance saver, the Furnace won't be ticked unnecessary when there's nothing to cook (or when just started cooking).
            int progress = Math.max(0, ((int) getHeatExchanger().getTemperature() - 343) / 30);
            progress = Math.min(5, progress);
            for (int i = 0; i < progress; i++) {
                furnace.updateEntity();
            }
        }
    }
}
Also used : TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace)

Example 9 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project SecurityCraft by Geforce132.

the class BlockKeypadFurnace method convert.

@Override
public boolean convert(EntityPlayer player, World world, BlockPos pos) {
    EnumFacing enumfacing = (EnumFacing) world.getBlockState(pos).getValue(FACING);
    TileEntityFurnace furnace = (TileEntityFurnace) world.getTileEntity(pos);
    NBTTagCompound tag = new NBTTagCompound();
    furnace.writeToNBT(tag);
    furnace.clear();
    world.setBlockState(pos, SCContent.keypadFurnace.getDefaultState().withProperty(FACING, enumfacing).withProperty(OPEN, false));
    ((IOwnable) world.getTileEntity(pos)).getOwner().set(player.getCommandSenderName(), player.getUniqueID().toString());
    ((TileEntityKeypadFurnace) world.getTileEntity(pos)).readFromNBT(tag);
    return true;
}
Also used : TileEntityKeypadFurnace(net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace) EnumFacing(net.minecraft.util.EnumFacing) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace)

Example 10 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace 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)

Aggregations

TileEntityFurnace (net.minecraft.tileentity.TileEntityFurnace)15 TileEntity (net.minecraft.tileentity.TileEntity)9 BlockPos (net.minecraft.util.math.BlockPos)7 ItemStack (net.minecraft.item.ItemStack)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 EnumFacing (net.minecraft.util.EnumFacing)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)3 World (net.minecraft.world.World)2 InvWrapper (net.minecraftforge.items.wrapper.InvWrapper)2 Burnable (com.minecolonies.api.colony.requestsystem.requestable.Burnable)1 AbstractBuildingFurnaceUser (com.minecolonies.coremod.colony.buildings.AbstractBuildingFurnaceUser)1 BakingProduct (com.minecolonies.coremod.entity.ai.citizen.baker.BakingProduct)1 AIState (com.minecolonies.coremod.entity.ai.util.AIState)1 EntityPlayerConfiguration (com.wuest.prefab.Config.EntityPlayerConfiguration)1 HouseConfiguration (com.wuest.prefab.Config.Structures.HouseConfiguration)1 ModerateHouseConfiguration (com.wuest.prefab.Config.Structures.ModerateHouseConfiguration)1 TileEntityKeypadFurnace (net.geforcemods.securitycraft.tileentity.TileEntityKeypadFurnace)1 Block (net.minecraft.block.Block)1 EnumPartType (net.minecraft.block.BlockBed.EnumPartType)1 EnumDoorHalf (net.minecraft.block.BlockDoor.EnumDoorHalf)1