Jump to content

[Solved] Entity not rendering properly. Help???


Recommended Posts

Posted

So I recently added an entity to my mod. It is supposed to render a standard biped, but instead it renders like this:cBGvT9M

Here is the code:

The entity's class:

public class GreyMan
			extends EntityMob{

public GreyMan(World par1World) {
	super(par1World);
        this.isImmuneToFire = true;
        this.experienceValue = 10;
        
        this.getNavigator().setBreakDoors(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
        this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
        this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
        this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
        this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
        this.tasks.addTask(8, new EntityAILookIdle(this));
        this.tasks.addTask(9, new EntityAIOpenDoor(this, true));
        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
        this.setSize(0.6F, 1.8F);
}

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.23000000417232513D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D);
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.blaze.breathe";
    }
    
    /**
    * Returns the sound this mob makes when it is hurt.
    */
   protected String getHurtSound()
   {
       return "mob.blaze.hit";
   }

   /**
    * Returns the sound this mob makes on death.
    */
   protected String getDeathSound()
   {
       return "mob.blaze.death";
   }
   
   protected void func_145780_a(int p_145780_1_, int p_145780_2_, int p_145780_3_, Block p_145780_4_)
   {
       this.playSound("mob.skeleton.step", 0.15F, 1.0F);
   }
   
   /**
    * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
    * use this to react to sunlight and start to burn.
    */
   public void onLivingUpdate()
   {
   if (this.isWet())
	   this.teleportRandomly();
   }
   
   /**
    * Teleport the grey man to a random nearby position
    */
   protected boolean teleportRandomly()
   {
       double d0 = this.posX + (this.rand.nextDouble() - 0.5D) * 64.0D;
       double d1 = this.posY + (double)(this.rand.nextInt(64) - 32);
       double d2 = this.posZ + (this.rand.nextDouble() - 0.5D) * 64.0D;
       return this.teleportTo(d0, d1, d2);
   }
   
   /**
    * Teleport the grey man
    */
   protected boolean teleportTo(double par1, double par3, double par5)
   {
       EnderTeleportEvent event = new EnderTeleportEvent(this, par1, par3, par5, 0);
       if (MinecraftForge.EVENT_BUS.post(event)){
           return false;
       }
       double d3 = this.posX;
       double d4 = this.posY;
       double d5 = this.posZ;
       this.posX = event.targetX;
       this.posY = event.targetY;
       this.posZ = event.targetZ;
       boolean flag = false;
       int i = MathHelper.floor_double(this.posX);
       int j = MathHelper.floor_double(this.posY);
       int k = MathHelper.floor_double(this.posZ);

       if (this.worldObj.blockExists(i, j, k))
       {
           boolean flag1 = false;

           while (!flag1 && j > 0)
           {
               Block block = this.worldObj.getBlock(i, j - 1, k);

               if (block.getMaterial().blocksMovement())
               {
                   flag1 = true;
               }
               else
               {
                   --this.posY;
                   --j;
               }
           }

           if (flag1)
           {
               this.setPosition(this.posX, this.posY, this.posZ);

               if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox))
               {
                   flag = true;
               }
           }
       }

       if (!flag)
       {
           this.setPosition(d3, d4, d5);
           return false;
       }
       else
       {
           short short1 = 128;

           for (int l = 0; l < short1; ++l)
           {
               double d6 = (double)l / ((double)short1 - 1.0D);
               float f = (this.rand.nextFloat() - 0.5F) * 0.2F;
               float f1 = (this.rand.nextFloat() - 0.5F) * 0.2F;
               float f2 = (this.rand.nextFloat() - 0.5F) * 0.2F;
               double d7 = d3 + (this.posX - d3) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D;
               double d8 = d4 + (this.posY - d4) * d6 + this.rand.nextDouble() * (double)this.height;
               double d9 = d5 + (this.posZ - d5) * d6 + (this.rand.nextDouble() - 0.5D) * (double)this.width * 2.0D;
               this.worldObj.spawnParticle("portal", d7, d8, d9, (double)f, (double)f1, (double)f2);
           }

           this.worldObj.playSoundEffect(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
           this.playSound("mob.endermen.portal", 1.0F, 1.0F);
           return true;
       }
   }
}

 

