Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

When ever I run my mod my block always looks like a cube instead of its model

Also this is printed out in the console:

OBJLoader.Parser: command 's' (model: '[My model location]') is not currently supported, skipping

 

this is my code for rendering:

 

package com.sjoopies.eclipsecraft.client.renderer;

 

import java.io.IOException;

import java.util.List;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.WorldRenderer;

import net.minecraft.client.renderer.block.model.BakedQuad;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.client.resources.model.IBakedModel;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.EnumFacing;

import net.minecraft.util.ResourceLocation;

import net.minecraftforge.client.model.Attributes;

import net.minecraftforge.client.model.IModel;

import net.minecraftforge.client.model.ModelLoaderRegistry;

import net.minecraftforge.client.model.TRSRTransformation;

import net.minecraftforge.client.model.obj.OBJLoader;

 

import org.lwjgl.opengl.GL11;

 

import com.google.common.base.Function;

import com.sjoopies.eclipsecraft.ref.ECRef;

 

public class CyrstalRenderer extends TileEntitySpecialRenderer {

 

public static final ResourceLocation texture = new ResourceLocation(ECRef.MODID + ":" + "textures/blocks/crystal.png");

private static final ModelResourceLocation loc = new ModelResourceLocation(ECRef.MODID + ":" + "models/block/crystal.obj");

 

Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {

public TextureAtlasSprite apply(ResourceLocation location) {

return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());

}

};

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {

Tessellator tessellator = Tessellator.getInstance();

this.bindTexture(texture);

 

WorldRenderer worldRenderer = tessellator.getWorldRenderer();

GL11.glPushMatrix();

GL11.glTranslated(x, y, z);

// GL11.glRotatef(i++, 0.0f, 0.0f, 1.0f);

IModel crystalModel = null;

try {

crystalModel = OBJLoader.instance.loadModel(loc);

} catch (IOException e) {

crystalModel = ModelLoaderRegistry.getMissingModel();

e.printStackTrace();

}

IBakedModel bakedModel = crystalModel.bake((TRSRTransformation.identity()), Attributes.DEFAULT_BAKED_FORMAT, textureGetter);

worldRenderer.begin(7, Attributes.DEFAULT_BAKED_FORMAT);// StartDrawingQuads

 

List<BakedQuad> generalQuads = bakedModel.getGeneralQuads();

System.out.println(generalQuads);

for (BakedQuad q : generalQuads)

{

 

int[] vd = q.getVertexData();

worldRenderer.addVertexData(vd);

}

for (EnumFacing face : EnumFacing.values())

{

List<BakedQuad> faceQuads = bakedModel.getFaceQuads(face);

for (BakedQuad q : faceQuads)

{

int[] vd = q.getVertexData();

worldRenderer.addVertexData(vd);

}

}

tessellator.draw();

GL11.glPopMatrix();

 

}

 

}

 

 

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.