Jump to content

[1.8] Having some more modeling issues -.-


NovaViper

Recommended Posts

I can't do the arrays since I'm extending to RenderLiving, it won't allow me to add more. Also, my entites have different textures for each subtype

Again: learn Java - your problem is no longer with Minecraft, it is with your own lack of knowledge.

 

You can do whatever you want in your own constructor so long as you have everything there that the super constructor needs. You can't pass extra arguments to the super constructor, but you can have as many as you want in your own. Basic Java (sorry if it seems like I'm harping on you, but it really is very basic and you owe it to yourself to learn it).

Link to comment
Share on other sites

  • Replies 78
  • Created
  • Last Reply

Top Posters In This Topic

No, like, I literally can't change the constructor, it won't allow me to

 

	public RenderZertumModel(RenderManager render, ModelBase base, float par1) {

	super(render, base, par1);
	this.addLayer(new LayersZertum(this));
}

 

It says "Implicit super constructor RenderLiving() is undefined. Must explicitly invoke another constructor"

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

There is something wrong in your code, then, that you didn't show, because I can call super on RenderLiving's constructor just fine while adding any parameters I want to my own constructor:

public class RenderGenericLiving extends RenderLiving {
public RenderGenericLiving(RenderManager renderManager, ModelBase model, float shadowSize, float scale, String texturePath) {
	super(renderManager, model, shadowSize);
	// other stuff
}
}

No errors there. I bet you left in an empty constructor, e.g. public RenderZertumModel() { super(); }.

 

This just reinforces my point even more...

Link to comment
Share on other sites

