Search in sources :

Example 1 with PneumaticTube

use of com.bluepowermod.part.tube.PneumaticTube in project BluePower by Qmunity.

the class PartConverterTube method convert.

@Override
public IPart convert(NBTTagCompound old) {
    PartInfo info = PartManager.getPartInfo(old.getString("part_id"));
    if (info == null)
        return null;
    PneumaticTube part = (PneumaticTube) info.create();
    part.readFromNBT(old.getCompoundTag("partData"));
    return part;
}
Also used : PneumaticTube(com.bluepowermod.part.tube.PneumaticTube) PartInfo(com.bluepowermod.part.PartInfo)

Example 2 with PneumaticTube

use of com.bluepowermod.part.tube.PneumaticTube in project BluePower by Qmunity.

the class TileManager method retrieveItemsFromManagers.

private void retrieveItemsFromManagers() {
    PneumaticTube tube = MultipartCompatibility.getPart(worldObj, xCoord + getOutputDirection().offsetX, yCoord + getOutputDirection().offsetY, zCoord + getOutputDirection().offsetZ, PneumaticTube.class);
    if (tube != null) {
        for (ItemStack stack : inventory) {
            int acceptedItems = acceptedItems(stack);
            if (acceptedItems > 0) {
                ItemStack retrievingStack = stack.copy();
                retrievingStack.stackSize = retrievingStack.getMaxStackSize();
                if (tube.getLogic().retrieveStack(this, getOutputDirection(), retrievingStack, filterColor))
                    return;
            }
        }
    }
}
Also used : PneumaticTube(com.bluepowermod.part.tube.PneumaticTube) ItemStack(net.minecraft.item.ItemStack)

Example 3 with PneumaticTube

use of com.bluepowermod.part.tube.PneumaticTube in project BluePower by Qmunity.

the class IOHelper method insert.

public static ItemStack insert(TileEntity tile, ItemStack itemStack, ForgeDirection direction, TubeColor color, boolean simulate) {
    if (tile == null || itemStack == null)
        return itemStack;
    if (tile instanceof ITubeConnection) {
        TubeStack tubeStack = ((ITubeConnection) tile).acceptItemFromTube(new TubeStack(itemStack, direction.getOpposite(), color), direction, simulate);
        if (tubeStack == null)
            return null;
        return tubeStack.stack;
    }
    IInventory inv = getInventoryForTE(tile);
    if (inv != null)
        return insert(inv, itemStack, direction.ordinal(), simulate);
    PneumaticTube tube = MultipartCompatibility.getPart(tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord, PneumaticTube.class);
    if (tube != null) {
        // we don't need to check connections, that's catched earlier.
        TubeLogic logic = tube.getLogic();
        return logic.injectStack(itemStack, direction.getOpposite(), color, simulate) ? null : itemStack;
    }
    return itemStack;
}
Also used : ITubeConnection(com.bluepowermod.api.tube.ITubeConnection) IInventory(net.minecraft.inventory.IInventory) PneumaticTube(com.bluepowermod.part.tube.PneumaticTube) TubeStack(com.bluepowermod.part.tube.TubeStack) TubeLogic(com.bluepowermod.part.tube.TubeLogic)

Example 4 with PneumaticTube

use of com.bluepowermod.part.tube.PneumaticTube in project BluePower by Qmunity.

the class MessageRedirectTubeStack method handleClientSide.

@Override
public void handleClientSide(EntityPlayer player) {
    PneumaticTube tube = MultipartCompatibility.getPart(player.worldObj, x, y, z, PneumaticTube.class);
    if (tube == null)
        return;
    TubeLogic logic = tube.getLogic();
    if (logic == null)
        return;
    logic.onClientTubeRedirectPacket(stack);
}
Also used : PneumaticTube(com.bluepowermod.part.tube.PneumaticTube) TubeLogic(com.bluepowermod.part.tube.TubeLogic)

Example 5 with PneumaticTube

use of com.bluepowermod.part.tube.PneumaticTube in project BluePower by Qmunity.

the class TileRetriever method pullItem.

@Override
protected void pullItem() {
    if (isBufferEmpty()) {
        PneumaticTube tube = MultipartCompatibility.getPart(worldObj, xCoord + getFacingDirection().offsetX, yCoord + getFacingDirection().offsetY, zCoord + getFacingDirection().offsetZ, PneumaticTube.class);
        if (tube != null) {
            boolean everythingNull = true;
            for (int i = 0; i < inventory.length; i++) {
                if (mode == 1 || slotIndex == i) {
                    ItemStack stack = inventory[i];
                    if (stack != null) {
                        if (tube.getLogic().retrieveStack(this, getFacingDirection(), stack)) {
                            if (mode == 0) {
                                if (++slotIndex >= inventory.length)
                                    slotIndex = 0;
                                while (slotIndex != i) {
                                    if (inventory[slotIndex] != null)
                                        break;
                                    if (++slotIndex >= inventory.length)
                                        slotIndex = 0;
                                }
                            }
                            return;
                        }
                        everythingNull = false;
                    }
                }
            }
            if (everythingNull) {
                tube.getLogic().retrieveStack(this, getFacingDirection(), null);
                slotIndex = 0;
            }
        } else {
            super.pullItem();
        }
    }
}
Also used : PneumaticTube(com.bluepowermod.part.tube.PneumaticTube) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PneumaticTube (com.bluepowermod.part.tube.PneumaticTube)5 TubeLogic (com.bluepowermod.part.tube.TubeLogic)2 ItemStack (net.minecraft.item.ItemStack)2 ITubeConnection (com.bluepowermod.api.tube.ITubeConnection)1 PartInfo (com.bluepowermod.part.PartInfo)1 TubeStack (com.bluepowermod.part.tube.TubeStack)1 IInventory (net.minecraft.inventory.IInventory)1