The model's code:

// Date: 9/7/2014 6:33:49 AM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX

package com.awsp8.wizardry.entity.model;

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

public class ModelGreyMan extends ModelBase{
  //fields
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;
  
  public ModelGreyMan()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      head = new ModelRenderer(this, 0, 0);
      head.addBox(-4F, -8F, -4F, 8, 8, ;
      head.setRotationPoint(0F, 0F, 0F);
      head.setTextureSize(64, 32);
      head.mirror = true;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 16, 16);
      body.addBox(-4F, 0F, -2F, 8, 12, 4);
      body.setRotationPoint(0F, 0F, 0F);
      body.setTextureSize(64, 32);
      body.mirror = true;
      setRotation(body, 0F, 0F, 0F);
      rightarm = new ModelRenderer(this, 40, 16);
      rightarm.addBox(-3F, -2F, -2F, 4, 12, 4);
      rightarm.setRotationPoint(-5F, 2F, 0F);
      rightarm.setTextureSize(64, 32);
      rightarm.mirror = true;
      setRotation(rightarm, 0F, 0F, 0F);
      leftarm = new ModelRenderer(this, 40, 16);
      leftarm.addBox(-1F, -2F, -2F, 4, 12, 4);
      leftarm.setRotationPoint(5F, 2F, 0F);
      leftarm.setTextureSize(64, 32);
      leftarm.mirror = true;
      setRotation(leftarm, 0F, 0F, 0F);
      rightleg = new ModelRenderer(this, 0, 16);
      rightleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      rightleg.setRotationPoint(-2F, 12F, 0F);
      rightleg.setTextureSize(64, 32);
      rightleg.mirror = true;
      setRotation(rightleg, 0F, 0F, 0F);
      leftleg = new ModelRenderer(this, 0, 16);
      leftleg.addBox(-2F, 0F, -2F, 4, 12, 4);
      leftleg.setRotationPoint(2F, 12F, 0F);
      leftleg.setTextureSize(64, 32);
      leftleg.mirror = true;
      setRotation(leftleg, 0F, 0F, 0F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    head.render(f5);
    body.render(f5);
    rightarm.render(f5);
    leftarm.render(f5);
    rightleg.render(f5);
    leftleg.render(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);
  }

}

 

The rendering class:

package com.awsp8.wizardry.entity.render;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation;

import com.awsp8.wizardry.Entities.GreyMan;
import com.awsp8.wizardry.entity.model.ModelGreyMan;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

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

public RenderGreyMan(ModelBase modelBase, float par2) {
	super(modelBase, par2);
}

@Override
protected ResourceLocation getEntityTexture(Entity var1) {
	return new ResourceLocation("wizardry", "/textures/entities/greyMan.png");
}
}

 

The proxy class:

package com.awsp8.wizardry;

import net.minecraft.client.model.ModelBiped;

import com.awsp8.wizardry.Entities.GreyMan;
import com.awsp8.wizardry.entity.model.ModelGreyMan;
import com.awsp8.wizardry.entity.render.RenderGreyMan;

import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy
			extends CommonProxy {

@Override
    public void registerRenderers() {
        RenderingRegistry.registerEntityRenderingHandler(GreyMan.class, new RenderGreyMan(new ModelGreyMan(), 0.5F)); 
    }
}

 

In the main class the proxy is registered like this:

    @SidedProxy(clientSide = Info.clientSide, serverSide = Info.serverSide)
    public static CommonProxy proxy;

 

My mod's init method in the main class:

    	registerEntity(GreyMan.class, "greyMan", 660000, 050505);
        addSpawn(GreyMan.class, 25, 2, 6, new BiomeGenBase[] {});