I did the first thing you had

 

	public RenderZertumModel(RenderManager renderManager, ModelBase... model, float shadowSize) {
	super(renderManager, model, shadowSize);
	// other stuff
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

I know, thats what I've been saying. I was trying to ask hoe am I suppose to do it if it expects only one model?

Put the main model as a separate argument, then something that's not a ModelBase next, and then the array of alternate models, or just pass the first element of the array to the super method.

 

If you don't understand what I'm saying, Google / Java tutorials are your friend.

Link to comment
Share on other sites

I've been looking around the internet but I haven't seen anyone actually have two different models being rendered.

You're not being very clear about what you want: do you want to render a different model based on the entity's state, or render TWO models at the same time for the same entity?

 

In any case, you still need to create or provide all the models you want when instantiating your render class, then choose amongst them when rendering. As I've both explained and demonstrated.

 

On a side note, all that time you've spent looking at other people's code hoping to find what you're looking for would have been better spent learning the fundamentals of Java - then you could write your own code.

Link to comment
Share on other sites

I want to render a different model based on the entity's state I don't know how do to do it in the render class, but in the ModelBase class I know how. I tried something like this

 

Render Class

package common.zeroquest.client.render;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.lwjgl.opengl.GL11;

import common.zeroquest.client.model.ModelZertum;
import common.zeroquest.client.render.layers.LayersZertum;
import common.zeroquest.client.render.layers.LayersZertumModel;
import common.zeroquest.entity.zertum.EntityDarkZertum;
import common.zeroquest.entity.zertum.EntityDestroZertum;
import common.zeroquest.entity.zertum.EntityForisZertum;
import common.zeroquest.entity.zertum.EntityIceZertum;
import common.zeroquest.entity.zertum.EntityMetalZertum;
import common.zeroquest.entity.zertum.EntityRedZertum;
import common.zeroquest.entity.zertum.EntityZertum;
import common.zeroquest.entity.zertum.EntityZertumEntity;
import common.zeroquest.lib.Constants;
import common.zeroquest.util.ResourceReference;

@SideOnly(Side.CLIENT)
public class RenderZertumModel extends RenderLiving {

private static ModelZertum zertum;
public static EntityZertumEntity entity;

public RenderZertumModel(RenderManager render, EntityZertumEntity entity, float par1) {

	super(render, zertum, par1);
	this.entity = entity;
	this.addLayer(new LayersZertumModel(this, entity));
}

public void func_177135_a(EntityZertumEntity entity, double par1, double par2, double par3, float par4, float par5) {
	if (entity.isWolfWet()) {
		float f2 = entity.getBrightness(par5) * entity.getShadingWhileWet(par5);
		GlStateManager.color(f2, f2, f2);
	}

	super.doRender(entity, par1, par2, par3, par4, par5);
}

protected ResourceLocation getEntityTexture(EntityZertumEntity entity) {
	if (!entity.hasEvolved()) {
		if (entity.isTamed()) {
			return ResourceReference.getZTameSkins(getZertumType());
		}
		else if (entity.isAngry()) {
			return ResourceReference.getZAngrySkins(getZertumType());
		}
		else if (!entity.isTamed() && !entity.isAngry()) {
			return ResourceReference.getZWildSkins(getZertumType());
		}
	}
	else if (entity.hasEvolved()) {
		if (entity.isTamed()) {
			return ResourceReference.getZEvoTamekins(getZertumType());
		}
		else if (!entity.isTamed() && !entity.isAngry()) {
			return ResourceReference.getZEvoWildSkins(getZertumType());
		}
	}
	return null;
}

private String getZertumType() {
	if (entity instanceof EntityZertum) {
		return "";
	}
	else if (entity instanceof EntityRedZertum) {
		return "r";
	}
	else if (entity instanceof EntityMetalZertum) {
		return "m";
	}
	else if (entity instanceof EntityIceZertum) {
		return "i";
	}
	else if (entity instanceof EntityForisZertum) {
		return "f";
	}
	else if (entity instanceof EntityDestroZertum) {
		return "des";
	}
	else if (entity instanceof EntityDarkZertum) {
		return "d";
	}
	return "";
}

@Override
public void doRender(EntityLiving entity, double par1, double par2, double par3, float par4, float par5) {
	this.func_177135_a((EntityZertumEntity) entity, par1, par2, par3, par4, par5);
}

@Override
public void doRender(EntityLivingBase entity, double par1, double par2, double par3, float par4, float par5) {
	this.func_177135_a((EntityZertumEntity) entity, par1, par2, par3, par4, par5);
}

@Override
protected ResourceLocation getEntityTexture(Entity p_110775_1_) {
	return this.getEntityTexture((EntityZertumEntity) p_110775_1_);
}

@Override
public void passSpecialRender(EntityLivingBase entityLivingBase, double par1, double par2, double par3) {
	EntityZertumEntity dog = (EntityZertumEntity) entityLivingBase;

	if (!dog.getPetName().isEmpty()) {
		super.passSpecialRender(entityLivingBase, par1, par2, par3);
	}
}

@Override
protected void renderOffsetLivingLabel(Entity entity, double x, double y, double z, String displayName, float scale, double distanceFromPlayer) {
	super.renderOffsetLivingLabel(entity, x, y, z, displayName, scale, distanceFromPlayer);

	EntityZertumEntity dog = (EntityZertumEntity) entity;

	if (distanceFromPlayer < 100.0D) {

		y += this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.016666668F * 0.7F;

		String tip = dog.mode.getMode().getTip();

		String label = String.format("%s[%d]", tip, dog.getZertumHunger());

		if (dog.isPlayerSleeping()) {
			this.renderLivingLabel(dog, label, x, y - 0.5D, z, 64, 0.7F);
		}
		else {
			this.renderLivingLabel(dog, label, x, y, z, 64, 0.7F);
		}
	}

	if (distanceFromPlayer < 100.0D) {
		y += this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.016666668F * 0.5F;

		if (this.renderManager.livingPlayer.isSneaking()) {
			EntityLivingBase owner = dog.getOwnerEntity();
			if (owner != null) {
				this.renderLivingLabel(dog, owner.getDisplayName().getUnformattedText(), x, y, z, 5, 0.5F);
			}
			else {
				this.renderLivingLabel(dog, dog.getOwnerName(), x, y, z, 5, 0.5F);
			}
		}
	}
}

protected void renderLivingLabel(Entity p_147906_1_, String p_147906_2_, double p_147906_3_, double p_147906_5_, double p_147906_7_, int p_147906_9_, float scale) {
	double d3 = p_147906_1_.getDistanceSqToEntity(this.renderManager.livingPlayer);

	if (d3 <= p_147906_9_ * p_147906_9_) {
		FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
		float f1 = 0.016666668F * scale;
		GlStateManager.pushMatrix();
		GlStateManager.translate((float) p_147906_3_ + 0.0F, (float) p_147906_5_ + p_147906_1_.height + 0.5F, (float) p_147906_7_);
		GL11.glNormal3f(0.0F, 1.0F, 0.0F);
		GlStateManager.rotate(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
		GlStateManager.rotate(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
		GlStateManager.scale(-f1, -f1, f1);
		GlStateManager.disableLighting();
		GlStateManager.depthMask(false);
		GlStateManager.disableDepth();
		GlStateManager.enableBlend();
		GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
		Tessellator tessellator = Tessellator.getInstance();
		WorldRenderer worldrenderer = tessellator.getWorldRenderer();
		byte b0 = 0;

		if (p_147906_2_.equals("deadmau5")) {
			b0 = -10;
		}

		GlStateManager.disableTexture2D();
		worldrenderer.startDrawingQuads();
		int j = fontrenderer.getStringWidth(p_147906_2_) / 2;
		worldrenderer.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
		worldrenderer.addVertex(-j - 1, -1 + b0, 0.0D);
		worldrenderer.addVertex(-j - 1, 8 + b0, 0.0D);
		worldrenderer.addVertex(j + 1, 8 + b0, 0.0D);
		worldrenderer.addVertex(j + 1, -1 + b0, 0.0D);
		tessellator.draw();
		GlStateManager.enableTexture2D();
		fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, 553648127);
		GlStateManager.enableDepth();
		GlStateManager.depthMask(true);
		fontrenderer.drawString(p_147906_2_, -fontrenderer.getStringWidth(p_147906_2_) / 2, b0, -1);
		GlStateManager.enableLighting();
		GlStateManager.disableBlend();
		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
		GlStateManager.popMatrix();
	}
}

}

 

Layers class

package common.zeroquest.client.render.layers;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.EnumDyeColor;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import common.zeroquest.client.render.RenderZertumModel;
import common.zeroquest.entity.zertum.EntityDarkZertum;
import common.zeroquest.entity.zertum.EntityDestroZertum;
import common.zeroquest.entity.zertum.EntityForisZertum;
import common.zeroquest.entity.zertum.EntityIceZertum;
import common.zeroquest.entity.zertum.EntityMetalZertum;
import common.zeroquest.entity.zertum.EntityRedZertum;
import common.zeroquest.entity.zertum.EntityZertum;
import common.zeroquest.entity.zertum.EntityZertumEntity;
import common.zeroquest.lib.Constants;
import common.zeroquest.util.ResourceReference;

@SideOnly(Side.CLIENT)
public class LayersZertumModel implements LayerRenderer {

private final RenderZertumModel renderer;
public static EntityZertumEntity entity;

public LayersZertumModel(RenderZertumModel renderer, EntityZertumEntity entity) {
	this.renderer = renderer;
	this.entity = entity;

}

public void func_177145_a(EntityZertumEntity entity, float par1, float par2, float par3, float par4, float par5, float par6, float par7) {
	if (!entity.isInvisible()) {
		if (!entity.hasEvolved()) {
			if (entity.isTamed()) {
				this.renderer.bindTexture(ResourceReference.getZLayers("collar"));
				EnumDyeColor enumdyecolor = EnumDyeColor.byMetadata(entity.getCollarColor().getMetadata());
				float[] afloat = EntitySheep.func_175513_a(enumdyecolor);
				GlStateManager.color(afloat[0], afloat[1], afloat[2]);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}
			if (entity.isTamed() && entity.getHealth() <= Constants.lowHP) {
				this.renderer.bindTexture(ResourceReference.getZLayers("dying"));
				GlStateManager.color(1f, 1f, 1f);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}
			if (entity.isTamed() && entity.isSaddled()) {
				this.renderer.bindTexture(ResourceReference.getZLayers("saddle"));
				GlStateManager.color(1f, 1f, 1f);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}
			if (entity.getGender() == true) {
				if (entity.isTamed()) {
					this.renderer.bindTexture(ResourceReference.getZMaleTameLayers(getZertumType()));
					GlStateManager.color(1f, 1f, 1f);
					this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
				}
				else {
					this.renderer.bindTexture(ResourceReference.getZMaleLayers(getZertumType()));
					GlStateManager.color(1f, 1f, 1f);
					this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
				}
			}
		}
		else if (entity.hasEvolved()) {
			if (entity.isTamed()) {
				this.renderer.bindTexture(ResourceReference.getZELayers("collar"));
				EnumDyeColor enumdyecolor = EnumDyeColor.byMetadata(entity.getCollarColor().getMetadata());
				float[] afloat = EntitySheep.func_175513_a(enumdyecolor);
				GlStateManager.color(afloat[0], afloat[1], afloat[2]);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}

			if (entity.isTamed() && entity.getHealth() <= Constants.lowHP) {
				this.renderer.bindTexture(ResourceReference.getZELayers("dying"));
				GlStateManager.color(1f, 1f, 1f);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}

			if (entity.isTamed() && entity.isSaddled()) {
				this.renderer.bindTexture(ResourceReference.getZELayers("saddle"));
				GlStateManager.color(1f, 1f, 1f);
				this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
			}
			if (entity.getGender() == true) {
				if (entity.isTamed()) {
					this.renderer.bindTexture(ResourceReference.getZEMaleLayers(getZertumType()));
					GlStateManager.color(1f, 1f, 1f);
					this.renderer.getMainModel().render(entity, par1, par2, par4, par5, par6, par7);
				}
			}
		}
	}
}

private String getZertumType() {
	if (entity instanceof EntityZertum) {
		return "";
	}
	else if (entity instanceof EntityRedZertum) {
		return "r";
	}
	else if (entity instanceof EntityMetalZertum) {
		return "m";
	}
	else if (entity instanceof EntityIceZertum) {
		return "i";
	}
	else if (entity instanceof EntityForisZertum) {
		return "f";
	}
	else if (entity instanceof EntityDestroZertum) {
		return "des";
	}
	else if (entity instanceof EntityDarkZertum) {
		return "d";
	}
	return "";
}

@Override
public boolean shouldCombineTextures() {
	return true;
}

@Override
public void doRenderLayer(EntityLivingBase entity, float par1, float par2, float par3, float par4, float par5, float par6, float par7) {
	this.func_177145_a((EntityZertumEntity) entity, par1, par2, par3, par4, par5, par6, par7);
}

}

 

But I can't add the different entity types because I need an entity to get the instance

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

What do you think the 'Entity' parameter is for? There is an entity parameter in nearly every single Render class method.

 

I'd really like to help you further, but nothing I say is going to teach you Java, and that's what you need. Just look at your code:

private String getZertumType() {
if (entity instanceof EntityZertum) {
	return "";
}
else if (entity instanceof EntityRedZertum) {
	return "r";
}
else if (entity instanceof EntityMetalZertum) {
	return "m";
}
else if (entity instanceof EntityIceZertum) {
	return "i";
}
else if (entity instanceof EntityForisZertum) {
	return "f";
}
else if (entity instanceof EntityDestroZertum) {
	return "des";
}
else if (entity instanceof EntityDarkZertum) {
	return "d";
}
return "";
}

For one, that will never work, because all subclasses are also instances of the parent class, so only your first condition is ever evaluated.

Next, I assume this is the method in which you 'need an entity' - so send it one as a parameter!

Finally, why have a method like this at all, when you can simply add it to your EntityZertum class and have each subclass override it to return the appropriate value? Much better encapsulation and extendability.

 

Best of luck to you.

Link to comment
Share on other sites

I did, but on my Client Proxy, it says it has to be a varable, so i changed all the parameters as a class extending to EntityZertumEntity, which caused an error for the subclass check saying it has to be a entity, not a class. And the different subtypes all have different textures and have completely different abilities from the others.

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

Wait.. I just got an idea, is it possible to set a entity's type as an enum? The idea is to just scratch out all of the Zertum types I have and just have one class where all of the zertum types are using. And the types can be changed by certain conditions, like say, the type of biome it is in. And these types are enums.

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

I started on it but I eventually cut it out because I wasn't really sure if using enums wouldn't allow me to switch between certain things like the health and damage of the entity

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Link to comment
Share on other sites

I would change the blockState, and than call the following to change the model:

	YourTileEntityRenderer renderer = new YourTileEntityRenderer();
	TileEntityRendererDispatcher.instance.mapSpecialRenderers.put(YourTileEntity.class, renderer);
	renderer.func_147497_a(TileEntityRendererDispatcher.instance);

 

This is what I use to change a model ingame. (I actualy linked it to a command for ingame editing models)

I hope this helps you a bit in the right direction.

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

It's not for a tile entity, its for a living one

Then just select appropriate model on the renderer...

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

But it says TileEntity.. my entity isn't a TileEntity

What I'm saying is for Entity. You should have a renderer for the entity, select appropriate model there!

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

And I'm trying to accomplish using multiple models for multiple entities

What? Dont you have your own renderer for the entities? That cant be..

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.