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

Ok, I'm current branching from my last problem with my entity not spawning, I've got it to work. :)

 

The only problem now, is that it doesn't render. Here's my code:

 

Entity

package realmoffera.entity;

import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class EntityCoinsRF extends Entity {
public int value = 10;

public EntityCoinsRF(World world) {
	super(world);
	this.yOffset = 0.0F;
	this.setSize(0.5F, 0.5F);
}

public EntityCoinsRF(World world, int value, double x, double y, double z) {
	this(world);
	this.value = value;
	setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0);
}

@Override
protected void entityInit() {
	System.out.println("Initializing coins at X: " + posX + "|Y: " + posY + "|Z: " + posZ);
}

@Override
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
	return false;
}

@Override
public void onUpdate() {
	System.out.println("Updating at X: " + posX + "|Y: " + posY + "|Z: " + posZ);
	super.onUpdate();
}

@Override
public void onCollideWithPlayer(EntityPlayer player) {
	System.out.println("Colliding with player!");
	super.onCollideWithPlayer(player);
	NBTTagCompound nbt = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
	nbt.setInteger("Coins", nbt.getInteger("Coins") + value);
	setDead();
}

@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
	value = nbt.getInteger("Value");
}

@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
	nbt.setInteger("Value", value);
}

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

@Override
protected boolean canTriggerWalking() {
	return false;
}

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

@Override
public boolean handleWaterMovement() {
	return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}

@Override
@SideOnly(Side.CLIENT)
public void performHurtAnimation() {
}

@Override
protected void dealFireDamage(int par1) {
}
}

 

Render

package realmoffera.client.render;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import realmoffera.UtilRF;
import realmoffera.client.model.ModelCoinsRF;
import realmoffera.entity.EntityCoinsRF;

public class RenderCoinsRF extends Render {
public static final ResourceLocation COPPER = UtilRF.newResource("textures/entity/coins/copper.png"), SILVER = UtilRF.newResource("textures/entity/coins/silver.png"), GOLD = UtilRF.newResource("textures/entity/coins/gold.png"), PLATINUM = UtilRF.newResource("textures/entity/coins/platinum.png");
public static final ModelCoinsRF model = new ModelCoinsRF();

@Override
public void doRender(Entity entity, double d, double d1, double d2, float d3, float d4) {
	System.err.println("IM RENDERING!");
	EntityCoinsRF coins = (EntityCoinsRF) entity;
	this.bindTexture(getEntityTexture(coins));
	model.render(coins, (float) d4, (float) d1, (float) d2, (float) d3, (float) d4, 1);
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	EntityCoinsRF coins = (EntityCoinsRF) entity;
	return coins.value >= 100000 ? PLATINUM : (coins.value >= 10000 ? GOLD : (coins.value >= 1000 ? SILVER : COPPER));
}
}

 

Model

package realmoffera.client.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import realmoffera.entity.EntityCoinsRF;

