use of net.minecraft.client.renderer.ItemModelMesher in project HorsePower by GoryMoon.
the class ColorGetter method getTextureAtlasSprite.
@Nullable
private static TextureAtlasSprite getTextureAtlasSprite(ItemStack itemStack) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher itemModelMesher = renderItem.getItemModelMesher();
IBakedModel itemModel = itemModelMesher.getItemModel(itemStack);
return itemModel.getParticleTexture();
}
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()]));
}
use of net.minecraft.client.renderer.ItemModelMesher in project ClaySoldiersMod by SanAndreasP.
the class ParticleNbtItemBreaking method init.
private void init(ItemStack stack) {
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
IBakedModel model = mesher.getItemModel(stack);
this.setParticleTexture(model.getOverrides().handleItemState(model, stack, null, null).getParticleTexture());
ColorObj clr = new ColorObj(Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, 0));
this.particleRed = clr.fRed();
this.particleGreen = clr.fGreen();
this.particleBlue = clr.fBlue();
}
use of net.minecraft.client.renderer.ItemModelMesher in project A-Little-Extra-Tiles by Doc-1.
the class GuiStack method getTexture.
public String getTexture(ItemStack stack) {
Block block = Block.getBlockFromItem(stack.getItem());
Item item = stack.getItem();
int damage = item.getDamage(stack);
int meta = item.getMetadata(damage);
IBlockState state = BlockUtils.getState(block, meta);
Minecraft minecraft = Minecraft.getMinecraft();
if (this.useBlock) {
ResourceLocation reg = block.getRegistryName();
BlockRendererDispatcher ren = minecraft.getBlockRendererDispatcher();
texture = ren.getModelForState(state).getQuads(state, facing, 0).get(0).getSprite().toString();
} else {
RenderItem itemRen = minecraft.getRenderItem();
ItemModelMesher mesher = itemRen.getItemModelMesher();
CreativeBakedModel model;
texture = mesher.getItemModel(stack).getQuads(null, null, 0).get(0).getSprite().toString();
// texture =
// .getQuads(null, null, 0).get(0).getSprite().toString();
}
return texture;
}
Aggregations