Search in sources :

Example 1 with IBakedModel

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();
}
Also used : IBakedModel(net.minecraft.client.resources.model.IBakedModel) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 2 with IBakedModel

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);
        }
    }
}
Also used : ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.resources.model.IBakedModel) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) IOException(java.io.IOException)

Example 3 with IBakedModel

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);
}
Also used : EnumSimplePacket(micdoodle8.mods.galacticraft.core.network.PacketSimple.EnumSimplePacket) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) OBJModel(net.minecraftforge.client.model.obj.OBJModel) IFlexibleBakedModel(net.minecraftforge.client.model.IFlexibleBakedModel) Item(net.minecraft.item.Item) GameRegistry(net.minecraftforge.fml.common.registry.GameRegistry) SpaceRaceManager(micdoodle8.mods.galacticraft.core.dimension.SpaceRaceManager) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ImmutableList(com.google.common.collect.ImmutableList) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) Sys(org.lwjgl.Sys) WorldRenderer(net.minecraft.client.renderer.WorldRenderer) GL11(org.lwjgl.opengl.GL11) SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ModelTransformWrapper(micdoodle8.mods.galacticraft.core.wrappers.ModelTransformWrapper) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Function(com.google.common.base.Function) OBJLoaderGC(micdoodle8.mods.galacticraft.core.client.model.OBJLoaderGC) ModelBakery(net.minecraft.client.resources.model.ModelBakery) ScaledResolution(net.minecraft.client.gui.ScaledResolution) IBakedModel(net.minecraft.client.resources.model.IBakedModel) IOException(java.io.IOException) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) IModel(net.minecraftforge.client.model.IModel) ClientProxyCore(micdoodle8.mods.galacticraft.core.proxy.ClientProxyCore) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) GalacticraftCore(micdoodle8.mods.galacticraft.core.GalacticraftCore) List(java.util.List) Tessellator(net.minecraft.client.renderer.Tessellator) FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) ResourceLocation(net.minecraft.util.ResourceLocation) IModelState(net.minecraftforge.client.model.IModelState) TRSRTransformation(net.minecraftforge.client.model.TRSRTransformation) IModel(net.minecraftforge.client.model.IModel) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) OBJModel(net.minecraftforge.client.model.obj.OBJModel)

Example 4 with IBakedModel

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);
            }
        }
    }
}
Also used : StackAtPosition(buildcraft.core.StackAtPosition) IBakedModel(net.minecraft.client.resources.model.IBakedModel)

Example 5 with IBakedModel

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);
    }
}
Also used : ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) IBakedModel(net.minecraft.client.resources.model.IBakedModel) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IBakedModel (net.minecraft.client.resources.model.IBakedModel)9 ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)4 Minecraft (net.minecraft.client.Minecraft)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Function (com.google.common.base.Function)2 IOException (java.io.IOException)2 OBJLoaderGC (micdoodle8.mods.galacticraft.core.client.model.OBJLoaderGC)2 Block (net.minecraft.block.Block)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 DefaultVertexFormats (net.minecraft.client.renderer.vertex.DefaultVertexFormats)2 TRSRTransformation (net.minecraftforge.client.model.TRSRTransformation)2 OBJModel (net.minecraftforge.client.model.obj.OBJModel)2 RedstoneBoardRobotNBT (buildcraft.api.boards.RedstoneBoardRobotNBT)1 StackAtPosition (buildcraft.core.StackAtPosition)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 List (java.util.List)1 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)1