Jump to content

[1.8] Entity renders two times?


DaryBob

Recommended Posts

Hi guy's, today I made a mob. If I spawn him, he has like two textures, very weird. I also wanted him to wear an armor and an item. I thought about it, and removed the armor code. But he still was there two times.. Could you please take a look into ma' code?

Thanks, Dary

 

EntityCreator.java

package netcrafter.mods.aoto.util;

import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.projectile.EntityEgg;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.registry.EntityRegistry;
import netcrafter.mods.aoto.Main;

public class EntityCreator {

public static final void createEntity(Class entityClass, Render renderer, String name, EnumCreatureType type, boolean doesSpawn, int probability, int minSpawn, int maxSpawn, BiomeGenBase[] biomes, int solidColor, int spotColor, boolean hasSpawnEgg) {
	int id = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, name, id);
	EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true);
	RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer);

	if(doesSpawn) { EntityRegistry.addSpawn(name, probability, minSpawn, maxSpawn, type, biomes); }		
	if(hasSpawnEgg) { EntityList.entityEggs.put(Integer.valueOf(id), new EntityList.EntityEggInfo(id, solidColor, spotColor)); }
}

public static final void createEntityItem(Class entityClass, Render renderer, String name) {
	int id = EntityRegistry.findGlobalUniqueEntityId();

	EntityRegistry.registerGlobalEntityID(entityClass, name, id);
	EntityRegistry.registerModEntity(entityClass, name, id, Main.instance, 64, 1, true);
	RenderingRegistry.registerEntityRenderingHandler(entityClass, renderer);

}


}

 

CommonProxy.java

package netcrafter.mods.aoto.proxy;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import netcrafter.mods.aoto.Main;
import netcrafter.mods.aoto.crafting.AOTOCrafting;
import netcrafter.mods.aoto.entity.boss.EntityForestGuardian;
import netcrafter.mods.aoto.entity.boss.EntityKingSteve;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot;
import netcrafter.mods.aoto.init.AOTOBlocks;
import netcrafter.mods.aoto.init.AOTOItems;
import netcrafter.mods.aoto.render.entity.RenderForestGuardian;
import netcrafter.mods.aoto.render.entity.RenderKingSteve;
import netcrafter.mods.aoto.render.entity.RenderTreeMinion;
import netcrafter.mods.aoto.util.EntityCreator;
import netcrafter.mods.aoto.util.WorldGenRegister;
import netcrafter.mods.aoto.world.gen.feature.ForestGen;

public class CommonProxy {

    public void preInit(FMLPreInitializationEvent e) {
    	//Creating and registering items and blocks
	AOTOItems.createItems();
	AOTOBlocks.createBlocks();
    }

    public void init(FMLInitializationEvent e) {
    	//Register crafting recipes
        AOTOCrafting.initCrafting();
        
        //Create and register entities
        EntityCreator.createEntityItem(EntityTreeRoot.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), AOTOItems.tree_root, Minecraft.getMinecraft().getRenderItem()), "TreeRoot");
        EntityCreator.createEntity(EntityKingSteve.class, new RenderKingSteve(), "KingSteve", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xF2FF00, 0x020B12, true);
        EntityCreator.createEntity(EntityForestGuardian.class, new RenderForestGuardian(), "ForestGuardian", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xC219A3, 0x19C238, true);
        EntityCreator.createEntity(EntityTreeMinion.class, new RenderTreeMinion(), "TreeMinion", EnumCreatureType.MONSTER, false, 0, 0, 0, null, 0xA85236, 0x6E260E, true);
        
        //Register world generators
        WorldGenRegister.registerGenerators();
    }

    public void postInit(FMLPostInitializationEvent e) {

    }

public void registerRenders() {

}

}

 

EntityKingSteve.java

package netcrafter.mods.aoto.entity.boss;

import java.util.Random;

import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMoveTowardsTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.monster.EntityGuardian;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MathHelper;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;
import netcrafter.mods.aoto.Reference;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.entity.projectile.EntityTreeRoot;
import netcrafter.mods.aoto.init.AOTOItems;

