Search in sources :

Example 1 with BPPart

use of com.bluepowermod.part.BPPart in project BluePower by Qmunity.

the class ItemPart method addInformation.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, EntityPlayer player, List list, boolean unused) {
    BPPart part = PartManager.getExample(item);
    if (part == null)
        return;
    List<String> l = new ArrayList<String>();
    part.addTooltip(item, l);
    list.addAll(l);
}
Also used : ArrayList(java.util.ArrayList) BPPart(com.bluepowermod.part.BPPart) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with BPPart

use of com.bluepowermod.part.BPPart in project BluePower by Qmunity.

the class ItemPart method canGoInCopySlot.

@Override
public boolean canGoInCopySlot(ItemStack stack) {
    BPPart part = info.create();
    BPApi.getInstance().loadSilkySettings(part, stack);
    return part.canGoInCopySlot(stack);
}
Also used : BPPart(com.bluepowermod.part.BPPart)

Example 3 with BPPart

use of com.bluepowermod.part.BPPart in project BluePower by Qmunity.

the class PneumaticTube method onActivated.

/**
     * Event called when the part is activated (right clicked)
     *
     * @param player
     *            Player that right clicked the part
     * @param item
     *            Item that was used to click it
     * @return Whether or not an action occurred
     */
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
    if (getWorld() == null)
        return false;
    if (item != null) {
        TubeColor newColor = null;
        if (item.getItem() == BPItems.paint_brush && ((ItemDamageableColorableOverlay) BPItems.paint_brush).tryUseItem(item)) {
            newColor = TubeColor.values()[item.getItemDamage()];
        } else if (item.getItem() == Items.water_bucket || (item.getItem() == BPItems.paint_brush && item.getItemDamage() == 16)) {
            newColor = TubeColor.NONE;
        }
        if (newColor != null) {
            if (!getWorld().isRemote) {
                List<Vec3dCube> boxes = getTubeBoxes();
                Vec3dCube box = mop.getCube();
                int face = -1;
                if (box.equals(boxes.get(0))) {
                    face = mop.sideHit;
                } else {
                    face = getSideFromAABBIndex(boxes.indexOf(box));
                }
                color[face] = newColor;
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
            }
            return true;
        }
        if (item.getItem() instanceof ItemPart) {
            BPPart part = PartManager.getExample(item);
            if (redwireType == null && part instanceof PartRedwireFaceUninsulated) {
                if (!getWorld().isRemote) {
                    redwireType = ((IRedwire) part).getRedwireType(ForgeDirection.UNKNOWN);
                    if (!player.capabilities.isCreativeMode)
                        item.stackSize--;
                    // Redstone update
                    getRedstoneConnectionCache().recalculateConnections();
                    RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                    updateConnections();
                    getLogic().clearNodeCaches();
                    notifyUpdate();
                    sendUpdatePacket();
                }
                return true;
            }
        }
        // Removing redwire
        if (redwireType != null && item.getItem() instanceof IScrewdriver && player.isSneaking()) {
            if (!getWorld().isRemote) {
                IOHelper.spawnItemInWorld(getWorld(), PartManager.getPartInfo("wire." + redwireType.getName()).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
                redwireType = null;
                // Redstone update
                getRedstoneConnectionCache().recalculateConnections();
                RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
                sendUpdatePacket();
            }
            return true;
        }
    }
    return false;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) ItemPart(com.bluepowermod.item.ItemPart) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) BPPart(com.bluepowermod.part.BPPart) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)

Example 4 with BPPart

use of com.bluepowermod.part.BPPart in project BluePower by Qmunity.

the class RenderPartItem method render.

private void render(float x, float y, float z, float scale, ItemRenderType type, ItemStack item, Object... data) {
    boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
    boolean alpha = GL11.glGetBoolean(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glPushMatrix();
    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(x, y, z);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    try {
        BPPart part = PartManager.getExample(item);
        part.renderItem(type, item, data);
    } catch (Exception ex) {
    }
    GL11.glPopMatrix();
    if (!blend)
        GL11.glDisable(GL11.GL_BLEND);
    if (!alpha)
        GL11.glDisable(GL11.GL_ALPHA_TEST);
}
Also used : BPPart(com.bluepowermod.part.BPPart)

Example 5 with BPPart

use of com.bluepowermod.part.BPPart in project BluePower by Qmunity.

the class ItemPart method getItemsOnStack.

@Override
public List<ItemStack> getItemsOnStack(ItemStack stack) {
    BPPart part = info.create();
    BPApi.getInstance().loadSilkySettings(part, stack);
    return part.getItemsOnStack(stack);
}
Also used : BPPart(com.bluepowermod.part.BPPart)

Aggregations

BPPart (com.bluepowermod.part.BPPart)5 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)1 ItemPart (com.bluepowermod.item.ItemPart)1 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 ArrayList (java.util.ArrayList)1 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)1