public class ModelCoinsRF extends ModelBase {
ModelRenderer coin1;
ModelRenderer coin2;
ModelRenderer coin3;
ModelRenderer coin4;

public ModelCoinsRF() {
	textureWidth = 32;
	textureHeight = 32;
	coin1 = new ModelRenderer(this, 0, 0);
	coin1.addBox(0F, 0F, 0F, 4, 1, 4);
	coin1.setRotationPoint(-2F, 23F, -2F);
	coin1.setTextureSize(32, 32);
	coin1.mirror = true;
	setRotation(coin1, 0F, 0F, 0F);
	coin2 = new ModelRenderer(this, 0, 0);
	coin2.addBox(0F, 0F, 2F, 4, 1, 4);
	coin2.setRotationPoint(-1F, 23F, 7F);
	coin2.setTextureSize(32, 32);
	coin2.mirror = true;
	setRotation(coin2, 0.1858931F, 2.918521F, 0.0371786F);
	coin3 = new ModelRenderer(this, 0, 0);
	coin3.addBox(0F, 0F, 0F, 4, 1, 4);
	coin3.setRotationPoint(-2F, 23F, -5F);
	coin3.setTextureSize(32, 32);
	coin3.mirror = true;
	setRotation(coin3, 0.0371786F, -0.6878043F, -0.3346075F);
	coin4 = new ModelRenderer(this, 0, 0);
	coin4.addBox(0F, 0F, 0F, 4, 1, 4);
	coin4.setRotationPoint(4.2F, 23F, 1.4F);
	coin4.setTextureSize(32, 32);
	coin4.mirror = true;
	setRotation(coin4, 0F, -2.9557F, -0.2974289F);
}

public void render(EntityCoinsRF coins, float f, float f1, float f2, float f3, float f4, float f5) {
	super.render(coins, f, f1, f2, f3, f4, f5);
	setRotationAngles(f, f1, f2, f3, f4, f5, coins);
	coin1.render(f5);
	if(coins.value < 100) {
		if(coins.value >= 25) {
			coin2.render(f5);
		}
		if(coins.value >= 50) {
			coin3.render(f5);
		}
		if(coins.value >= 75) {
			coin4.render(5);
		}
	} else if(coins.value < 1000) {
		if(coins.value >= 250) {
			coin2.render(f5);
		}
		if(coins.value >= 500) {
			coin3.render(f5);
		}
		if(coins.value >= 750) {
			coin4.render(5);
		}
	} else if(coins.value < 10000) {
		if(coins.value >= 2500) {
			coin2.render(f5);
		}
		if(coins.value >= 5000) {
			coin3.render(f5);
		}
		if(coins.value >= 7500) {
			coin4.render(5);
		}
	} else if(coins.value < 100000) {
		if(coins.value >= 25000) {
			coin2.render(f5);
		}
		if(coins.value >= 50000) {
			coin3.render(f5);
		}
		if(coins.value >= 75000) {
			coin4.render(5);
		}
	}
}

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
	this.render((EntityCoinsRF) entity, f, f1, f2, f3, f4, f5);
}

private void setRotation(ModelRenderer model, float x, float y, float z) {
	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) {
	super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
}
}

 

Render Registering

package realmoffera.helper;

import realmoffera.UtilRF;
import realmoffera.client.render.RenderBatRF;
import realmoffera.client.render.RenderBipedRF;
import realmoffera.client.render.RenderCoinsRF;
import realmoffera.client.render.RenderMummyRF;
import realmoffera.entity.EntityCaveBatRF;
import realmoffera.entity.EntityCoinsRF;
import realmoffera.entity.EntityGoblinArcherRF;
import realmoffera.entity.EntityGoblinScoutRF;
import realmoffera.entity.EntityGoblinWarriorRF;
import realmoffera.entity.EntityMummyRF;
import realmoffera.entity.EntityPaladinRF;
import cpw.mods.fml.client.registry.RenderingRegistry;

public class RenderHelperRF {
public static void init() {
	RenderingRegistry.registerEntityRenderingHandler(EntityMummyRF.class, new RenderMummyRF(UtilRF.newResource("textures/entity/mummy.png")));
	RenderingRegistry.registerEntityRenderingHandler(EntityGoblinScoutRF.class, new RenderBipedRF(UtilRF.newResource("textures/entity/goblin.png")));
	RenderingRegistry.registerEntityRenderingHandler(EntityCaveBatRF.class, new RenderBatRF(UtilRF.newResource("textures/entity/caveBat.png")));
	RenderingRegistry.registerEntityRenderingHandler(EntityPaladinRF.class, new RenderBipedRF(UtilRF.newResource("textures/entity/paladin.png"), 1, 1.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityGoblinWarriorRF.class, new RenderBipedRF(UtilRF.newResource("textures/entity/goblin.png")));
	RenderingRegistry.registerEntityRenderingHandler(EntityGoblinArcherRF.class, new RenderBipedRF(UtilRF.newResource("textures/entity/goblin.png")));
	RenderingRegistry.registerEntityRenderingHandler(EntityCoinsRF.class, new RenderCoinsRF());
}
}

 

All of my other entities are spawning and rendering properly, and all the prints in the entity code is being called when they're supposed to.

 

I have a print in my render method to see if it's rendering. It's never called.

Kain