public class EntityKingSteve extends EntityMob implements IBossDisplayData {

private int attackCounter = 0;
    private int deathTicks = 0;
    private int regenTime = 0;

public EntityKingSteve(World worldIn) {
	super(worldIn);
	this.setSize(1.5F, 7.0F);
	this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 2.0D, true));
	this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 1.0D, (float) 2.0D));
    this.tasks.addTask(3, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(5, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
    
    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(360.0F);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(35.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.26D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(15.0D);
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(2.0D);
    }
    
    protected void func_180481_a(DifficultyInstance p_180481_1_) {
        super.func_180481_a(p_180481_1_);
        this.setCurrentItemOrArmor(0, new ItemStack(AOTOItems.long_diamond_sword));
        this.setCurrentItemOrArmor(1, new ItemStack(AOTOItems.beard));
    }

@Override
    protected String getLivingSound() {
        return Reference.MOD_ID + ":mob.forestguardian.living";
    }

    @Override
    protected String getHurtSound() {
        return Reference.MOD_ID + ":mob.forestguardian.hurt";
    }

    @Override
    protected String getDeathSound() {
        return Reference.MOD_ID + ":mob.forestguardian.death";
    }
    
    /** Calls this method if the mob is dead */
    @SuppressWarnings("unchecked")
    @Override
    protected void onDeathUpdate() {
    	//Increments deathTicks every tick
    	++this.deathTicks;

    	//Creates a huge explosion if the value of deathTicks is between 180 and 200
        if (this.deathTicks >= 180 && this.deathTicks <= 200) {
            final float f = (this.rand.nextFloat() - 0.5F) * 1.5F;
            final float f1 = (this.rand.nextFloat() - 0.5F) * 2.0F;
            final float f2 = (this.rand.nextFloat() - 0.5F) * 1.5F;
            //Spawns the explosion into the world
            this.worldObj.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, this.posX + f, this.posY + 2.0D + f1, this.posZ + f2, 0.0D, 0.0D, 0.0D);
        }

        int i;
        int j;

        if (!this.worldObj.isRemote) {
        	
        	if (this.deathTicks > 150 && this.deathTicks % 5 == 0) {
                i = 30;

                while (i > 0) {
                    j = EntityXPOrb.getXPSplit(i);
                    i -= j;
                    //Spawns xp orbs while i is bigger than zero
                    this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
                }
            }

        }

        //Rotates the mob
        this.moveEntity(0.0D, 0.10000000149011612D, 0.0D);
        this.renderYawOffset = this.rotationYaw += 20.0F;

        //Checks if the death ticks reached 200
        if (this.deathTicks == 200 && !this.worldObj.isRemote) {
            i = 20;

            while (i > 0) {
                j = EntityXPOrb.getXPSplit(i);
                i -= j;
                //Spawns xp orbs while i is bigger than 0
                this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
            }

            //Drops an item
            this.entityDropItem(new ItemStack(AOTOItems.gem, 1, 1), 0.5F);
            
            //Spawns a lighting bolt into the world
            this.worldObj.addWeatherEffect(new EntityLightningBolt(worldObj, this.posX + 6, this.posY + 6, this.posZ));
            
            //Sets this mob dead
            super.setDead();
        }
    }

    @Override
    protected void dropFewItems(boolean par1, int par2) {
    	final ItemStack var2 = new ItemStack(AOTOItems.crown);
        EnchantmentHelper.addRandomEnchantment(this.rand, var2, 5);
        this.entityDropItem(var2, 0.0F);
    }
    
    @Override
    public EntityItem entityDropItem(ItemStack par1ItemStack, float par2) {
        final EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY + par2, this.posZ, par1ItemStack);
        entityitem.motionY = -2.0D;
        entityitem.setPickupDelay(60);
        if (this.captureDrops) {
            this.capturedDrops.add(entityitem);
        }else{
            this.worldObj.spawnEntityInWorld(entityitem);
        }
        return entityitem;
    }
    
    @Override
    public void onLivingUpdate() {
    	
    	if(regenTime++ > 10) {
    		regenTime = 0;
    		this.heal(4);
    	}   	
    	super.onLivingUpdate();
    }

}

 

