Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12] TESR rendering .obj model way too dark


TheTrollguy_
 Share

Recommended Posts

So I'm trying to render my .obj model in my TESR, but it is always dark. If I don't disable the lighting, it renders completely black.

 

What am I doing wrong? Is there something to tweak while exporting my models or?

 

P.S. I'm using TESR because there are going to be some animations and whatnot, so don't bother telling me that I shouldn't use TESR when I should. 

 

TESRCounter.java

package tt.kitchenstuffmod.client.renderer.blockentity;

import org.lwjgl.opengl.GL11;

import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelRenderer;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import tt.kitchenstuffmod.blockentity.BlockEntityCounter;
import tt.kitchenstuffmod.main.KitchenStuffMod;
import tt.kitchenstuffmod.util.ModelLoader;

@SideOnly(Side.CLIENT)
public class TESRCounter extends TileEntitySpecialRenderer<BlockEntityCounter>
{
	private static IBakedModel top;
	private static IBakedModel body;
	private static IBakedModel lower;
	private static IBakedModel upper;
	
	public static void loadModels()
	{
		
		top = ModelLoader.loadModel("counter/counter_top"); // 'loadModel' just loads the models and handles exceptions, nothing special...
		body = ModelLoader.loadModel("counter/top_01");
		lower = ModelLoader.loadModel("counter/lowerdraw");
		upper = ModelLoader.loadModel("counter/upperdraw"); 
		KitchenStuffMod.log("Models loaded...");
	}
	
	private Tessellator tessellator;
	private BufferBuilder buffer;
	private World world;
	private BlockPos position;
	private IBlockState block_state;

	private BlockModelRenderer renderer = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer();
		
	@Override
	public void render(BlockEntityCounter block_entity, double x, double y, double z, float partial_ticks, int destroy_stage, float alpha)
	{
		this.tessellator = Tessellator.getInstance();
		this.buffer = this.tessellator.getBuffer();
		this.world = block_entity.getWorld();
		this.position = block_entity.getPos();
		this.block_state = world.getBlockState(position);
		
		BlockPos entity_position = block_entity.getPos();
		
		push_all();

		GlStateManager.translate(x - entity_position.getX(), y - entity_position.getY(), z - entity_position.getZ());
		
        GlStateManager.disableLighting();
        
        // the name of the texture is wrong, on purpose (top get the purple-black thingy)
        render_model(body, new ResourceLocation("minecraft", "textures/blocks/planks_fbirch.png"));
  
        pop_all();    

	}
	
	private void render_model(IBakedModel model, ResourceLocation texture)
	{
		this.buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
		this.bindTexture(texture);
		this.renderer.renderModel(world, model, block_state, position, buffer, true);
		this.tessellator.draw();
	}
	
	private void push()
	{
        GlStateManager.pushMatrix();
	}
	
	private void push_all()
	{
		GlStateManager.pushAttrib();
        GlStateManager.pushMatrix();
	}
	
	private void pop()
	{
		GlStateManager.popMatrix();
	}
	
	private void pop_all()
	{
		GlStateManager.popMatrix();
        GlStateManager.popAttrib();
	}
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I have been trying to download Forge but the Windows Installer isn't coming up, I can see the installer one would use for Linux but no Windows, I have downloaded Java and Jarfix but nothing is working, can someone help?  
    • So I thought that when a capability is attached to an item/entity/etc... the capability will stay until whatever it's attached to is gone. But this doesn't seem to be the case, as when I printed to console whenever a capability is attached, it seems as though a new version of the capability is attached to an item every time I select it in my hotbar, hover over it in inventory, etc. Is this how it's supposed to work? If so, why?
    • Hi, I'm trying to set up a simple forge server just to play with a couple of my friends, but no matter what I do or try I cannot seem to get a Mods folder and for the actual forge part of the server to actually launch. Every time I try to launch the forge.jar via a .bat file I just get a bunch of errors [Errors below] I'm not sure what I'm doing wrong. If I can get some help that would be awesome, thanks C:\Users\User\Desktop\Server>java -Xms2G -Xmx6G -jar forge-1.12.2-14.23.5.2855.jar nogui A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.base/java.lang.reflect.Method.invoke(Method.java:567)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)         at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34) Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader 'bootstrap')         at net.minecraft.launchwrapper.Launch.<init>(Launch.java:34)         at net.minecraft.launchwrapper.Launch.main(Launch.java:28)         ... 6 more C:\Users\User\Desktop\Server>pause Press any key to continue . . .  
    • Is it ok if i ask what that is?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.