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());
}
}
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;
}
}
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);
});
}
}
Aggregations