Search in sources :

Example 61 with ItemBlock

use of net.minecraft.item.ItemBlock in project ArsMagica2 by Mithion.

the class GuiArcaneCompendium method renderItemToolTip.

private void renderItemToolTip(ItemStack stack, int x, int y) {
    try {
        List list = stack.getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips);
        CompendiumEntry entry;
        if (stack.getItem() instanceof ItemBlock) {
            ItemBlock item = (ItemBlock) stack.getItem();
            Block block = item.field_150939_a;
            String name = block.getUnlocalizedName().replace("arsmagica2:", "").replace("tile.", "");
            String metaname = name + "@" + stack.getItemDamage();
            entry = ArcaneCompendium.instance.getEntry(metaname);
            if (entry == null)
                entry = ArcaneCompendium.instance.getEntry(name);
        } else {
            if (stack.getItem() == ItemsCommonProxy.spell_component) {
                list.clear();
                ISkillTreeEntry skill = SkillManager.instance.getSkill(stack.getItemDamage());
                if (skill == null)
                    return;
                list.add(SkillManager.instance.getDisplayName(skill));
                entry = ArcaneCompendium.instance.getEntry(SkillManager.instance.getSkillName(skill));
            } else {
                String name = stack.getItem().getUnlocalizedName().replace("item.", "").replace("arsmagica2:", "");
                String metaname = name + "@" + stack.getItemDamage();
                entry = ArcaneCompendium.instance.getEntry(metaname);
                if (entry == null)
                    entry = ArcaneCompendium.instance.getEntry(name);
            }
        }
        for (int k = 0; k < list.size(); ++k) {
            if (k == 0) {
                if (entry != null) {
                    list.set(k, "§2" + (String) list.get(k));
                } else {
                    list.set(k, "§" + stack.getRarity().rarityColor.getFormattingCode() + (String) list.get(k));
                }
            } else {
                list.set(k, EnumChatFormatting.GRAY + (String) list.get(k));
            }
        }
        //split out multiline entries (only entry 0 in this case)
        if (((String) list.get(0)).indexOf('\n') != -1) {
            String s = ((String) list.get(0));
            String colorPrefix = "";
            list.remove(0);
            if (entry != null) {
                colorPrefix = "§2";
            } else {
                colorPrefix = "§" + stack.getRarity().rarityColor.getFormattingCode();
            }
            String[] split = s.split("\n");
            for (int i = split.length - 1; i >= 0; --i) {
                list.add(0, colorPrefix + split[i]);
            }
        }
        FontRenderer font = stack.getItem().getFontRenderer(stack);
        drawHoveringText(list, x, y, (font == null ? this.fontRendererObj : font));
    } catch (Throwable t) {
    }
}
Also used : ISkillTreeEntry(am2.api.spell.component.interfaces.ISkillTreeEntry) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) EntityList(net.minecraft.entity.EntityList) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemBlock(net.minecraft.item.ItemBlock)

Example 62 with ItemBlock

use of net.minecraft.item.ItemBlock in project MineFactoryReloaded by powercrystals.

the class TileEntityBlockPlacer method activateMachine.

