use of net.minecraft.client.resources.model.IBakedModel in project Hyperium by HyperiumClient.
the class ClientPhysic method doRender.
public static void doRender(Entity entity, double x, double y, double z) {
rotation = (double) (System.nanoTime() - tick) / 2500000 * ItemDummyContainer.rotateSpeed;
if (!mc.inGameHasFocus)
rotation = 0;
EntityItem item = ((EntityItem) entity);
ItemStack itemstack = item.getEntityItem();
int i = itemstack != null && itemstack.getItem() != null ? Item.getIdFromItem(itemstack.getItem()) + itemstack.getMetadata() : 187;
random.setSeed(i);
Minecraft.getMinecraft().getTextureManager().bindTexture(getEntityTexture());
Minecraft.getMinecraft().getTextureManager().getTexture(getEntityTexture()).setBlurMipmap(false, false);
GlStateManager.enableRescaleNormal();
GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
GlStateManager.enableBlend();
RenderHelper.enableStandardItemLighting();
GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GlStateManager.pushMatrix();
IBakedModel ibakedmodel = mc.getRenderItem().getItemModelMesher().getItemModel(itemstack);
boolean flag1 = ibakedmodel.isGui3d();
boolean is3D = ibakedmodel.isGui3d();
int j = getModelCount(itemstack);
GlStateManager.translate((float) x, (float) y, (float) z);
if (ibakedmodel.isGui3d())
GlStateManager.scale(0.5F, 0.5F, 0.5F);
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(item.rotationYaw, 0.0F, 0.0F, 1.0F);
GlStateManager.translate(0, 0, is3D ? -0.08 : -0.04);
// Handle Rotations
if (is3D || mc.getRenderManager().options != null) {
if (is3D) {
if (!item.onGround) {
double rotation = ClientPhysic.rotation * 2;
item.rotationPitch += rotation;
}
} else {
if (!Double.isNaN(item.posX) && !Double.isNaN(item.posY) && !Double.isNaN(item.posZ) && item.worldObj != null) {
if (item.onGround) {
item.rotationPitch = 0;
} else {
double rotation = ClientPhysic.rotation * 2;
item.rotationPitch += rotation;
}
}
}
GlStateManager.rotate(item.rotationPitch, 1, 0, 0.0F);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
for (int k = 0; k < j; k++) {
GlStateManager.pushMatrix();
if (flag1) {
if (k > 0) {
float f7 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f9 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
float f6 = (random.nextFloat() * 2.0F - 1.0F) * 0.15F;
GlStateManager.translate(f7, f9, f6);
}
mc.getRenderItem().renderItem(itemstack, ibakedmodel);
GlStateManager.popMatrix();
} else {
mc.getRenderItem().renderItem(itemstack, ibakedmodel);
GlStateManager.popMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.05375F);
}
}
GlStateManager.popMatrix();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
Minecraft.getMinecraft().getTextureManager().bindTexture(getEntityTexture());
Minecraft.getMinecraft().getTextureManager().getTexture(getEntityTexture()).restoreLastBlurMipmap();
}
use of net.minecraft.client.resources.model.IBakedModel in project Galacticraft by micdoodle8.
the class ClientUtil method replaceModel.
public static void replaceModel(String modid, ModelBakeEvent event, String resLoc, String objLoc, List<String> visibleGroups, Class<? extends ModelTransformWrapper> clazz, IModelState parentState, String... variants) {
if (variants.length == 0) {
variants = new String[] { "inventory" };
}
IBakedModel newModel;
try {
newModel = modelFromOBJ(new ResourceLocation(modid, objLoc), visibleGroups, parentState);
if (clazz != null) {
newModel = clazz.getConstructor(IBakedModel.class).newInstance(newModel);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
for (String variant : variants) {
ModelResourceLocation modelResourceLocation = new ModelResourceLocation(modid + ":" + resLoc, variant);
IBakedModel object = event.modelRegistry.getObject(modelResourceLocation);
if (object != null) {
event.modelRegistry.putObject(modelResourceLocation, newModel);
}
}
}
use of net.minecraft.client.resources.model.IBakedModel in project Galacticraft by micdoodle8.
the class ClientUtil method modelFromOBJ.
public static IBakedModel modelFromOBJ(ResourceLocation loc, List<String> visibleGroups, IModelState parentState) throws IOException {
IModel model = OBJLoaderGC.instance.loadModel(loc);
Function<ResourceLocation, TextureAtlasSprite> spriteFunction = location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
return model.bake(new OBJModel.OBJState(visibleGroups, false, parentState), DefaultVertexFormats.ITEM, spriteFunction);
}
use of net.minecraft.client.resources.model.IBakedModel in project BuildCraft by BuildCraft.
the class RenderBuildingItems method doRenderItem.
private void doRenderItem(BuildingItem i, float light) {
if (i == null) {
return;
}
i.displayUpdate();
for (StackAtPosition s : i.getStacks()) {
if (s.display) {
if (s.stack != null) {
IBakedModel model = renderItem.getItemModelMesher().getItemModel(s.stack);
if (model != null) {
float renderScale = 0.7f;
GL11.glPushMatrix();
GL11.glTranslatef((float) s.pos.xCoord, (float) s.pos.yCoord, (float) s.pos.zCoord);
GL11.glTranslatef(0, 0.25F, 0);
GL11.glScalef(renderScale, renderScale, renderScale);
renderItem.renderItem(s.stack, model);
GL11.glPopMatrix();
} else {
BCLog.logger.warn("Model was null for " + s.stack);
}
} else {
BCLog.logger.warn("ItemStack was null for " + s + ", " + i);
}
}
}
}
use of net.minecraft.client.resources.model.IBakedModel in project BuildCraft by BuildCraft.
the class BuildCraftFactory method registerModels.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerModels(ModelBakeEvent event) {
ModelResourceLocation mrl = new ModelResourceLocation("buildcraftfactory:blockChute");
// for (ModelResourceLocation entry : ((RegistrySimple<ModelResourceLocation, IBakedModel>)
// event.modelRegistry).getKeys()) {
// String str = entry.toString();
// if (str.contains("buildcraftfactory")) {
// BCLog.logger.info(str);
// }
// }
IBakedModel model = event.modelRegistry.getObject(mrl);
if (model != null) {
event.modelRegistry.putObject(mrl, ChuteRenderModel.create(model));
}
if (Loader.isModLoaded("BuildCraft|Energy")) {
ComplexRefiningManager.registerModels(event);
}
}
Aggregations