  • Author

I've done some more experimenting, and it seems that my entity class isn't taking any renders? I tried registering the entity with RenderXPOrb and many others, but nothing pops up as an error.

Kain

  • Author

Again, more experimentation. By extending EntityMob, it works. But I don't want it to extend EntityMob just because it's not rendering. Is there something that EntityMob or EntityLiving(Base) does that edits the rendering of entities? Even though it says it's rendering, I added a print to see where it was actually rendering.

 

IM RENDERING THE MODEL AT X: 0.7624547|Y: -1.62|Z: -0.47452742

 

I don't think that's right.

 

Entity Code:

package realmoffera.entity;

import net.minecraft.block.material.Material;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class EntityCoinsRF extends EntityMob {
public int value = 10;

public EntityCoinsRF(World world) {
	super(world);
	this.preventEntitySpawning = true;
	this.yOffset = 0.0F;
	this.setSize(0.5F, 0.5F);
}

public EntityCoinsRF(World world, int value, double x, double y, double z) {
	super(world);
	this.yOffset = 0.0F;
	this.setSize(0.5F, 0.5F);
	this.preventEntitySpawning = false;
	this.value = value;
	setLocationAndAngles(x, y, z, MathHelper.wrapAngleTo180_float(world.rand.nextFloat() * 360.0F), 0);
}

@Override
protected void entityInit() {
	super.entityInit();
	System.out.println("Initializing coins at X: " + posX + "|Y: " + posY + "|Z: " + posZ);
}

@Override
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) {
	return false;
}

@Override
public void onUpdate() {
	super.onUpdate();
	System.out.println("Updating at X: " + posX + "|Y: " + posY + "|Z: " + posZ);
}

public boolean canBeCollidedWith() {
	return true;
}

@Override
public void onCollideWithPlayer(EntityPlayer player) {
	System.out.println("Colliding with player!");
	super.onCollideWithPlayer(player);
	NBTTagCompound nbt = player.getEntityData().getCompoundTag(EntityPlayer.PERSISTED_NBT_TAG);
	nbt.setInteger("Coins", nbt.getInteger("Coins") + value);
	setDead();
}

@Override
public void readEntityFromNBT(NBTTagCompound nbt) {
	value = nbt.getInteger("Value");
}

@Override
public void writeEntityToNBT(NBTTagCompound nbt) {
	nbt.setInteger("Value", value);
}

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

@Override
protected boolean canTriggerWalking() {
	return false;
}

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

@Override
public boolean handleWaterMovement() {
	return this.worldObj.handleMaterialAcceleration(this.boundingBox, Material.water, this);
}

@Override
@SideOnly(Side.CLIENT)
public void performHurtAnimation() {
}

@Override
protected void dealFireDamage(int par1) {
}

@SideOnly(Side.CLIENT)
public float getShadowSize() {
	return 0.0F;
}
}

 

Model Code:

package realmoffera.client.model;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import realmoffera.entity.EntityCoinsRF;

