Search in sources :

Example 36 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)

Example 37 with ItemBlock

use of net.minecraft.item.ItemBlock in project LogisticsPipes by RS485.

the class ModuleCrafter method openAttachedGui.

public void openAttachedGui(EntityPlayer player) {
    if (MainProxy.isClient(player.worldObj)) {
        if (player instanceof EntityPlayerMP) {
            player.closeScreen();
        } else if (player instanceof EntityPlayerSP) {
            player.closeScreen();
        }
        MainProxy.sendPacketToServer(PacketHandler.getPacket(CraftingPipeOpenConnectedGuiPacket.class).setModulePos(this));
        return;
    }
    // hack to avoid wrenching blocks
    int savedEquipped = player.inventory.currentItem;
    boolean foundSlot = false;
    // try to find a empty slot
    for (int i = 0; i < 9; i++) {
        if (player.inventory.getStackInSlot(i) == null) {
            foundSlot = true;
            player.inventory.currentItem = i;
            break;
        }
    }
    // okay, anything that's a block?
    if (!foundSlot) {
        for (int i = 0; i < 9; i++) {
            ItemStack is = player.inventory.getStackInSlot(i);
            if (is.getItem() instanceof ItemBlock) {
                foundSlot = true;
                player.inventory.currentItem = i;
                break;
            }
        }
    }
    // give up and select whatever is right of the current slot
    if (!foundSlot) {
        player.inventory.currentItem = (player.inventory.currentItem + 1) % 9;
    }
    WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(getWorld(), getX(), getY(), getZ());
    worldCoordinates.getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).anyMatch(adjacent -> {
        boolean found = SimpleServiceLocator.craftingRecipeProviders.stream().anyMatch(provider -> provider.canOpenGui(adjacent.tileEntity));
        if (!found) {
            found = (adjacent.tileEntity instanceof IInventory);
        }
        if (found) {
            Block block = getWorld().getBlock(adjacent.tileEntity.xCoord, adjacent.tileEntity.yCoord, adjacent.tileEntity.zCoord);
            if (block != null && block.onBlockActivated(getWorld(), adjacent.tileEntity.xCoord, adjacent.tileEntity.yCoord, adjacent.tileEntity.zCoord, player, 0, 0, 0, 0)) {
                return true;
            }
        }
        return false;
    });
    player.inventory.currentItem = savedEquipped;
}
Also used : IInventory(net.minecraft.inventory.IInventory) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 38 with ItemBlock

use of net.minecraft.item.ItemBlock in project malmo by Microsoft.

the class MinecraftTypeHelper method attemptToGetAsVariant.

/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
     * (eg blue_orchid vs orchidBlue etc.)
     * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
     * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
     * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
     */
public static Variation attemptToGetAsVariant(String part, ItemStack is) {
    if (is.getItem() instanceof ItemBlock) {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock) (is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : (java.util.Set<IProperty>) bs.getProperties().keySet()) {
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    } else
        return attemptToGetAsVariant(part);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IProperty(net.minecraft.block.properties.IProperty) ItemBlock(net.minecraft.item.ItemBlock) Variation(com.microsoft.Malmo.Schemas.Variation)

Example 39 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class ReplacementBlock method getMeta.

/**
	 * Called to get the metadata of the replacement block in the world.
	 * @param world The world object
	 * @param x The X coord
	 * @param y The Y coord
	 * @param z The Z coord
	 * @param stack The ItemStack being used to replace the block (may be null)
	 * @return The metadata of the block
	 */
protected int getMeta(World world, int x, int y, int z, ItemStack stack) {
    int m = 0;
    if (_hasMeta > 0) {
        if (_hasMeta > 1)
            return _meta;
        m = stack.getItemDamage();
        Item item = stack.getItem();
        if (item instanceof ItemBlock)
            m = ((ItemBlock) item).getMetadata(m);
    }
    return m;
}
Also used : Item(net.minecraft.item.Item) ItemBlock(net.minecraft.item.ItemBlock)

Example 40 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class RenderChargingStationPad method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    TileEntity te = world.getTileEntity(x, y, z);
    if (te instanceof TileEntityChargingStation) {
        TileEntityChargingStation station = (TileEntityChargingStation) te;
        if (station.getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE) > 0) {
            ItemStack camo = station.getCamoStack();
            Block camoBlock = ((ItemBlock) camo.getItem()).field_150939_a;
            renderer.renderAllFaces = true;
            renderer.setOverrideBlockTexture(camoBlock.getIcon(0, camo.getItemDamage()));
            renderer.setRenderBounds(0, 15 / 16D, 0, 1, 1, 1);
            renderer.renderStandardBlock(block, x, y, z);
            renderer.setOverrideBlockTexture(null);
            renderer.renderAllFaces = false;
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChargingStation(pneumaticCraft.common.tileentity.TileEntityChargingStation) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)69 Block (net.minecraft.block.Block)36 ItemStack (net.minecraft.item.ItemStack)34 Item (net.minecraft.item.Item)14 IBlockState (net.minecraft.block.state.IBlockState)7 EntityItem (net.minecraft.entity.item.EntityItem)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 RenderItem (net.minecraft.client.renderer.entity.RenderItem)3 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 IOwnable (net.geforcemods.securitycraft.api.IOwnable)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ChatComponentText (net.minecraft.util.ChatComponentText)2