Search in sources :

Example 91 with TileEntity

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

the class AmadronOfferManager method tryRestockCustomOffers.

public void tryRestockCustomOffers() {
    for (AmadronOffer offer : allOffers) {
        if (offer instanceof AmadronOfferCustom) {
            AmadronOfferCustom custom = (AmadronOfferCustom) offer;
            TileEntity input = custom.getProvidingTileEntity();
            TileEntity output = custom.getReturningTileEntity();
            int possiblePickups = ContainerAmadron.capShoppingAmount(custom.invert(), 50, input instanceof IInventory ? (IInventory) input : null, output instanceof IInventory ? (IInventory) output : null, input instanceof IFluidHandler ? (IFluidHandler) input : null, output instanceof IFluidHandler ? (IFluidHandler) output : null, null);
            if (possiblePickups > 0) {
                ChunkPosition pos = new ChunkPosition(input.xCoord, input.yCoord, input.zCoord);
                EntityDrone drone = ContainerAmadron.retrieveOrderItems(custom, possiblePickups, input.getWorldObj(), pos, input.getWorldObj(), pos);
                if (drone != null) {
                    drone.setHandlingOffer(custom.copy(), possiblePickups, null, "Restock");
                }
            }
            custom.invert();
            custom.payout();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) EntityDrone(pneumaticCraft.common.entity.living.EntityDrone) ChunkPosition(net.minecraft.world.ChunkPosition) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 92 with TileEntity

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

the class DroneInteractRFImport method doInteract.

@Override
public boolean doInteract(ChunkPosition pos, IDrone drone, IBlockInteractHandler interactHandler, boolean simulate) {
    IEnergyStorage droneEnergy = CoFHCore.getEnergyStorage(drone);
    if (droneEnergy.getEnergyStored() == droneEnergy.getMaxEnergyStored()) {
        interactHandler.abort();
        return false;
    } else {
        TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ);
        if (te instanceof IEnergyProvider) {
            IEnergyProvider provider = (IEnergyProvider) te;
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (interactHandler.getSides()[d.ordinal()]) {
                    int transferedEnergy = droneEnergy.receiveEnergy(provider.extractEnergy(d, interactHandler.useCount() ? interactHandler.getRemainingCount() : Integer.MAX_VALUE, true), true);
                    if (transferedEnergy > 0) {
                        if (!simulate) {
                            interactHandler.decreaseCount(transferedEnergy);
                            droneEnergy.receiveEnergy(transferedEnergy, false);
                            provider.extractEnergy(d, transferedEnergy, false);
                        }
                        return true;
                    }
                }
            }
        }
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IEnergyProvider(cofh.api.energy.IEnergyProvider) IEnergyStorage(cofh.api.energy.IEnergyStorage) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 93 with TileEntity

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

the class WailaPneumaticHandler method addTipToMachine.

public static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
    NBTTagCompound tCompound = accessor.getNBTData();
    TileEntity te = accessor.getTileEntity();
    if (te instanceof IPneumaticMachine) {
        addTipToMachine(currenttip, (IPneumaticMachine) te, tCompound.getFloat("pressure"));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IPneumaticMachine(pneumaticCraft.api.tileentity.IPneumaticMachine) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 94 with TileEntity

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

the class TileEntityAssemblyDrill method updateEntity.

@Override
public void updateEntity() {
    oldDrillRotation = drillRotation;
    super.updateEntity();
    if (isDrillOn) {
        drillSpeed = Math.min(drillSpeed + TileEntityConstants.ASSEMBLY_DRILL_ACCELERATION * speed, TileEntityConstants.ASSEMBLY_DRILL_MAX_SPEED);
    } else {
        drillSpeed = Math.max(drillSpeed - TileEntityConstants.ASSEMBLY_DRILL_ACCELERATION, 0);
    }
    drillRotation += drillSpeed;
    while (drillRotation >= 360) {
        drillRotation -= 360;
    }
    if (!worldObj.isRemote && drillStep > 0) {
        ForgeDirection[] platformDirection = getPlatformDirection();
        if (platformDirection == null)
            drillStep = 1;
        switch(drillStep) {
            case 1:
                slowMode = false;
                gotoHomePosition();
                break;
            case 2:
                hoverOverNeighbour(platformDirection[0], platformDirection[1]);
                break;
            case 3:
                isDrillOn = true;
                break;
            case 4:
                slowMode = true;
                gotoNeighbour(platformDirection[0], platformDirection[1]);
                break;
            case 5:
                hoverOverNeighbour(platformDirection[0], platformDirection[1]);
                isDrillOn = false;
                TileEntity te = getTileEntityForCurrentDirection();
                if (te instanceof TileEntityAssemblyPlatform) {
                    TileEntityAssemblyPlatform platform = (TileEntityAssemblyPlatform) te;
                    platform.hasDrilledStack = true;
                    ItemStack output = getDrilledOutputForItem(platform.getHeldStack());
                    if (output != null) {
                        platform.setHeldStack(output);
                    }
                }
                break;
            case 6:
                slowMode = false;
                gotoHomePosition();
                break;
        }
        if (isDoneInternal()) {
            drillStep++;
            if (drillStep > 6)
                drillStep = 0;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ItemStack(net.minecraft.item.ItemStack)

Example 95 with TileEntity

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

the class TileEntityBase method autoExportLiquid.

public void autoExportLiquid() {
    FluidStack extractedStack = ((IFluidHandler) this).drain(ForgeDirection.UNKNOWN, Integer.MAX_VALUE, false);
    if (extractedStack != null) {
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            TileEntity te = getTileCache()[d.ordinal()].getTileEntity();
            if (te instanceof IFluidHandler) {
                if (((IFluidHandler) te).canFill(d.getOpposite(), extractedStack.getFluid())) {
                    int filledAmount = ((IFluidHandler) te).fill(d.getOpposite(), extractedStack, true);
                    ((IFluidHandler) this).drain(ForgeDirection.UNKNOWN, filledAmount, true);
                    extractedStack.amount -= filledAmount;
                    if (extractedStack.amount <= 0)
                        break;
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IFluidHandler(net.minecraftforge.fluids.IFluidHandler) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)822 ItemStack (net.minecraft.item.ItemStack)149 BlockPos (net.minecraft.util.math.BlockPos)130 Block (net.minecraft.block.Block)83 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)76 EnumFacing (net.minecraft.util.EnumFacing)62 ArrayList (java.util.ArrayList)61 IBlockState (net.minecraft.block.state.IBlockState)61 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)57 IInventory (net.minecraft.inventory.IInventory)49 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)44 World (net.minecraft.world.World)43 EntityItem (net.minecraft.entity.item.EntityItem)39 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)35 FluidStack (net.minecraftforge.fluids.FluidStack)29 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 HashMap (java.util.HashMap)25 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)23 AMVector3 (am2.api.math.AMVector3)21 Entity (net.minecraft.entity.Entity)21