public class ModelCoinsRF extends ModelBase {
ModelRenderer coin1;
ModelRenderer coin2;
ModelRenderer coin3;
ModelRenderer coin4;

public ModelCoinsRF() {
	super();
	textureWidth = 32;
	textureHeight = 32;
	coin1 = new ModelRenderer(this, 0, 0);
	coin1.addBox(0F, 0F, 0F, 4, 1, 4);
	coin1.setRotationPoint(-2F, 23F, -2F);
	coin1.setTextureSize(32, 32);
	coin1.mirror = true;
	setRotation(coin1, 0F, 0F, 0F);
	coin2 = new ModelRenderer(this, 0, 0);
	coin2.addBox(0F, 0F, 2F, 4, 1, 4);
	coin2.setRotationPoint(-1F, 23F, 7F);
	coin2.setTextureSize(32, 32);
	coin2.mirror = true;
	setRotation(coin2, 0.1858931F, 2.918521F, 0.0371786F);
	coin3 = new ModelRenderer(this, 0, 0);
	coin3.addBox(0F, 0F, 0F, 4, 1, 4);
	coin3.setRotationPoint(-2F, 23F, -5F);
	coin3.setTextureSize(32, 32);
	coin3.mirror = true;
	setRotation(coin3, 0.0371786F, -0.6878043F, -0.3346075F);
	coin4 = new ModelRenderer(this, 0, 0);
	coin4.addBox(0F, 0F, 0F, 4, 1, 4);
	coin4.setRotationPoint(4.2F, 23F, 1.4F);
	coin4.setTextureSize(32, 32);
	coin4.mirror = true;
	setRotation(coin4, 0F, -2.9557F, -0.2974289F);
}

@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
	System.err.println("IM RENDERING THE MODEL AT X: " + f + "|Y: " + f1 + "|Z: " + f2);
	EntityCoinsRF coins = (EntityCoinsRF) entity;
	super.render(coins, f, f1, f2, f3, f4, f5);
	setRotationAngles(f, f1, f2, f3, f4, f5, coins);
	coin1.render(f5);
	if(coins.value < 100) {
		if(coins.value >= 25) {
			coin2.render(f5);
		}
		if(coins.value >= 50) {
			coin3.render(f5);
		}
		if(coins.value >= 75) {
			coin4.render(5);
		}
	} else if(coins.value < 1000) {
		if(coins.value >= 250) {
			coin2.render(f5);
		}
		if(coins.value >= 500) {
			coin3.render(f5);
		}
		if(coins.value >= 750) {
			coin4.render(5);
		}
	} else if(coins.value < 10000) {
		if(coins.value >= 2500) {
			coin2.render(f5);
		}
		if(coins.value >= 5000) {
			coin3.render(f5);
		}
		if(coins.value >= 7500) {
			coin4.render(5);
		}
	} else if(coins.value < 100000) {
		if(coins.value >= 25000) {
			coin2.render(f5);
		}
		if(coins.value >= 50000) {
			coin3.render(f5);
		}
		if(coins.value >= 75000) {
			coin4.render(5);
		}
	}
}

private void setRotation(ModelRenderer model, float x, float y, float z) {
	model.rotateAngleX = x;
	model.rotateAngleY = y;
	model.rotateAngleZ = z;
}
}

 

Render Code:

package realmoffera.client.render;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import realmoffera.UtilRF;
import realmoffera.client.model.ModelCoinsRF;
import realmoffera.entity.EntityCoinsRF;

public class RenderCoinsRF extends Render {
public static final ResourceLocation COPPER = UtilRF.newResource("textures/entity/coins/copper.png"), SILVER = UtilRF.newResource("textures/entity/coins/silver.png"), GOLD = UtilRF.newResource("textures/entity/coins/gold.png"), PLATINUM = UtilRF.newResource("textures/entity/coins/platinum.png");
public static final ModelCoinsRF model = new ModelCoinsRF();

public RenderCoinsRF() {
	super();
}

@Override
public void doRender(Entity entity, double d, double d1, double d2, float d3, float d4) {
	System.err.println("IM RENDERING!");
	EntityCoinsRF coins = (EntityCoinsRF) entity;
	this.bindTexture(getEntityTexture(coins));
	model.render(coins, (float) d4, (float) d1, (float) d2, (float) d3, (float) d4, 1);
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	EntityCoinsRF coins = (EntityCoinsRF) entity;
	return coins.value >= 100000 ? PLATINUM : (coins.value >= 10000 ? GOLD : (coins.value >= 1000 ? SILVER : COPPER));
}
}

Kain

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...

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.