Later in the main class:


    public void registerEntity(Class<? extends Entity> entityClass, String entityName, int bkEggColor, int fgEggColor) {
    	int id = EntityRegistry.findGlobalUniqueEntityId();
    	EntityRegistry.registerGlobalEntityID(entityClass, entityName, id);
    	EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, bkEggColor, fgEggColor));
    }


public void addSpawn(Class<? extends EntityLiving> entityClass, int spawnProb, int min, int max, BiomeGenBase[] biomes) {
	if (spawnProb > 0) {
			EntityRegistry.addSpawn(entityClass, spawnProb, min, max, EnumCreatureType.creature, biomes);
	}
}

 

I have been troubleshooting this code for a week now, any help is appreciated. :)

Posted

Where do you call "registerRenderers"?

Where do you register your entity to the EntityRegistry?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 9/8/2014 at 7:19 AM, SanAndreasP said:

Where do you call "registerRenderers"?

Where do you register your entity to the EntityRegistry?

 

Oh right... That would be in the main class of my mod. It's up there now. Sorry about the lack in code guys, I think that's all my entity's code. :)

Posted

I don't see where you call registerRenderers, or the SidedProxy annotation. By the way, there is a version of registerGlobalEntityId that accepts color parameters.

Check out my mod, Realms of Chaos, here.

 

If I helped you, be sure to press the "Thank You" button!

Posted
  On 9/8/2014 at 2:43 PM, Eternaldoom said:

I don't see where you call registerRenderers, or the SidedProxy annotation. By the way, there is a version of registerGlobalEntityId that accepts color parameters.

 

It's there now. Any other info you need?

 

Oh and btw I know there is a version of registerGlobalEntityId that take colors, it just wasn't working for me. :)

 

Edit: Wait a second... did you say I have to call registerRenderers? I think I just created it is all. I will try that :)

Posted
  On 9/8/2014 at 4:17 PM, diesieben07 said:

Yet another case of "wait, this method is not just called by magic?"... Yay.

