Search in sources :

Example 31 with ItemBlock

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

the class FlickerOperatorFelledOak method getPlantLocation.

private AMVector3 getPlantLocation(World worldObj, IFlickerController habitat, ItemStack sapling) {
    if (sapling.getItem() instanceof ItemBlock == false)
        return null;
    TileEntity te = (TileEntity) habitat;
    byte[] data = habitat.getMetadata(this);
    AMVector3 offset = null;
    if (data == null || data.length == 0) {
        offset = new AMVector3(te.xCoord - radius_horiz, te.yCoord - radius_vert, te.zCoord - radius_horiz);
    } else {
        AMDataReader reader = new AMDataReader(data, false);
        offset = new AMVector3(reader.getInt(), te.yCoord - radius_vert, reader.getInt());
    }
    Block treeBlock = ((ItemBlock) sapling.getItem()).field_150939_a;
    for (int i = (int) offset.x; i <= te.xCoord + radius_horiz; i += 2) {
        for (int k = (int) offset.z; k <= te.zCoord + radius_horiz; k += 2) {
            for (int j = (int) offset.y; j <= te.yCoord + radius_vert; ++j) {
                Block block = worldObj.getBlock(i, j, k);
                if (block.isReplaceable(worldObj, i, j, k) && treeBlock.canPlaceBlockAt(worldObj, i, j, k)) {
                    AMDataWriter writer = new AMDataWriter();
                    writer.add(i).add(k);
                    habitat.setMetadata(this, writer.generate());
                    return new AMVector3(i, j, k);
                }
            }
        }
    }
    AMDataWriter writer = new AMDataWriter();
    writer.add(te.xCoord - radius_horiz).add(te.zCoord - radius_horiz);
    habitat.setMetadata(this, writer.generate());
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) AMDataReader(am2.network.AMDataReader) ItemBlock(net.minecraft.item.ItemBlock) AMDataWriter(am2.network.AMDataWriter)

Example 32 with ItemBlock

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

the class RenderMageWizard method func_82411_a.

protected void func_82411_a(EntityMageVillager par1EntityMageVillager, float par2) {
    float f1 = 1.0F;
    GL11.glColor3f(f1, f1, f1);
    super.renderEquippedItems(par1EntityMageVillager, par2);
    ItemStack itemstack = par1EntityMageVillager.getHeldItem();
    if (itemstack != null) {
        GL11.glPushMatrix();
        float f2;
        if (this.mainModel.isChild) {
            f2 = 0.5F;
            GL11.glTranslatef(0.0F, 0.625F, 0.0F);
            GL11.glRotatef(-20.0F, -1.0F, 0.0F, 0.0F);
            GL11.glScalef(f2, f2, f2);
        }
        this.field_82414_a.villagerNose.postRender(0.0625F);
        GL11.glTranslatef(-0.0625F, 0.53125F, 0.21875F);
        if (itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType())) {
            f2 = 0.5F;
            GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
            f2 *= 0.75F;
            GL11.glRotatef(20.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
            GL11.glScalef(f2, -f2, f2);
        } else if (itemstack.getItem() == Items.bow) {
            f2 = 0.625F;
            GL11.glTranslatef(0.0F, 0.125F, 0.3125F);
            GL11.glRotatef(-20.0F, 0.0F, 1.0F, 0.0F);
            GL11.glScalef(f2, -f2, f2);
            GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        } else if (itemstack.getItem().isFull3D()) {
            f2 = 0.625F;
            if (itemstack.getItem().shouldRotateAroundWhenRendering()) {
                GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
                GL11.glTranslatef(0.0F, -0.125F, 0.0F);
            }
            this.func_82410_b();
            GL11.glScalef(f2, -f2, f2);
            GL11.glRotatef(-100.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(45.0F, 0.0F, 1.0F, 0.0F);
        } else {
            f2 = 0.375F;
            GL11.glTranslatef(0.25F, 0.1875F, -0.1875F);
            GL11.glScalef(f2, f2, f2);
            GL11.glRotatef(60.0F, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(20.0F, 0.0F, 0.0F, 1.0F);
        }
        GL11.glRotatef(-15.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(40.0F, 0.0F, 0.0F, 1.0F);
        this.renderManager.itemRenderer.renderItem(par1EntityMageVillager, itemstack, 0);
        if (itemstack.getItem().requiresMultipleRenderPasses()) {
            this.renderManager.itemRenderer.renderItem(par1EntityMageVillager, itemstack, 1);
        }
        GL11.glPopMatrix();
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 33 with ItemBlock

use of net.minecraft.item.ItemBlock in project AgriCraft by AgriCraft.

the class OreDictHelper method getOreBlock.

private static void getOreBlock(AgriNuggetType type) {
    for (ItemStack itemStack : OreDictionary.getOres(type.ore)) {
        if (itemStack.getItem() instanceof ItemBlock) {
            ItemBlock block = (ItemBlock) itemStack.getItem();
            oreBlocks.put(type.name(), block.getBlock());
            oreBlockMeta.put(type.name(), itemStack.getItemDamage());
            return;
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 34 with ItemBlock

use of net.minecraft.item.ItemBlock in project BetterWithAddons by DaedalusGame.

the class ItemCarpenterSaw method isItemCarpentry.

public static boolean isItemCarpentry(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    Item item = stack.getItem();
    if (item instanceof ItemBlock) {
        Block block = ((ItemBlock) item).getBlock();
        IBlockState state = block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, stack.getMetadata(), player, hand);
        return isCarpentry(stack, state);
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock)

Example 35 with ItemBlock

use of net.minecraft.item.ItemBlock in project BetterWithAddons by DaedalusGame.

the class ItemMasonPick method isItemMasonry.

public static boolean isItemMasonry(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    Item item = stack.getItem();
    if (item instanceof ItemBlock) {
        Block block = ((ItemBlock) item).getBlock();
        IBlockState state = block.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, stack.getMetadata(), player, hand);
        return isMasonry(stack, state);
    }
    return false;
}
Also used : Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock)

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