Search in sources :

Example 71 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class CoordTrackUpgradeHandler method onPlayerInteract.

@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event) {
    if (event.action == Action.RIGHT_CLICK_BLOCK && isListeningToCoordTrackerSetting) {
        isListeningToCoordTrackerSetting = false;
        ForgeDirection dir = ForgeDirection.getOrientation(event.face);
        reset();
        ItemStack stack = event.entityPlayer.getCurrentArmor(3);
        if (stack != null) {
            NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "CoordTracker");
            tag.setInteger("dimID", event.entity.worldObj.provider.dimensionId);
            tag.setInteger("x", event.x + dir.offsetX);
            tag.setInteger("y", event.y + dir.offsetY);
            tag.setInteger("z", event.z + dir.offsetZ);
        }
        NetworkHandler.sendToServer(new PacketCoordTrackUpdate(event.entity.worldObj, event.x + dir.offsetX, event.y + dir.offsetY, event.z + dir.offsetZ));
    }
    return false;
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketCoordTrackUpdate(pneumaticCraft.common.network.PacketCoordTrackUpdate) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 72 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class ModelUniversalSensor method renderModel.

public void renderModel(float size, float dishRotation, boolean[] sidesConnected) {
    Base1.render(size);
    Base2.render(size);
    GL11.glPushMatrix();
    GL11.glRotatef(dishRotation, 0, 1, 0);
    Dish1.render(size);
    Dish2.render(size);
    Dish3.render(size);
    Dish4.render(size);
    Dish5.render(size);
    Dish6.render(size);
    GL11.glPopMatrix();
    ForgeDirection d = ForgeDirection.EAST;
    for (int i = 0; i < 4; i++) {
        d = d.getRotation(ForgeDirection.UP);
        if (sidesConnected[d.ordinal()]) {
            TubeConnection.rotateAngleY = (float) (i * Math.PI / 2);
            TubeConnection.render(size);
        }
    }
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Example 73 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class ModelKeroseneLamp method renderStatic.

@Override
public void renderStatic(float size, TileEntity te) {
    ForgeDirection sideConnected = ForgeDirection.DOWN;
    if (te != null) {
        sideConnected = ((TileEntityKeroseneLamp) te).getSideConnected();
    }
    Tank.render(size);
    Holder1.render(size);
    Holder2.render(size);
    Base.render(size);
    Top.render(size);
    if (sideConnected != ForgeDirection.DOWN) {
        Support1.render(size);
        if (sideConnected != ForgeDirection.UP) {
            SupportSide.rotateAngleY = 0;
            ForgeDirection rotation = ((TileEntityKeroseneLamp) te).getRotation();
            if (rotation != ForgeDirection.UP && rotation != ForgeDirection.DOWN) {
                while (sideConnected != rotation.getOpposite()) {
                    sideConnected = sideConnected.getRotation(ForgeDirection.DOWN);
                    SupportSide.rotateAngleY += Math.toRadians(90);
                }
            }
            SupportSide2.rotateAngleY = SupportSide.rotateAngleY;
            SupportSide.render(size);
            SupportSide2.render(size);
        }
    }
    if (te != null) {
        FluidTankInfo info = ((TileEntityKeroseneLamp) te).getTankInfo(null)[0];
        if (info.fluid != null && info.fluid.amount > 10) {
            float percentageFull = (float) info.fluid.amount / info.capacity;
            RenderInfo renderInfo = new RenderInfo(-3 / 16F + 0.01F, 23 / 16F - percentageFull * 2.999F / 16F, -3 / 16F + 0.01F, 3 / 16F - 0.01F, 22.99F / 16F, 3 / 16F - 0.01F);
            RenderUtils.INSTANCE.renderLiquid(info, renderInfo, te.getWorldObj());
        }
    }
}
Also used : FluidTankInfo(net.minecraftforge.fluids.FluidTankInfo) TileEntityKeroseneLamp(pneumaticCraft.common.tileentity.TileEntityKeroseneLamp) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) RenderInfo(pneumaticCraft.client.util.RenderUtils.RenderInfo)

Example 74 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection 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 75 with ForgeDirection

use of net.minecraftforge.common.util.ForgeDirection in project PneumaticCraft by MineMaarten.

the class LogisticsManager method tryProvide.

//curAI = new DroneAILiquidImport(drone, new FakeWidgetLogistics(provider.getPos(), providingStack));
// transportingFluid = new FluidStackWrapper(providingStack);
private void tryProvide(SemiBlockLogistics provider, SemiBlockLogistics requester, PriorityQueue<LogisticsTask> tasks) {
    IInventory providingInventory = IOHelper.getInventoryForTE(provider.getTileEntity());
    if (providingInventory != null) {
        if (requester instanceof IProvidingInventoryListener)
            ((IProvidingInventoryListener) requester).notify(provider.getTileEntity());
        for (int i = 0; i < providingInventory.getSizeInventory(); i++) {
            ItemStack providingStack = providingInventory.getStackInSlot(i);
            if (providingStack != null && (!(provider instanceof ISpecificProvider) || ((ISpecificProvider) provider).canProvide(providingStack)) && IOHelper.canExtractItemFromInventory(providingInventory, providingStack, i, 0)) {
                int requestedAmount = getRequestedAmount(requester, providingStack);
                if (requestedAmount > 0) {
                    ItemStack stack = providingStack.copy();
                    stack.stackSize = requestedAmount;
                    tasks.add(new LogisticsTask(provider, requester, stack));
                }
            }
        }
    }
    if (provider.getTileEntity() instanceof IFluidHandler) {
        IFluidHandler providingTank = (IFluidHandler) provider.getTileEntity();
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            FluidStack providingStack = providingTank.drain(d, 16000, false);
            if (providingStack != null && (!(provider instanceof ISpecificProvider) || ((ISpecificProvider) provider).canProvide(providingStack)) && providingTank.canDrain(d, providingStack.getFluid())) {
                int requestedAmount = getRequestedAmount(requester, providingStack);
                if (requestedAmount > 0) {
                    FluidStack stack = providingStack.copy();
                    stack.amount = requestedAmount;
                    tasks.add(new LogisticsTask(provider, requester, new FluidStackWrapper(stack)));
                }
            }
        }
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) FluidStack(net.minecraftforge.fluids.FluidStack) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ISpecificProvider(pneumaticCraft.common.semiblock.ISpecificProvider) IProvidingInventoryListener(pneumaticCraft.common.semiblock.IProvidingInventoryListener) FluidStackWrapper(pneumaticCraft.common.semiblock.SemiBlockLogistics.FluidStackWrapper) ItemStack(net.minecraft.item.ItemStack) IFluidHandler(net.minecraftforge.fluids.IFluidHandler)

Aggregations

ForgeDirection (net.minecraftforge.common.util.ForgeDirection)242 TileEntity (net.minecraft.tileentity.TileEntity)80 ItemStack (net.minecraft.item.ItemStack)47 ArrayList (java.util.ArrayList)29 Block (net.minecraft.block.Block)28 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)24 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)21 IInventory (net.minecraft.inventory.IInventory)19 FluidStack (net.minecraftforge.fluids.FluidStack)18 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)17 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)17 IFluidHandler (net.minecraftforge.fluids.IFluidHandler)16 HashMap (java.util.HashMap)12 Pair (logisticspipes.utils.tuples.Pair)11 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)10 World (net.minecraft.world.World)10 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8