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);
}
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;
}
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;
}
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;
}
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();
}
}
}
}
Aggregations