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 SilentGems by SilentChaos512.
the class ItemEnchantmentToken method registerModels.
@Override
public boolean registerModels() {
ModelResourceLocation model;
List<ModelResourceLocation> list = getVariants();
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
for (int i = 0; i < list.size(); ++i) {
model = list.get(i);
if (model != null) {
ModelLoader.registerItemVariants(this, model);
mesher.register(this, i, model);
}
}
mesher.register(this, BLANK_META, list.get(0));
return true;
}
use of net.minecraft.client.renderer.ItemModelMesher in project SilentGems by SilentChaos512.
the class ItemTeleporterLinker method registerModels.
@Override
public boolean registerModels() {
ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
ModelResourceLocation model = new ModelResourceLocation(getFullName().toLowerCase(), "inventory");
ModelLoader.registerItemVariants(this, model);
mesher.register(this, 0, model);
mesher.register(this, 1, model);
return true;
}
use of net.minecraft.client.renderer.ItemModelMesher in project LogisticsPipes by RS485.
the class LogisticsRenderPipe method renderItemStackOnSign.
public void renderItemStackOnSign(@Nonnull ItemStack itemstack) {
if (itemstack.isEmpty()) {
// Only happens on false configuration
return;
}
Minecraft mc = Minecraft.getMinecraft();
RenderItem itemRender = mc.getRenderItem();
GlStateManager.disableLighting();
// Forge: Reset color in case Items change it.
GlStateManager.color(1F, 1F, 1F);
// Forge: Make sure blend is enabled else tabs show a white border.
GlStateManager.enableBlend();
itemRender.zLevel = 100.0F;
GlStateManager.enableRescaleNormal();
// itemRender.renderItemAndEffectIntoGUI(itemstack, 0, 0);
// item render code
GlStateManager.pushMatrix();
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.enableAlpha();
GlStateManager.alphaFunc(516, 0.1F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
// mezz.jei.render.ItemStackFastRenderer#getBakedModel
ItemModelMesher itemModelMesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
IBakedModel bakedModel = itemModelMesher.getItemModel(itemstack);
bakedModel = bakedModel.getOverrides().handleItemState(bakedModel, itemstack, null, null);
// make item/block flat and position it
GlStateManager.translate(0.05F, 0F, 0F);
GlStateManager.scale(0.8F, 0.8F, 0.001F);
// model rotation
bakedModel = ForgeHooksClient.handleCameraTransforms(bakedModel, ItemCameraTransforms.TransformType.GUI, false);
// model scaling to fit on sign
GlStateManager.scale(0.4F, 0.4F, 0.4F);
itemRender.renderItem(itemstack, bakedModel);
GlStateManager.disableRescaleNormal();
GlStateManager.disableAlpha();
GlStateManager.popMatrix();
mc.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
mc.renderEngine.getTexture(TextureMap.LOCATION_BLOCKS_TEXTURE).restoreLastBlurMipmap();
// item render code end
// not needed?
// itemRender.renderItemOverlays(mc.fontRenderer, itemstack, 0, 0);
itemRender.zLevel = 0.0F;
}
use of net.minecraft.client.renderer.ItemModelMesher in project FoamFix by asiekierka.
the class FoamFixModelRegistryDuplicateWipe method onTextureStitchPost.
@SubscribeEvent
public void onTextureStitchPost(TextureStitchEvent.Post event) {
ItemModelMesher imm = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
BlockModelShapes bms = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
ModelManager mgr = bms.getModelManager();
Field f = ReflectionHelper.findField(ModelManager.class, "modelRegistry", "field_174958_a");
try {
IRegistry<ModelResourceLocation, IBakedModel> registry = (IRegistry<ModelResourceLocation, IBakedModel>) f.get(mgr);
FoamFix.logger.info("Clearing unnecessary model registry of size " + registry.getKeys().size() + ".");
for (ModelResourceLocation l : registry.getKeys()) {
registry.putObject(l, ProxyClient.DUMMY_MODEL);
}
} catch (Exception e) {
e.printStackTrace();
}
f = ReflectionHelper.findField(BlockModelShapes.class, "bakedModelStore", "field_178129_a");
try {
Map<IBlockState, IBakedModel> modelStore = (Map<IBlockState, IBakedModel>) f.get(bms);
FoamFix.logger.info("Clearing unnecessary model store of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
if (imm instanceof ItemModelMesherForge) {
f = ReflectionHelper.findField(ItemModelMesherForge.class, "models");
try {
IdentityHashMap<Item, TIntObjectHashMap<IBakedModel>> modelStore = (IdentityHashMap<Item, TIntObjectHashMap<IBakedModel>>) f.get(imm);
FoamFix.logger.info("Clearing unnecessary item shapes cache of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations