Jump to content

Flipping an ISimpleBlockRenderingHandler 180 degress (upside down)


Recommended Posts

Posted

Hey guys. So, I have an ISimpleBlockRenderingHandler that renders a block, and I wasnt to make it render upside down... what would the easiest way to this be? It uses the tesselator and all that and draws all the points so.. idk.. I have tried things like glRotate and all that and nothing seems to work. If anyone knows how to do this, PLEASE let me know! THX!

Posted

Draw the points in a different order.

 

Specifically, you might want to look at the last value passed....the texture V (as in, swap it).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

...Simpler?  Simpler than swapping two variables?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

ok fair enough, but first of all.. texture V ?? there are things like setRenderBounds, setOverrideBlockTexture, setNormal, renderBottomFace, draw, startDrawingQuads, etc... so .. here, ill post the code

package mods.UpwardsHopper;

import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.BlockHopper;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class RenderUpwardsHopper 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)
{
	if(block instanceof BlockUpwardsHopper) { return renderBlockHopper(Block.hopperBlock, x, y, z, world, renderer); }
	return false;
}

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

@Override
public int getRenderId()
{
	return UpwardsHopper.instance.hopperRenderID;
}

public boolean renderBlockHopper(BlockHopper par1BlockHopper, int par2, int par3, int par4, IBlockAccess blockAccess, RenderBlocks renderer)
{
	Tessellator tessellator = Tessellator.instance;
	tessellator.setBrightness(par1BlockHopper.getMixedBrightnessForBlock(blockAccess, par2, par3, par4));
	float f = 1.0F;
	int l = par1BlockHopper.colorMultiplier(blockAccess, par2, par3, par4);
	float f1 = (float) (l >> 16 & 255) / 255.0F;
	float f2 = (float) (l >> 8 & 255) / 255.0F;
	float f3 = (float) (l & 255) / 255.0F;

	if(EntityRenderer.anaglyphEnable)
	{
		float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
		float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
		float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
		f1 = f4;
		f2 = f5;
		f3 = f6;
	}

	tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
	return renderBlockHopperMetadata(par1BlockHopper, par2, par3, par4, blockAccess.getBlockMetadata(par2, par3, par4), false, renderer);
}

