Search in sources :

Example 11 with TileEntityFurnace

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

Example 12 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project BloodMagic by WayofTime.

the class AlchemyArrayEffectFurnaceFuel method update.

@Override
public boolean update(TileEntity tile, int ticksActive) {
    BlockPos pos = tile.getPos();
    World world = tile.getWorld();
    EntityPlayer sacrifice = null;
    for (EnumFacing face : EnumFacing.VALUES) {
        BlockPos furnacePos = pos.offset(face);
        Block block = world.getBlockState(furnacePos).getBlock();
        if (// This will only work vanilla furnaces. No others!
        block != Blocks.FURNACE) {
            continue;
        }
        TileEntity bottomTile = world.getTileEntity(furnacePos);
        if (bottomTile instanceof TileEntityFurnace) {
            TileEntityFurnace furnaceTile = (TileEntityFurnace) bottomTile;
            if (canFurnaceSmelt(furnaceTile) && !furnaceTile.isBurning()) {
                if (sacrifice == null || sacrifice.isDead) {
                    AxisAlignedBB bb = new AxisAlignedBB(pos).grow(radius);
                    List<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
                    for (EntityPlayer player : playerList) {
                        if (!player.isDead) {
                            sacrifice = player;
                        }
                    }
                }
                if (addFuelTime(furnaceTile, world, furnacePos, burnTicksAdded)) {
                    if (!sacrifice.capabilities.isCreativeMode) {
                        sacrifice.hurtResistantTime = 0;
                        // No.
                        sacrifice.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, 1.0F);
                    }
                }
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World)

Example 13 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project minecolonies by Minecolonies.

the class AbstractEntityAIUsesFurnace method retrieveSmeltableFromFurnace.

/**
 * Retrieve ready bars from the furnaces.
 * If no position has been set return.
 * Else navigate to the position of the furnace.
 * On arrival execute the extract method of the specialized worker.
 * @return the next state to go to.
 */
private AIState retrieveSmeltableFromFurnace() {
    worker.setLatestStatus(new TextComponentTranslation(COM_MINECOLONIES_COREMOD_STATUS_RETRIEVING));
    if (walkTo == null) {
        return START_WORKING;
    }
    if (walkToBlock(walkTo)) {
        setDelay(2);
        return getState();
    }
    final TileEntity entity = world.getTileEntity(walkTo);
    if (!(entity instanceof TileEntityFurnace) || (ItemStackUtils.isEmpty(((TileEntityFurnace) entity).getStackInSlot(RESULT_SLOT)))) {
        walkTo = null;
        return START_WORKING;
    }
    walkTo = null;
    extractFromFurnace((TileEntityFurnace) entity);
    incrementActionsDoneAndDecSaturation();
    setDelay(STANDARD_DELAY);
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace)

Example 14 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project minecolonies by Minecolonies.

the class AbstractEntityAIUsesFurnace method fillUpFurnace.

/**
 * Smelt the smeltable after the required items are in the inv.
 * @return the next state to go to.
 */
private AIState fillUpFurnace() {
    if (((AbstractBuildingFurnaceUser) getOwnBuilding()).getFurnaces().isEmpty()) {
        chatSpamFilter.talkWithoutSpam(COM_MINECOLONIES_COREMOD_STATUS_COOKING);
        setDelay(STANDARD_DELAY);
        return START_WORKING;
    }
    if (walkTo == null || world.getBlockState(walkTo).getBlock() != Blocks.FURNACE) {
        walkTo = null;
        setDelay(STANDARD_DELAY);
        return START_WORKING;
    }
    if (walkToBlock(walkTo)) {
        setDelay(2);
        return getState();
    }
    final TileEntity entity = world.getTileEntity(walkTo);
    if (entity instanceof TileEntityFurnace) {
        final TileEntityFurnace furnace = (TileEntityFurnace) entity;
        if (InventoryUtils.hasItemInItemHandler(new InvWrapper(worker.getInventoryCitizen()), this::isSmeltable) && (hasFuelInFurnaceAndNoSmeltable(furnace) || hasNeitherFuelNorSmeltAble(furnace))) {
            InventoryUtils.transferXOfFirstSlotInItemHandlerWithIntoInItemHandler(new InvWrapper(worker.getInventoryCitizen()), this::isSmeltable, STACKSIZE, new InvWrapper(furnace), SMELTABLE_SLOT);
        }
        if (InventoryUtils.hasItemInItemHandler(new InvWrapper(worker.getInventoryCitizen()), TileEntityFurnace::isItemFuel) && (hasSmeltableInFurnaceAndNoFuel(furnace) || hasNeitherFuelNorSmeltAble(furnace))) {
            InventoryUtils.transferXOfFirstSlotInItemHandlerWithIntoInItemHandler(new InvWrapper(worker.getInventoryCitizen()), TileEntityFurnace::isItemFuel, STACKSIZE, new InvWrapper(furnace), FUEL_SLOT);
        }
    }
    walkTo = null;
    setDelay(STANDARD_DELAY);
    return START_WORKING;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace)

Example 15 with TileEntityFurnace

use of net.minecraft.tileentity.TileEntityFurnace in project pnc-repressurized by TeamPneumatic.

the class HeatBehaviourFurnace method update.

@Override
public void update() {
    TileEntityFurnace furnace = getTileEntity();
    if (getHeatExchanger().getTemperature() > 373) {
        int furnaceBurnTime = furnace.getField(0);
        int furnaceCookTime = furnace.getField(2);
        if (furnaceBurnTime < 190 && !furnace.getStackInSlot(0).isEmpty()) {
            if (furnaceBurnTime == 0)
                BlockFurnace.setState(true, furnace.getWorld(), furnace.getPos());
            // currentItemBurnTime
            furnace.setField(1, 200);
            // furnaceBurnTime
            furnace.setField(0, furnaceBurnTime + 10);
            getHeatExchanger().addHeat(-1);
        }
        if (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.update();
            }
        }
    }
}
Also used : TileEntityFurnace(net.minecraft.tileentity.TileEntityFurnace)

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