Search in sources :

Example 76 with ItemBlock

use of net.minecraft.item.ItemBlock in project Almura by AlmuraDev.

the class CacheFeature method onRegisterItems.

@SubscribeEvent
public void onRegisterItems(RegistryEvent.Register<Item> event) {
    // TODO do this better
    ItemBlock item = (ItemBlock) new ItemBlock(CacheBlocks.WOOD).setRegistryName(CacheBlocks.WOOD.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
    item = (ItemBlock) new ItemBlock(CacheBlocks.IRON).setRegistryName(CacheBlocks.IRON.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
    item = (ItemBlock) new ItemBlock(CacheBlocks.GOLD).setRegistryName(CacheBlocks.GOLD.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
    item = (ItemBlock) new ItemBlock(CacheBlocks.DIAMOND).setRegistryName(CacheBlocks.DIAMOND.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
    item = (ItemBlock) new ItemBlock(CacheBlocks.NETHER).setRegistryName(CacheBlocks.NETHER.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
    item = (ItemBlock) new ItemBlock(CacheBlocks.ENDER).setRegistryName(CacheBlocks.ENDER.getRegistryName());
    event.getRegistry().register(item);
    if (FMLCommonHandler.instance().getSide().isClient()) {
        this.registerInventoryModel(item, item.getRegistryName());
    }
}
Also used : ItemBlock(net.minecraft.item.ItemBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 77 with ItemBlock

use of net.minecraft.item.ItemBlock in project Almura by AlmuraDev.

the class LookingDebugPanel method renderItemStackFromBlock.

private void renderItemStackFromBlock(final IBlockState state, final ItemStack pickStack) {
    this.clipContent = false;
    // Draw what we know of
    if (!pickStack.isEmpty()) {
        this.drawItem(pickStack, 4, this.autoHeight + 4);
        if (pickStack.getItem() instanceof ItemBlock) {
            this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight - 14, false, true);
        } else {
            this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight - 14, false, true);
        }
    } else {
        this.drawText(Text.of(TextColors.WHITE, Block.REGISTRY.getNameForObject(state.getBlock())), 24, this.autoHeight + 3, false, true);
    }
    final Map<IProperty<?>, Comparable<?>> properties = state.getProperties();
    final boolean hasProperties = !properties.isEmpty();
    if (hasProperties) {
        this.autoHeight -= 2;
    }
    for (final Map.Entry<IProperty<?>, Comparable<?>> entry : properties.entrySet()) {
        final IProperty<?> property = entry.getKey();
        final String name = property.getName();
        final Comparable<?> value = entry.getValue();
        final String describedValue = getName(property, value);
        if (value instanceof Boolean) {
            this.drawText(Text.of(TextColors.WHITE, name, ": ", ((Boolean) value) ? TextColors.GREEN : TextColors.RED, describedValue), 24, this.autoHeight);
        } else {
            this.drawProperty(name, describedValue, 24, pickStack.isEmpty() ? this.autoHeight + 13 : this.autoHeight);
        }
    }
    if (hasProperties) {
        this.autoHeight -= 4;
    }
}
Also used : IProperty(net.minecraft.block.properties.IProperty) NBTTagString(net.minecraft.nbt.NBTTagString) ItemBlock(net.minecraft.item.ItemBlock) Map(java.util.Map)

Example 78 with ItemBlock

use of net.minecraft.item.ItemBlock in project Almura by AlmuraDev.

the class ItemGroupImpl method displayAllRelevantItems.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("ConstantConditions")
public void displayAllRelevantItems(final NonNullList<ItemStack> items) {
    super.displayAllRelevantItems(items);
    if (this.sort) {
        items.sort((o1, o2) -> {
            final Item i1 = o1.getItem();
            final Item i2 = o2.getItem();
            final ResourceLocation id1 = i1 instanceof ItemBlock ? ((ItemBlock) i1).getBlock().getRegistryName() : i1.getRegistryName();
            final ResourceLocation id2 = i2 instanceof ItemBlock ? ((ItemBlock) i2).getBlock().getRegistryName() : i2.getRegistryName();
            return id1.compareTo(id2);
        });
    }
}
Also used : Item(net.minecraft.item.Item) ResourceLocation(net.minecraft.util.ResourceLocation) ItemBlock(net.minecraft.item.ItemBlock) SideOnly(net.minecraftforge.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