use of net.minecraft.client.renderer.ItemModelMesher in project minecolonies by Minecolonies.
the class ClientProxy method registerRenderer.
@Override
public void registerRenderer() {
super.registerRenderer();
final ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBaker), 0, new ModelResourceLocation(ModBlocks.blockHutBaker.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBlacksmith), 0, new ModelResourceLocation(ModBlocks.blockHutBlacksmith.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutBuilder), 0, new ModelResourceLocation(ModBlocks.blockHutBuilder.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutCitizen), 0, new ModelResourceLocation(ModBlocks.blockHutCitizen.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutFarmer), 0, new ModelResourceLocation(ModBlocks.blockHutFarmer.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutFisherman), 0, new ModelResourceLocation(ModBlocks.blockHutFisherman.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutLumberjack), 0, new ModelResourceLocation(ModBlocks.blockHutLumberjack.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutMiner), 0, new ModelResourceLocation(ModBlocks.blockHutMiner.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutStonemason), 0, new ModelResourceLocation(ModBlocks.blockHutStonemason.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutTownHall), 0, new ModelResourceLocation(ModBlocks.blockHutTownHall.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutWareHouse), 0, new ModelResourceLocation(ModBlocks.blockHutWareHouse.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutDeliveryman), 0, new ModelResourceLocation(ModBlocks.blockHutDeliveryman.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSubstitution.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutField), 0, new ModelResourceLocation(ModBlocks.blockHutField.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockHutGuardTower), 0, new ModelResourceLocation(ModBlocks.blockHutGuardTower.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockSolidSubstitution), 0, new ModelResourceLocation(ModBlocks.blockSolidSubstitution.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockConstructionTape), 0, new ModelResourceLocation(ModBlocks.blockConstructionTape.getRegistryName(), INVENTORY));
itemModelMesher.register(Item.getItemFromBlock(ModBlocks.blockConstructionTapeCorner), 0, new ModelResourceLocation(ModBlocks.blockConstructionTapeCorner.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.buildTool, 0, new ModelResourceLocation(ModItems.buildTool.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.caliper, 0, new ModelResourceLocation(ModItems.caliper.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.scanTool, 0, new ModelResourceLocation(ModItems.scanTool.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.scepterGuard, 0, new ModelResourceLocation(ModItems.scepterGuard.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.supplyChest, 0, new ModelResourceLocation(ModItems.supplyChest.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.supplyCamp, 0, new ModelResourceLocation(ModItems.supplyCamp.getRegistryName(), INVENTORY));
// Achievement proxy Items
itemModelMesher.register(ModItems.itemAchievementProxySettlement, 0, new ModelResourceLocation(ModItems.itemAchievementProxySettlement.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.itemAchievementProxyTown, 0, new ModelResourceLocation(ModItems.itemAchievementProxyTown.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.itemAchievementProxyCity, 0, new ModelResourceLocation(ModItems.itemAchievementProxyCity.getRegistryName(), INVENTORY));
itemModelMesher.register(ModItems.itemAchievementProxyMetropolis, 0, new ModelResourceLocation(ModItems.itemAchievementProxyMetropolis.getRegistryName(), INVENTORY));
}
use of net.minecraft.client.renderer.ItemModelMesher in project Bookshelf by Darkhax-Minecraft.
the class RenderUtils method getSprite.
/**
* Gets the TextureAtlasSprite for the ItemStack. Has support for both Items and Blocks.
*
* @param stack The ItemStack to get the sprite for.
* @return The sprite for the ItemStack.
*/
public static TextureAtlasSprite getSprite(ItemStack stack) {
final Minecraft mc = Minecraft.getMinecraft();
final Block block = StackUtils.getBlockFromStack(stack);
if (block == null) {
final ItemModelMesher mesher = mc.getRenderItem().getItemModelMesher();
return !stack.isEmpty() ? mesher.getParticleIcon(stack.getItem(), stack.getItemDamage()) : mesher.getItemModel(null).getParticleTexture();
}
return mc.getBlockRendererDispatcher().getBlockModelShapes().getTexture(block.getStateFromMeta(stack.getItemDamage()));
}
use of net.minecraft.client.renderer.ItemModelMesher in project Binnie by ForestryMC.
the class ControlLumbermillProgress method getWoodSprite.
@SideOnly(Side.CLIENT)
private TextureAtlasSprite getWoodSprite(ItemStack stack) {
Minecraft mc = Minecraft.getMinecraft();
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher modelMesher = renderItem.getItemModelMesher();
IBakedModel model = modelMesher.getItemModel(stack);
TextureAtlasSprite sprite = model.getParticleTexture();
if (sprite == mc.getTextureMapBlocks().getMissingSprite()) {
return getWoodSprite(new ItemStack(Blocks.LOG));
}
return sprite;
}
use of net.minecraft.client.renderer.ItemModelMesher in project Skree by Skelril.
the class CustomItemSystem method render.
// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object item) {
if (item instanceof Item && item instanceof ICustomItem) {
if (Sponge.getPlatform().getExecutionType().isClient()) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher mesher = renderItem.getItemModelMesher();
Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition();
if (optMeshDefinition.isPresent()) {
mesher.register((Item) item, optMeshDefinition.get());
}
List<String> variants = ((ICustomItem) item).__getMeshDefinitions();
List<ResourceLocation> modelResources = new ArrayList<>();
for (int i = 0; i < variants.size(); ++i) {
ModelResourceLocation resourceLocation = new ModelResourceLocation("skree:" + variants.get(i), "inventory");
if (!optMeshDefinition.isPresent()) {
mesher.register((Item) item, i, resourceLocation);
}
modelResources.add(resourceLocation);
}
ModelBakery.registerItemVariants((Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
}
} else {
throw new IllegalArgumentException("Invalid custom item!");
}
}
use of net.minecraft.client.renderer.ItemModelMesher in project Skree by Skelril.
the class GameIntegrator method registerItemRendering.
private void registerItemRendering(ItemDescriptor descriptor) {
Item item = descriptor.item;
ItemConfig config = descriptor.config;
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher mesher = renderItem.getItemModelMesher();
// TODO Custom mesher currently not supported
// Optional<ItemMeshDefinition> optMeshDefinition = (item).__getCustomMeshDefinition();
// if (optMeshDefinition.isPresent()) {
// mesher.register((Item) item, optMeshDefinition.get());
// }
List<String> variants = config.getMeshDefinitions();
List<ResourceLocation> modelResources = new ArrayList<>();
for (int i = 0; i < variants.size(); ++i) {
ModelResourceLocation resourceLocation = new ModelResourceLocation(modID + ":" + variants.get(i), "inventory");
// if (!optMeshDefinition.isPresent()) {
mesher.register(item, i, resourceLocation);
// }
modelResources.add(resourceLocation);
}
ModelBakery.registerItemVariants(item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
}
Aggregations