Jump to content

[1.7.2]Block Rendering In World Issues[Solved]


grim3212

Recommended Posts

Hello I am having a problem with rendering the block in the world as the title suggests.

 

What is going on is that only the final renderStandardBlock is being called.

 

public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
}

 

So for the method above only this will be called and everything above it is just lost.

 

var4.overrideBlockTexture = texture;
var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
var4.renderStandardBlock(var0, var1, var2, var3);

 

The Renderer is working but only the final parts.

package grim3212.mc.lampposts;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class RenderingHandler implements ISimpleBlockRenderingHandler {

@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
}

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	return modelId == LampPosts.renderID ? this.renderLampPost(block, x, y, z, renderer) : false;
}

@Override
public boolean shouldRender3DInInventory(int modelId) {
	return false;
}

@Override
public int getRenderId() {
	return LampPosts.renderID;
}

public boolean renderLampPost(Block var1, int var2, int var3, int var4, RenderBlocks var5) {
	World var7 = FMLClientHandler.instance().getWorldClient();
	int var8 = var7.getBlockMetadata(var2, var3, var4);
	if (var8 == 0) {
		RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0));
		return RenderLampPost.renderBottom(var1, var2, var3, var4, var5);
	} else if (var8 == 1) {
		RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0));
		return RenderLampPost.renderMiddle(var1, var2, var3, var4, var5);
	} else if (var8 == 2) {
		RenderLampPost.setTexture(Blocks.iron_block.getBlockTextureFromSide(0));
		return RenderLampPost.renderTop(var1, var2, var3, var4, var5);
	} else if (var8 == 3) {
		RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0));
		return RenderLampPost.renderBottom(var1, var2, var3, var4, var5);
	} else if (var8 == 4) {
		RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0));
		return RenderLampPost.renderMiddle(var1, var2, var3, var4, var5);
	} else if (var8 == 5) {
		RenderLampPost.setTexture(Blocks.nether_brick.getBlockTextureFromSide(0));
		return RenderLampPost.renderTop(var1, var2, var3, var4, var5);
	} else {
		return false;
	}
}

}

 

Also just in case I am using Forge 10.12.0.134

 

Any help is appreciated. Thanks

 

EDIT:

 

Workaround:

Instead of using this method I used Techne models instead.

Link to comment
Share on other sites

Hi

 

Do the parts render properly individually?

 

eg

public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
//		var4.overrideBlockTexture = texture;
//		var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F);
//		var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
} 

vs

 

public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F);
	var4.renderStandardBlock(var0, var1, var2, var3);
//		var4.overrideBlockTexture = texture;
//		var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
//		var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
} 

 

-TGG

Link to comment
Share on other sites

It is kind of working.

 

This is what it looks like before commenting it out.

yE7HPjU.png

 

And after which as you can see the part is rendering correctly but should be the bottom piece.

OJYRq0o.png

 

But if I place one in a two block radius then this happens.

cT6576m.png

jdscsJ9.png

 

I have no idea why this would be happening because their is nothing in the Blocks class checking for anything like this.

 

But anyway here is the renderer that renders each of the which might have something in it.

package grim3212.mc.lampposts;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;

public class RenderLampPost {
private static IIcon texture;

public static void setTexture(IIcon var0) {
	texture = var0;
}

public static boolean renderBottom(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 0.1F, 0.8F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
}

public static boolean renderMiddle(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
}

public static boolean renderTop(Block var0, int var1, int var2, int var3, RenderBlocks var4) {
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.1F, 0.2F, 0.1F, 0.9F, 0.3F, 0.9F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.1F, 0.9F, 0.1F, 0.9F, 1.0F, 0.9F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 0.2F, 0.625F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.1F, 0.3F, 0.1F, 0.2F, 0.9F, 0.2F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.8F, 0.3F, 0.8F, 0.9F, 0.9F, 0.9F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.8F, 0.3F, 0.1F, 0.9F, 0.9F, 0.2F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = texture;
	var0.setBlockBounds(0.1F, 0.3F, 0.8F, 0.2F, 0.9F, 0.9F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = Blocks.glowstone.getBlockTextureFromSide(0);
	var0.setBlockBounds(0.2F, 0.3F, 0.2F, 0.8F, 0.9F, 0.8F);
	var4.renderStandardBlock(var0, var1, var2, var3);
	var4.overrideBlockTexture = null;
	return true;
}
}

 

By the way the two block changing look thing only happens when I comment that out so I am completely lost.

 

 

 

Link to comment
Share on other sites

Hi

 

strange stuff.

 

Pure guesses here:

have you overridden Block.isOpaqueCube to return false?

are you doing something strange with Block.shouldSideBeRendered?

Have you tried changing the top, middle, and bottom textures to something different for each one?  perhaps what you think is the bottom block is actually the top block

 

Apart from that, I'm stuck, sorry!

 

-TGG

 

Link to comment
Share on other sites

Well I do have Block.isOpaqueCube set to return false and I also have shouldSideBeRendered to just return true.

Also all of the blocks are correct I did check.

 

Well thanks for all the help! I am going to try and see if I can get this working by using Techne models.

 

EDIT: I got everything working with the Techne models... Still weird that the way I had it didn't work.

 

Anyway thanks for helping.

 

 

 

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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