Search in sources :

Example 56 with TileEntity

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

the class HackableMobSpawner method isHacked.

public static boolean isHacked(IBlockAccess world, int x, int y, int z) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te != null) {
        NBTTagCompound tag = new NBTTagCompound();
        te.writeToNBT(tag);
        if (tag.hasKey("RequiredPlayerRange") && tag.getShort("RequiredPlayerRange") == 0)
            return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 57 with TileEntity

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

the class LogisticsManager method getRequestedAmount.

public static int getRequestedAmount(SemiBlockLogistics requester, ItemStack providingStack) {
    TileEntity te = requester.getTileEntity();
    if (!(te instanceof IInventory))
        return 0;
    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.stackSize;
    if (requestedAmount == 0)
        return 0;
    providingStack = providingStack.copy();
    providingStack.stackSize = requestedAmount;
    ItemStack remainder = providingStack.copy();
    remainder.stackSize += requester.getIncomingItems(providingStack);
    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        remainder = IOHelper.insert(te, remainder, d, true);
        if (remainder == null)
            break;
    }
    if (remainder != null)
        providingStack.stackSize -= remainder.stackSize;
    if (providingStack.stackSize <= 0)
        return 0;
    return providingStack.stackSize;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISpecificRequester(pneumaticCraft.common.semiblock.ISpecificRequester) ItemStack(net.minecraft.item.ItemStack)

Example 58 with TileEntity

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

the class LogisticsManager method getRequestedAmount.

public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
    int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
    if (requestedAmount == 0)
        return 0;
    providingStack = providingStack.copy();
    providingStack.amount = requestedAmount;
    FluidStack remainder = providingStack.copy();
    remainder.amount += requester.getIncomingFluid(remainder.getFluid());
    TileEntity te = requester.getTileEntity();
    if (te instanceof IFluidHandler) {
        IFluidHandler fluidHandler = (IFluidHandler) te;
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            int fluidFilled = fluidHandler.fill(d, remainder, false);
            if (fluidFilled > 0) {
                remainder.amount -= fluidFilled;
                break;
            }
        }
    }
    providingStack.amount -= remainder.amount;
    if (providingStack.amount <= 0)
        return 0;
    return providingStack.amount;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidStack(net.minecraftforge.fluids.FluidStack) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISpecificRequester(pneumaticCraft.common.semiblock.ISpecificRequester) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Example 59 with TileEntity

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

the class BlockAphorismTile method onBlockPlacedBy.

/**
     * Called when the block is placed in the world.
     */
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityLiving, ItemStack iStack) {
    super.onBlockPlacedBy(world, x, y, z, entityLiving, iStack);
    int meta = world.getBlockMetadata(x, y, z);
    if (meta < 2) {
        TileEntity te = world.getTileEntity(x, y, z);
        if (te instanceof TileEntityAphorismTile) {
            ((TileEntityAphorismTile) te).textRotation = (((int) entityLiving.rotationYaw + 45) / 90 + 2) % 4;
        }
    }
    if (world.isRemote && entityLiving instanceof EntityPlayer) {
        ((EntityPlayer) entityLiving).openGui(PneumaticCraft.instance, EnumGuiId.APHORISM_TILE.ordinal(), world, x, y, z);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAphorismTile(pneumaticCraft.common.tileentity.TileEntityAphorismTile) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 60 with TileEntity

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

the class BlockOmnidirectionalHopper method rotateBlock.

@Override
public boolean rotateBlock(World world, EntityPlayer player, int x, int y, int z, ForgeDirection face) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityOmnidirectionalHopper) {
        TileEntityOmnidirectionalHopper teOh = (TileEntityOmnidirectionalHopper) te;
        if (player != null && player.isSneaking()) {
            int newMeta = (world.getBlockMetadata(x, y, z) + 1) % 6;
            if (newMeta == teOh.getDirection().ordinal())
                newMeta = (newMeta + 1) % 6;
            world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
        } else {
            int newRotation = (teOh.getDirection().ordinal() + 1) % 6;
            if (newRotation == world.getBlockMetadata(x, y, z))
                newRotation = (newRotation + 1) % 6;
            teOh.setDirection(ForgeDirection.getOrientation(newRotation));
        }
        return true;
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityOmnidirectionalHopper(pneumaticCraft.common.tileentity.TileEntityOmnidirectionalHopper)

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