Lol yep, works fine now. :) thx everyone!

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

    • Looking for a fantastic way to save big on your next Temu order? The acr639380 Temu coupon code is exactly what you need! Whether you're shopping from the USA, Canada, or Europe, this code offers unbeatable savings — up to $100 off your next purchase. If you’ve been eyeing something on Temu, now’s the perfect time to grab it with this exclusive offer!  What Is the Coupon Code for Temu $100 Off? Both new and existing customers can benefit from this incredible deal when shopping on the Temu app or website. Just use code acr639380 at checkout to unlock your $100 discount. Here’s what it offers: acr639380: Flat $100 off your next purchase.   acr639380: Receive a $100 coupon pack for multiple uses.   acr639380: New customers get an exclusive $100 off their first purchase.   acr639380: Existing customers can claim an extra $100 off future purchases.   acr639380: Valid in the USA, Canada, and across Europe.    Temu $100 Off Coupon for New Users in 2025 If you're new to Temu, this coupon code is perfect for you. It’s your chance to enjoy huge savings right from your very first order. Here’s what new customers get with acr639380: Flat $100 discount on your first order.   Access to a $100 coupon bundle for multiple purchases.   Stack up to $100 in discounts across various orders.   Free shipping to 68 countries, including the USA, Canada, and UK.   An additional 30% off any item on your first purchase.    How to Redeem the Temu $100 Off Coupon (For New Users) It’s simple! Follow these quick steps: Visit the Temu website or download the Temu app.   Create a new account.   Add your favorite products to your cart.   At checkout, enter the Temu $100 off coupon code: acr639380.   Apply the code, enjoy the savings, and complete your purchase!    Temu Coupon $100 Off for Existing Customers Good news — existing customers aren’t left out! Temu rewards loyal shoppers too. Perks for returning users with acr639380: Get an extra $100 off your next order.   A $100 coupon bundle for multiple future purchases.   Free gifts with express shipping (USA & Canada).   An additional 30% off on any purchase.   Free shipping to 68 countries globally.    How to Use Temu $100 Off Coupon (For Existing Customers) To redeem: Log into your Temu account.   Add your items to the cart.   At checkout, enter acr639380.   Apply the code and enjoy your savings!    Temu $100 Off Coupon for First Orders Your first Temu order just got better with acr639380: $100 off your initial purchase.   Access to exclusive first-time user discounts.   Up to $100 in savings on multiple items.   Free shipping to 68 countries.   Extra 30% off your first order.    Where to Find the Latest Temu $100 Off Coupon Looking for the newest and verified Temu coupon codes? Here’s where you can find them: Temu’s newsletter: Subscribe for email-exclusive deals.   Official Temu social media pages.   Trusted coupon websites.   Community threads like Temu coupon $100 off Reddit where users share legit codes.    Is the Temu $100 Off Coupon Legit? Absolutely — the acr639380 coupon is verified, tested, and 100% legit. It works for both new and existing customers worldwide, with no expiration date. Use it with confidence!  How Does the Temu $100 Off Coupon Work? Simple — enter acr639380 at checkout, and the discount is applied automatically. Whether it’s your first order or a repeat purchase, you’ll enjoy direct savings.  How to Earn Temu $100 Coupons as a New Customer New customers can score extra Temu savings by: Signing up for a new Temu account.   Making your first purchase using acr639380.   Watching for special promotions and email deals.   Checking Temu’s homepage for limited-time coupon bundles.    Advantages of Using the Temu $100 Off Coupon Here’s what makes this coupon so appealing: Flat $100 discount on first-time and future orders.   $100 coupon bundle for multiple uses.   Up to 90% off popular products.   Extra 30% off for existing customers.   Free gifts for new users.   Free shipping to 68 countries, including the USA, UK, and Canada.    Temu $100 Discount Code + Free Gift for Everyone Both new and existing customers get added perks: $100 off your first order.   An extra 30% off any product.   Free gifts on first purchases.   Up to 90% off select deals on the Temu app.   Free shipping to 68 countries.    Pros and Cons of Using the Temu Coupon Code $100 Off in 2025 Pros: Massive $100 discount.   Up to 90% off on select items.   Free global shipping to 68 countries.   30% off bonus for existing users.   Verified, legit, and no expiration date.   Cons: Free shipping limited to select countries.   Some exclusions may apply to already discounted items.    Terms and Conditions (2025) No expiration date.   Valid in 68 countries.   No minimum spend required.   Applicable for multiple purchases.   Some product exclusions may apply.    Final Note: Don’t Miss Out on the $100 Temu Coupon If you’re shopping on Temu, don’t leave money on the table. Use coupon code acr639380 to unlock $100 off, free shipping, extra discounts, and exclusive perks. It’s one of the easiest ways to make your shopping spree even more rewarding.  FAQs: Temu $100 Off Coupon Q: Is the $100 off coupon available for both new and existing customers? A: Yes! Both can use acr639380 for amazing discounts. Q: How do I redeem the Temu $100 coupon? A: Enter acr639380 at checkout to instantly save $100. Q: Does the Temu coupon expire? A: No — this coupon currently has no expiration date. Q: Can the coupon be used for multiple purchases? A: Yes, the $100 off coupon and bundle can apply to multiple orders. Q: Does it work for international users? A: Absolutely! It’s valid in 68 countries, including the USA, Canada, and Europe.
    • Add the full crash-report or latest.log (logs-folder) with sites like https://mclo.gs/ and paste the link to it here
    • Hey everyone! We're working on a new Fabric mod called RodinCraft, it uses our in-house AI to generate Minecraft structures from simple text prompts or images. For example, you can type something like "floating castle" or upload a picture of a house, and the mod will build a Minecraft version of it in-game. It’s powered by our own 3D AI system, Rodin Gen-1.5. Video demo: Watch it on Twitter (https://x.com/DeemosTech/status/1917660914503016839) We’re still in early development, so we’d love your feedback: 1. Would you use something like this? 2. What features would make it better or more useful? 3. Any thoughts or concerns?   Thanks! — RodinCraft Team
    • Um i was installing minecraft and it said i needed neoforge 21.1.186 but i don't know how to install it.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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