@Override
protected boolean activateMachine() {
    for (int i = 0; i < getSizeInventory(); i++) {
        if (_inventory[i] == null || !(_inventory[i].getItem() instanceof ItemBlock)) {
            continue;
        }
        BlockPosition bp = BlockPosition.fromFactoryTile(this);
        bp.moveForwards(1);
        if (worldObj.isAirBlock(bp.x, bp.y, bp.z)) {
            worldObj.setBlock(bp.x, bp.y, bp.z, _inventory[i].itemID, _inventory[i].getItemDamage(), 3);
            Block block = Block.blocksList[_inventory[i].itemID];
            worldObj.playSoundEffect(bp.x + 0.5, bp.y + 0.5, bp.z + 0.5, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F);
            decrStackSize(i, 1);
            return true;
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : BlockPosition(powercrystals.core.position.BlockPosition) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock)

Example 63 with ItemBlock

use of net.minecraft.item.ItemBlock in project MineFactoryReloaded by powercrystals.

the class TileEntityBlockSmasher method getOutput.

private ItemStack getOutput(ItemStack input) {
    if (!(input.getItem() instanceof ItemBlock)) {
        return null;
    }
    int blockId = ((ItemBlock) input.getItem()).getBlockID();
    Block b = Block.blocksList[blockId];
    if (b == null) {
        return null;
    }
    @SuppressWarnings("rawtypes") ArrayList drops = _smashingWorld.smashBlock(b, blockId, input.getItemDamage(), _fortune);
    // TODO: support multiple-output
    if (drops != null && drops.size() > 0) {
        // HACK: randomly return one of the drops
        return (ItemStack) drops.get(drops.size() > 1 ? _rand.nextInt(drops.size()) : 0);
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack)

Example 64 with ItemBlock

use of net.minecraft.item.ItemBlock in project RecurrentComplex by Ivorforce.

the class RCRegistryHandler method register.

@Deprecated
public static void register(Block block, String id, Class<? extends ItemBlock> itemClass, Object... itemArgs) {
    ItemBlock item = FMLUtils.constructItem(block, itemClass, itemArgs);
    register(block, id, item != null ? item : new ItemBlock(block));
}
Also used : ItemBlock(net.minecraft.item.ItemBlock)

Example 65 with ItemBlock

use of net.minecraft.item.ItemBlock in project BluePower by Qmunity.

the class TubeStack method render.

@SideOnly(Side.CLIENT)
public void render(float partialTick) {
    if (renderMode == RenderMode.AUTO) {
        renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL : RenderMode.REDUCED;
    }
    final RenderMode finalRenderMode = renderMode;
    if (customRenderItem == null) {
        customRenderItem = new RenderItem() {

            @Override
            public boolean shouldBob() {
                return false;
            }

            ;

            @Override
            public byte getMiniBlockCount(ItemStack stack, byte original) {
                return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original;
            }
        };
        customRenderItem.setRenderManager(RenderManager.instance);
        renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
        renderedItem.hoverStart = 0.0F;
    }
    renderedItem.setEntityItemStack(stack);
    double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;
    GL11.glPushMatrix();
    GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5, heading.offsetZ * renderProgress * 0.5);
    if (finalRenderMode != RenderMode.NONE) {
        GL11.glPushMatrix();
        if (stack.stackSize > 5) {
            GL11.glScaled(0.8, 0.8, 0.8);
        }
        if (!(stack.getItem() instanceof ItemBlock)) {
            GL11.glScaled(0.8, 0.8, 0.8);
            GL11.glTranslated(0, -0.15, 0);
        }
        customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    } else {
        float size = 0.02F;
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBegin(GL11.GL_QUADS);
        RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    if (color != TubeColor.NONE) {
        float size = 0.2F;
        int colorInt = ItemDye.field_150922_c[color.ordinal()];
        float red = (colorInt >> 16) / 256F;
        float green = (colorInt >> 8 & 255) / 256F;
        float blue = (colorInt & 255) / 256F;
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor3f(red, green, blue);
        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
        RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size));
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
    }
    GL11.glPopMatrix();
}
Also used : RenderItem(net.minecraft.client.renderer.entity.RenderItem) ResourceLocation(net.minecraft.util.ResourceLocation) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) EntityItem(net.minecraft.entity.item.EntityItem) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)78 Block (net.minecraft.block.Block)41 ItemStack (net.minecraft.item.ItemStack)37 Item (net.minecraft.item.Item)20 IBlockState (net.minecraft.block.state.IBlockState)11 EntityItem (net.minecraft.entity.item.EntityItem)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 IProperty (net.minecraft.block.properties.IProperty)3 RenderItem (net.minecraft.client.renderer.entity.RenderItem)3 EnumFacing (net.minecraft.util.EnumFacing)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 BlockPos (net.minecraft.util.math.BlockPos)3 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 ChatComponentText (net.minecraft.util.ChatComponentText)2