public boolean renderBlockHopperMetadata(BlockHopper par1BlockHopper, int par2, int par3, int par4, int par5, boolean par6, RenderBlocks renderer)
{
	Tessellator tessellator = Tessellator.instance;
	int i1 = BlockHopper.func_94451_c(par5);
	double d0 = 0.625D;
	renderer.setRenderBounds(0.0D, d0, 0.0D, 1.0D, 1.0D, 1.0D);

	if(par6)
	{
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, -1.0F, 0.0F);
		renderer.renderBottomFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 0, par5));
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderTopFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 1, par5));
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, -1.0F);
		renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 2, par5));
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, 1.0F);
		renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 3, par5));
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(-1.0F, 0.0F, 0.0F);
		renderer.renderNorthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 4, par5));
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(1.0F, 0.0F, 0.0F);
		renderer.renderSouthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(par1BlockHopper, 5, par5));
		tessellator.draw();
	}
	else
	{
		renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
	}

	float f;

	if(!par6)
	{
		tessellator.setBrightness(par1BlockHopper.getMixedBrightnessForBlock(renderer.blockAccess, par2, par3, par4));
		float f1 = 1.0F;
		int j1 = par1BlockHopper.colorMultiplier(renderer.blockAccess, par2, par3, par4);
		f = (float) (j1 >> 16 & 255) / 255.0F;
		float f2 = (float) (j1 >> 8 & 255) / 255.0F;
		float f3 = (float) (j1 & 255) / 255.0F;

		if(EntityRenderer.anaglyphEnable)
		{
			float f4 = (f * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
			float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
			float f6 = (f * 30.0F + f3 * 70.0F) / 100.0F;
			f = f4;
			f2 = f5;
			f3 = f6;
		}

		tessellator.setColorOpaque_F(f1 * f, f1 * f2, f1 * f3);
	}

	Icon icon = BlockHopper.func_94453_b("hopper");
	Icon icon1 = BlockHopper.func_94453_b("hopper_inside");
	f = 0.125F;

	if(par6)
	{
		tessellator.startDrawingQuads();
		tessellator.setNormal(1.0F, 0.0F, 0.0F);
		renderer.renderSouthFace(par1BlockHopper, (double) (-1.0F + f), 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(-1.0F, 0.0F, 0.0F);
		renderer.renderNorthFace(par1BlockHopper, (double) (1.0F - f), 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, 1.0F);
		renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, (double) (-1.0F + f), icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, -1.0F);
		renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, (double) (1.0F - f), icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderTopFace(par1BlockHopper, 0.0D, -1.0D + d0, 0.0D, icon1);
		tessellator.draw();
	}
	else
	{
		renderer.renderSouthFace(par1BlockHopper, (double) ((float) par2 - 1.0F + f), (double) par3, (double) par4, icon);
		renderer.renderNorthFace(par1BlockHopper, (double) ((float) par2 + 1.0F - f), (double) par3, (double) par4, icon);
		renderer.renderWestFace(par1BlockHopper, (double) par2, (double) par3, (double) ((float) par4 - 1.0F + f), icon);
		renderer.renderEastFace(par1BlockHopper, (double) par2, (double) par3, (double) ((float) par4 + 1.0F - f), icon);
		renderer.renderTopFace(par1BlockHopper, (double) par2, (double) ((float) par3 - 1.0F) + d0, (double) par4, icon1);
	}

	renderer.setOverrideBlockTexture(icon);
	double d1 = 0.25D;
	double d2 = 0.25D;
	renderer.setRenderBounds(d1, d2, d1, 1.0D - d1, d0 - 0.002D, 1.0D - d1);

	if(par6)
	{
		tessellator.startDrawingQuads();
		tessellator.setNormal(1.0F, 0.0F, 0.0F);
		renderer.renderSouthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(-1.0F, 0.0F, 0.0F);
		renderer.renderNorthFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, 1.0F);
		renderer.renderWestFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 0.0F, -1.0F);
		renderer.renderEastFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, 1.0F, 0.0F);
		renderer.renderTopFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
		tessellator.startDrawingQuads();
		tessellator.setNormal(0.0F, -1.0F, 0.0F);
		renderer.renderBottomFace(par1BlockHopper, 0.0D, 0.0D, 0.0D, icon);
		tessellator.draw();
	}
	else
	{
		renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
	}

	if(!par6)
	{
		double d3 = 0.375D;
		double d4 = 0.25D;
		renderer.setOverrideBlockTexture(icon);

		if(i1 == 0)
		{
			renderer.setRenderBounds(d3, 0.0D, d3, 1.0D - d3, 0.25D, 1.0D - d3);
			renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
		}

		if(i1 == 2)
		{
			renderer.setRenderBounds(d3, d2, 0.0D, 1.0D - d3, d2 + d4, d1);
			renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
		}

		if(i1 == 3)
		{
			renderer.setRenderBounds(d3, d2, 1.0D - d1, 1.0D - d3, d2 + d4, 1.0D);
			renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
		}

		if(i1 == 4)
		{
			renderer.setRenderBounds(0.0D, d2, d3, d1, d2 + d4, 1.0D - d3);
			renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
		}

		if(i1 == 5)
		{
			renderer.setRenderBounds(1.0D - d1, d2, d3, 1.0D, d2 + d4, 1.0D - d3);
			renderer.renderStandardBlock(par1BlockHopper, par2, par3, par4);
		}
	}

	renderer.clearOverrideBlockTexture();
	return true;
}
}

I suppose its not a big deal if its stolen.. probably not an original idea anyway.. meh.

Posted

Ah, I see, you're using the built in render[direction]Face fucntions.

 

Yeah.  You're going to need to duplicate those and change them.

 

You're looking for this:

 

tessellator.addVertexWithUV(var28, var34, var36, var20, var24);

 

Note five variables are passed.  They are, in order: X, Y, Z, U, V.

 

XYZ should be fairly obvious.  It's the coordinate in space the vertex is located at.  Typically they vary from block.posX to block.posX+1 (same for Y and Z, modified by bounds).  U and V relate to the texture.  U is a horizontal (x axis) position on the texture, V is the vertical (y axis) position.

 

You need to duplicate the renderFace functions for the sides you want flipped, then swap the variables passed to the V parameter with each other (eg. if the four verts use var23 and var24 you'd change them to be the other).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

hmm.. all it did was make the inside of the hopper look like pink wool..... uhm... i did something wrong?!?! xD

edit: renderer.renderStandardBlock is being called...

Posted

hmm.. all it did was make the inside of the hopper look like pink wool..... uhm... i did something wrong?!?! xD

edit: renderer.renderStandardBlock is being called...

 

You might want to build the renderer yourself, rather than relying on the prebuilt functions.  It's not that difficult, really.  At least, for cubes.

 

I'll dig up some code I have for a custom renderer I have when I get home.  It is basically what you need, just you have to swap some variables around.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Ah, I see, you're trying to do something more complicated than I expected.

 

I thought you were trying to get a TEXTURE upside down.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

... uh... well... so... can u help still?

 

Not really no. :\

I've barely touched rendering.  I've made a cube. :V

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

×
×
  • Create New...

Important Information

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