RenderKingSteve.java

package netcrafter.mods.aoto.render.entity;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.boss.BossStatus;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.util.ResourceLocation;
import netcrafter.mods.aoto.Reference;
import netcrafter.mods.aoto.entity.boss.EntityKingSteve;
import netcrafter.mods.aoto.entity.mob.EntityTreeMinion;
import netcrafter.mods.aoto.model.ModelKingSteve;
import netcrafter.mods.aoto.model.ModelTreeMinion;

public class RenderKingSteve extends RenderBiped {

    public RenderKingSteve() {
    	
    	super(Minecraft.getMinecraft().getRenderManager(), new ModelKingSteve(), 0);
    	
	this.addLayer(new LayerHeldItem(this));
	LayerBipedArmor layerbipedarmor = new LayerBipedArmor(this) {
		protected void func_177177_a() {
			this.field_177186_d = new ModelBiped(1.0F);
			this.field_177189_c = new ModelBiped(0.5F);
		}
	};

        this.addLayer(layerbipedarmor);

    }

    @Override
    protected ResourceLocation getEntityTexture(Entity par1Entity) {
        return new ResourceLocation(Reference.MOD_ID, "textures/models/king_steve.png");
    }
    
private void renderEntity(EntityKingSteve entity, double x, double y, double z, float yaw, float partialTickTime) {
    super.doRender(entity, x, y, z, yaw, partialTickTime);
    }

    @Override
    public void doRender(EntityLiving par1EntityLiving, double par2, double par4, double par6, float par8, float par9) {
        BossStatus.setBossStatus((IBossDisplayData) par1EntityLiving, false);
        super.doRender(par1EntityLiving, par2, par4, par6, par8, par9);
    }
    
}

 

ModelKingSteve.java

package netcrafter.mods.aoto.model;

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

public class ModelKingSteve extends ModelBiped {

    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer rightleg;
    ModelRenderer leftleg;
  
  public ModelKingSteve() {
    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);
  }

}

 

Well now, that I pasted the model, maybe it renders it two times, because it is already a modelbiped?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Create didn't work but i did figure out the issue, it was everycompat, my assumption with my coding experience was that since it was index out of bounds there was a mod adding too many items that caused the items index to be out of bounds, now i have to knowledge of the backend of minecraft so it was just a assumption so i just tested removing different mods that added a lot of blocks and everycompat was the problem.
    • So I got into the client thanks to someone on the forge discord and got a server up and running, but now I'm trying to join the server but I keep getting this error when I try and join, and I cant figure it out. can anyone help me out? https://pastebin.com/9Kv7p1wn
    • Hello everyone , I am trying to develop an AI controlled player with the help of dl4j using reinforcement learning.   Unfortunatly when i try to add it to my gradle as shown in this link My Build won't work with this error: A problem occurred starting process 'command 'C:\Program Files\Java\jdk-17\bin\java.exe'' > Could not start 'C:\Program Files\Java\jdk-17\bin\java.exe' > Cannot run program "C:\Program Files\Java\jdk-17\bin\java.exe" (in directory "E:\minecraft_mod\build\reobfJar"): CreateProcess error=206,The filename or extension is too long > CreateProcess error=206, The filename or extension is too long I litteraly just spent 4 hours searching for solutions but none of them would work. The command size limitation made by windows is creating this error , there is a workaround in intelliJ , name "Shorten command lines" but it is only for application lauching. I found  this solution for gradle but it also doesn't work. Most of the solution that i found were used for spring application using gradle so i am afraid it need more configuration for forge or it just won't work.
    • Thank you! But, it still isnt working..   https://mclo.gs/ypYZRbM I have a new Log.  
    • Thanks! It solved my bugs, all the mods loaded.
  • 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.