Jump to content

Recommended Posts

Posted

my mob boss extends the renderbiped class.  everything works fine except it has an image INSIDE the model.  the image causes "z-fighting" and when the mob rotates, for example, you can see it inside my custom model ...it is the strangest effect .  . ..I have searched the web and have not found any reason for it ....

 

render class:

 

package com.glistre.glistremod.queen;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelSkeleton;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import com.glistre.glistremod.entities.guardian.TobieModelQueen;

@SideOnly(Side.CLIENT)
public class TobieQueenRender extends RenderBiped
{
    private static final ResourceLocation tobieQueenTextures = new ResourceLocation("glistremod:textures/entities/TobieQueenElizabeth.png");
//    private static final ResourceLocation witherSkeletonTextures = new ResourceLocation("glistremod:textures/entities/TobieQueenElizabeth.png");
//    private static final String __OBFID = "CL_00001023";

    public TobieQueenRender(TobieModelQueen tobieModelQueen, float f)
    {
        super(new TobieModelQueen(), 0.5F);
    }


/**
     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
     * entityLiving, partialTickTime
     */
   protected void preRenderCallback(EntityTobieQueen tobieQueen, float partTicks)
    {
   //skeleton type == 1 wither; 1.2F, 1.2F, 1.2F == normal size , increase size without remodeling in Techne to 8.0F, 8.0F, 8.0F
       if (tobieQueen.getSkeletonType() == 0)
       {
            GL11.glScalef(6.0F, 6.0F, 6.0F);
      }
    }

   protected void func_82422_c()
    {
        GL11.glTranslatef(0.09375F, 0.1875F, 0.0F);
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(EntityTobieQueen tobieQueen)
    {
        return tobieQueenTextures;

    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */


    /**
     * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
     * entityLiving, partialTickTime
     */
   protected void preRenderCallback(EntityLivingBase tobieQueen, float partTicks)
    {
        this.preRenderCallback((EntityTobieQueen)tobieQueen, partTicks);
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(Entity tobieQueen)
    {
        return this.getEntityTexture((EntityTobieQueen)tobieQueen);
    }
}

 

model

package com.glistre.glistremod.queen;

import java.util.Random;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;

@SideOnly(Side.CLIENT)
public class TobieModelQueen extends ModelBiped
{
    
    public static Random rand;
    
  //fields
    ModelRenderer head;
    ModelRenderer body;
    ModelRenderer rightarm;
    ModelRenderer leftarm;
    ModelRenderer body2;
    ModelRenderer visor;

  
  public TobieModelQueen()
  {
    textureWidth = 64;
    textureHeight = 49;
    
      float f6 = 2.0F;
      head = new ModelRenderer(this, 12, 0);
      head.addBox(-5F, -10F, -5F, 10, 10, 10);
      head.setRotationPoint(0F, -2F, 0F);
      head.setTextureSize(64, 49);
      head.mirror = false;
      setRotation(head, 0F, 0F, 0F);
      body = new ModelRenderer(this, 17, 21);
      body.addBox(-5F, 0F, -3F, 10, 8, 5);
      body.setRotationPoint(0F, -1F, 0F);
      body.setTextureSize(64, 49);
      body.mirror = false;
      setRotation(body, 0F, 0F, 0F);
      rightarm = new ModelRenderer(this, 48, 22);
      rightarm.addBox(-5F, -2F, -2F, 4, 12, 4);
      rightarm.setRotationPoint(-5F, 1F, 0F);
      rightarm.setTextureSize(64, 49);
      rightarm.mirror = false;
      setRotation(rightarm, 0F, 0F, 0F);
      leftarm = new ModelRenderer(this, 0, 22);
      leftarm.addBox(1F, -2F, -2F, 4, 12, 4);
      leftarm.setRotationPoint(5F, 1F, 0F);
      leftarm.setTextureSize(64, 49);
      leftarm.mirror = false;
      setRotation(leftarm, 0F, 0F, 0F);
      body2 = new ModelRenderer(this, 19, 35);
      body2.addBox(-4F, 4F, -2F, 8, 11, 3);
      body2.setRotationPoint(0F, -1F, 0F);
      body2.setTextureSize(64, 49);
      body2.mirror = false;
      setRotation(body2, 0F, 0F, 0F);
      visor = new ModelRenderer(this, 42, 6);
      visor.addBox(-5F, -8F, -6F, 10, 3, 1);
      visor.setRotationPoint(0F, -2F, 0F);
      visor.setTextureSize(64, 49);
      visor.mirror = false;
      setRotation(visor, 0F, 0F, 0F);

  }

  @Override 
  public void render(Entity entity, float limbSwing, float limbSwingAmount, float rotFloat, float rotYaw, float rotPitch, float partTicks)
  {
    super.render(entity, limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks);
    setRotationAngles(limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks, entity);
    head.render(partTicks);
    body.render(partTicks);   
    rightarm.render(partTicks); 
    leftarm.render(partTicks);
    body2.render(partTicks);
    visor.render(partTicks);
    

  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  /**
   * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
   * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
   * "far" arms and legs can swing at most.
   */
  public void setRotationAngles(float limbSwing, float limbSwingAmount, float rotFloat, float rotYaw, float rotPitch, float partTicks, Entity entity)
  {
      /**
       * Arm Oscillations
       */
      super.setRotationAngles(limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks, entity);
      float f6 = MathHelper.sin(this.onGround * (float)Math.PI);
      float f7 = MathHelper.sin((1.0F - (1.0F - this.onGround) * (1.0F - this.onGround)) * (float)Math.PI);
      this.rightarm.rotateAngleZ = 0.0F;
      this.leftarm.rotateAngleZ = 0.0F;
      this.rightarm.rotateAngleY = -(0.1F - f6 * 0.6F);
      this.leftarm.rotateAngleY = 0.1F - f6 * 0.6F;
      this.rightarm.rotateAngleX = 0.0F;
      this.leftarm.rotateAngleX = 0.0F;
      this.rightarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
      this.leftarm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
      this.rightarm.rotateAngleZ += MathHelper.cos(rotFloat * 0.09F) * 0.05F + 0.05F;
      this.leftarm.rotateAngleZ -= MathHelper.cos(rotFloat * 0.09F) * 0.05F + 0.05F;
      this.rightarm.rotateAngleX += MathHelper.sin(rotFloat * 0.067F) * 0.05F;
      this.leftarm.rotateAngleX -= MathHelper.sin(rotFloat * 0.067F) * 0.05F;

      /**
       * FullBody Floating
       */
      float oscillate = MathHelper.cos(rotFloat * 0.09F) * 0.005F;
      
      this.head.rotationPointY += oscillate;
      this.body.rotationPointY += oscillate;
      this.body2.rotationPointY += oscillate;
      this.rightarm.rotationPointY += oscillate;
      this.leftarm.rotationPointY += oscillate;
      this.visor.rotationPointY += oscillate;
      
  }
}


 

entity mob boss:

package com.glistre.glistremod.queen;

import java.util.Calendar;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.entities.GlistreEntityRegistry;
import com.glistre.glistremod.items.ItemRegistry;
import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;

import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFleeSun;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIRestrictSun;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityIronGolem;
//import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityWitch;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityLargeFireball;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.AchievementList;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;

public class EntityTobieQueen extends EntityMob implements IRangedAttackMob
{
    private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);
    private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityZombie.class, 1.2D, false);
//    private static final String __OBFID = "CL_00001697";

    public EntityTobieQueen(World p_i1741_1_)
    {
        super(p_i1741_1_);
        //add attack AI for TobieQueen to player next line
        this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1,  new EntityAIAttackOnCollide(this, EntityZombie.class, 1.0D, true));
        this.tasks.addTask(3, new EntityAIRestrictSun(this));
//        this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D));
        this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
        this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityZombie.class, 8.0F));

        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, 3, true));
        
        this.tasks.addTask(4, new EntityAILookIdle(this));
        this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityZombie.class, 2, true));
//        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, 2, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntitySpider.class, 3, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, 3, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityCaveSpider.class, 4, true));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityEnderman.class, 4, true));
      

        if (p_i1741_1_ != null && !p_i1741_1_.isRemote)
        {
            this.setCombatTask();
        }
    }
    

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
//       this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(150.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.34000000417232513D);
        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(12.0D);
//     raise health from 15.0D to 115.0D
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(115.0D);
        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(10.0D);
    }

    protected void entityInit()
    {
        super.entityInit();
        this.dataWatcher.addObject(13, new Byte((byte)0));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.skeleton.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.skeleton.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.skeleton.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);
    }

    public boolean attackEntityAsMob(Entity p_70652_1_)
    {
        if (super.attackEntityAsMob(p_70652_1_))
        {
            if (this.getSkeletonType() == 1 && p_70652_1_ instanceof EntityLivingBase)
            {
                ((EntityLivingBase)p_70652_1_).addPotionEffect(new PotionEffect(Potion.wither.id, 200));
            }

            return true;
        }
        else
        {
            return false;
        }
    }

    /**
     * Get this Entity's EnumCreatureAttribute
     */
    public EnumCreatureAttribute getCreatureAttribute()
    {
        return EnumCreatureAttribute.UNDEAD;
    }

    /**
     * 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.worldObj.isDaytime() && !this.worldObj.isRemote)
        {
            float f = this.getBrightness(1.0F);

            if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))
            {
                boolean flag = true;
                ItemStack itemstack = this.getEquipmentInSlot(4);

                if (itemstack != null)
                {
                    if (itemstack.isItemStackDamageable())
                    {
                        itemstack.setItemDamage(itemstack.getItemDamageForDisplay() + this.rand.nextInt(2));

                        if (itemstack.getItemDamageForDisplay() >= itemstack.getMaxDamage())
                        {
                            this.renderBrokenItemStack(itemstack);
                            this.setCurrentItemOrArmor(4, (ItemStack)null);
                        }
                    }

                    flag = false;
                }

                if (flag)
                {
                    this.setFire(;
                }
            }
        }

        if (this.worldObj.isRemote && this.getSkeletonType() == 1)
        {
            this.setSize(0.72F, 2.34F);
        }

        super.onLivingUpdate();
    }*/

    /**
     * Handles updating while being ridden by an entity
     */
    public void updateRidden()
    {
        super.updateRidden();

        if (this.ridingEntity instanceof EntityCreature)
        {
            EntityCreature entitycreature = (EntityCreature)this.ridingEntity;
            this.renderYawOffset = entitycreature.renderYawOffset;
        }
    }

    /**
     * Called when the mob's health reaches 0.
     */
    public void onDeath(DamageSource p_70645_1_)
    {
        super.onDeath(p_70645_1_);

        if (p_70645_1_.getSourceOfDamage() instanceof EntityBlasterBolt && p_70645_1_.getEntity() instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)p_70645_1_.getEntity();
            double d0 = entityplayer.posX - this.posX;
            double d1 = entityplayer.posZ - this.posZ;

            if (d0 * d0 + d1 * d1 >= 2500.0D)
            {
                entityplayer.triggerAchievement(AchievementList.snipeSkeleton);
            }
        }
    }

    protected Item getDropItem()
    {
        return ItemRegistry.enderGun;
    }

    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropFewItems(boolean p_70628_1_, int p_70628_2_)
    {
        int j;
        int k;

        if (this.getSkeletonType() == 1)
        {
            j = this.rand.nextInt(3 + p_70628_2_) - 1;

            for (k = 0; k < j; ++k)
            {
                this.dropItem(ItemRegistry.sceptre_1, 1);
            }
        }
        else
        {
        j = this.rand.nextInt(3 + p_70628_2_);

        for (k = 0; k < j; ++k)
        	{
            this.dropItem(GlistreMod.enderbolt_1, 1);
        	}
        }

        j = this.rand.nextInt(3 + p_70628_2_);

        for (k = 0; k < j; ++k)
        	{
            this.dropItem(ItemRegistry.Glistre_Dust, 1);
        	}
        
        j = this.rand.nextInt(3 + p_70628_2_);

        for (k = 0; k < j; ++k)
        	{
            this.dropItem(ItemRegistry.Glistre_Ingot, 1);
        	}    
    }


    protected void dropRareDrop(int p_70600_1_)
    { 
        if (this.getSkeletonType() == 1)
        	
        // what does float do here?       	       	
           {
        	this.entityDropItem(new ItemStack(ItemRegistry.blasterGun_1, 1, 1), 0.0F);
           }
        //make non-wither TobySkeleton guardian drop rare drop
        else 
        {
            this.entityDropItem(new ItemStack(GlistreEntityRegistry.TobieWorstProjectile_1, 1, 1), 0.0F);
        } 
    }

    
    /**
     * Makes entity wear random armor based on difficulty
     */
   protected void addRandomArmor()
    {
//       super.addRandomArmor();
       this.setCurrentItemOrArmor(0, new ItemStack(ItemRegistry.tobieGun_1));
        // sets the ability for the RayGun to drop which is different than enderGun don't want RayGun for player
        this.equipmentDropChances[0] = 0.0F;
    }

    public IEntityLivingData onSpawnWithEgg(IEntityLivingData p_110161_1_)
    {
        p_110161_1_ = super.onSpawnWithEgg(p_110161_1_);

        if (this.worldObj.provider instanceof WorldProviderHell && this.getRNG().nextInt(5) > 0)
        {
            this.tasks.addTask(2, this.aiAttackOnCollide);
            this.setSkeletonType(1);
            this.setCurrentItemOrArmor(0, new ItemStack(ItemRegistry.sceptre_1));
            this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
// sets the ability for the RayGun to drop which is different than blaster dont want RayGun for player
            this.equipmentDropChances[0] = 0.0F;
        }
        else
        {
            this.tasks.addTask(0, this.aiArrowAttack);
            this.addRandomArmor();
            this.setCurrentItemOrArmor(0, new ItemStack(ItemRegistry.tobieGun_1));
            this.enchantEquipment();
        }

        this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * this.worldObj.func_147462_b(this.posX, this.posY, this.posZ));

        if (this.getEquipmentInSlot(4) == null)
        {
            Calendar calendar = this.worldObj.getCurrentDate();

            if (calendar.get(2) + 1 == 10 && calendar.get(5) == 31 && this.rand.nextFloat() < 0.25F)
            {
                this.setCurrentItemOrArmor(4, new ItemStack(this.rand.nextFloat() < 0.1F ? Blocks.lit_pumpkin : Blocks.pumpkin));
                this.equipmentDropChances[4] = 0.0F;
            }
        }

        return p_110161_1_;
    }

    /**
     * sets this entity's combat AI.
     */
    public void setCombatTask()
    {
        this.tasks.removeTask(this.aiAttackOnCollide);
        this.tasks.removeTask(this.aiArrowAttack);
        ItemStack itemstack = this.getHeldItem();

        if (itemstack != null && itemstack.getItem() == ItemRegistry.tobieGun_1)
        {
            this.tasks.addTask(0, this.aiArrowAttack);
        }
        else
        {
            this.tasks.addTask(1, this.aiAttackOnCollide);
        }
    }

    /**
     * Attack the specified entity using a ranged attack.
     */
    public void attackEntityWithRangedAttack(EntityLivingBase entity, float distance)
    {
        EntityBlasterBolt entityblasterbolt = new EntityBlasterBolt(this.worldObj, this, entity, 1.6F, (float)(14 - this.worldObj.difficultySetting.getDifficultyId() * 4));
        int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
        int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
        entityblasterbolt.setDamage((double)(distance * 2.0F) + this.rand.nextGaussian() * 0.25D + (double)((float)this.worldObj.difficultySetting.getDifficultyId() * 0.11F));

        if (i > 0)
        {
            entityblasterbolt.setDamage(entityblasterbolt.getDamage() + (double)i * 0.5D + 0.5D);
        }

        if (j > 0)
        {
            entityblasterbolt.setKnockbackStrength(j);
        }

        if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, this.getHeldItem()) > 0 || this.getSkeletonType() == 1)
        {
            entityblasterbolt.setFire(100);
        }

        this.playSound("glistremod:laserblaster", 1.2F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
        this.worldObj.spawnEntityInWorld(entityblasterbolt);
        
        //next part shoots fireballs from Tobie Queen
        //calculates the x,y,z DISTANCE between the projectile and the target. getLook() only gives the DIRECTION.

            double d0 = entity.posX - this.posX;
            double d1 = entity.boundingBox.minY + (double)(entity.height / 2.0F) - (this.posY + (double)(this.height / 2.0F));
            double d2 = entity.posZ - this.posZ;
            //calculating the accuracy (randomness) of the projectile. (The square root of the total distance divided by half. So, larger distances are more accurately fired.)

            float f1 = MathHelper.sqrt_float(distance) * 0.5F;
            this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, (int)this.posX, (int)this.posY, (int)this.posZ, 0);

            for (int k = 0; k < 1; ++k)
            {
         //This sets the x,y,z vector of the projectile, it uses the distance numbers calculated above, times a random number. (Because the Blaze fires randomly), 
         //you can take out "this.rand.nextGaussian() * (double)f1" and the projectile will always hit you dead on.    

                EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d0 + this.rand.nextGaussian() * (double)f1, d1, d2 + this.rand.nextGaussian() * (double)f1);
        //This is where the projectile starts, the 0.5F is added to half the height to place it near normanl size mobs mouth area , but for Queen should be 8.0 chest area, 8.9 mouth.            
   //mob.ghast.fireball
                entitylargefireball.posY = this.posY + (double)(this.height / 2.0F) + 8.0D;
                this.playSound("mob.blaze.hit", 1.2F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

                this.worldObj.spawnEntityInWorld(entitylargefireball);
            }
        }
            
            
    

    /**
     * Return this skeleton's type.
     */
    public int getSkeletonType()
    {
        return this.dataWatcher.getWatchableObjectByte(13);
    }

    /**
     * Set this skeleton's type.
     */
    public void setSkeletonType(int p_82201_1_)
    {
        this.dataWatcher.updateObject(13, Byte.valueOf((byte)p_82201_1_));
        this.isImmuneToFire = p_82201_1_ == 1;

        if (p_82201_1_ == 1)
        {
            this.setSize(0.72F, 2.34F);
        }
        else
        {
            this.setSize(0.6F, 1.8F);
        }
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound p_70037_1_)
    {
        super.readEntityFromNBT(p_70037_1_);

        if (p_70037_1_.hasKey("SkeletonType", 99))
        {
            byte b0 = p_70037_1_.getByte("SkeletonType");
            this.setSkeletonType(b0);
        }

        this.setCombatTask();
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound p_70014_1_)
    {
        super.writeEntityToNBT(p_70014_1_);
        p_70014_1_.setByte("SkeletonType", (byte)this.getSkeletonType());
    }

    /**
     * Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
     */
    public void setCurrentItemOrArmor(int slot, ItemStack itemstack)
    {
        super.setCurrentItemOrArmor(slot, itemstack);

        if (!this.worldObj.isRemote && slot == 0)
        {
            this.setCombatTask();
        }
    }

    /**
     * Returns the Y Offset of this entity.
     */
    public double getYOffset()
    {
        return super.getYOffset() - 0.5D;
    }
}

 

I registered the mob in client proxy which extends common proxy

 

Posted

the dupe image is actually inside the model I created and turns independently it's like a shadow effect and seems to be part of the skeleton animation somehow

 

I thought that was the answer but I cannot find anywhere unchecked for world.isRemote == false  ... where would I look? 

 

here is my spawning class  I have world.isRemote checked false in public Entity spawnEntity

 

package com.glistre.glistremod.queen;
import java.util.List;

import com.glistre.glistremod.GlistreMod;
import com.glistre.glistremod.reference.Reference;
import com.glistre.glistremod.tabs.TabRegistry;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockLiquid;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityLivingData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Facing;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeCache.Block;


public class QueenElizabethMonsterPlacer extends ItemMonsterPlacer
{
    @SideOnly(Side.CLIENT)
    private IIcon theIcon;
    protected int colorBase = 0xFF0000;
    protected int colorSpots = 0xFFFF5D;

   protected String entityToSpawnName = "Tobie Queen Elizabeth";
   protected String entityToSpawnNameFull = "Tobie Queen Elizabeth";
    protected EntityLiving entityToSpawn = null;

    
    public QueenElizabethMonsterPlacer(String parEntityToSpawnName, int parPrimaryColor, 
          int parSecondaryColor)
    {
        setHasSubtypes(false);
        maxStackSize = 64;
        this.setMaxDamage(800);
        setCreativeTab(TabRegistry.tabCustom);
        setEntityToSpawnName(parEntityToSpawnName);
        colorBase = parPrimaryColor;
        colorSpots = parSecondaryColor;
        // DEBUG
//       System.out.println("Spawn egg constructor for "+entityToSpawnName);
    }

    /**
     * Callback for item usage. If the item does something special on right clicking, 
     * he will have one of those. Return
     * True if something happen and false if it don't. This is for ITEMS, not BLOCKS
     */
    @Override
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, 
          World world, int par4, int par5, int par6, int par7, float par8, 
          float par9, float par10)
    {
    	
        if (world.isRemote)
        {
            return true;
        }
        else
        {
            net.minecraft.block.Block block = world.getBlock(par4, par5, par6);
            par4 += Facing.offsetsXForSide[par7];
            par5 += Facing.offsetsYForSide[par7];
            par6 += Facing.offsetsZForSide[par7];
            double d0 = 0.0D;

            if (par7 == 1 && block.getRenderType() == 11)
            {
                d0 = 0.5D;
            }

            Entity entity = spawnEntity(world, par4 + 0.5D, par5 + d0, par6 + 0.5D);

            if (entity != null)
            {
                if (entity instanceof EntityLivingBase && par1ItemStack.hasDisplayName())
                {
                    ((EntityLiving)entity).setCustomNameTag(par1ItemStack.getDisplayName());
                }

                if (!par2EntityPlayer.capabilities.isCreativeMode)
                {
                    --par1ItemStack.stackSize;
                }
            }
            //adds sound effect on spawning entity
            
            world.playSoundAtEntity(par2EntityPlayer, "glistremod:sceptre_1", 1.0F, 2.0F);
            
        	par2EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
        	par1ItemStack.damageItem(1, par2EntityPlayer);

            return true;
        }
    }

    /**
     * Called whenever this item is equipped and the right mouse button is pressed. 
     *Args: itemStack, world, entityPlayer
     */
    @Override
    public ItemStack onItemRightClick(ItemStack itemStack, World world, 
          EntityPlayer player)
    {

        if (world.isRemote)
        {

            return itemStack;
        }
        else
        {
            MovingObjectPosition movingobjectposition = 
                  getMovingObjectPositionFromPlayer(world, player, true);

            if (movingobjectposition == null)
            {
                return itemStack;
            }
            else
            {
                if (movingobjectposition.typeOfHit == MovingObjectPosition
                      .MovingObjectType.BLOCK)
                {
                    int i = movingobjectposition.blockX;
                    int j = movingobjectposition.blockY;
                    int k = movingobjectposition.blockZ;

                    if (!world.canMineBlock(player, i, j, k))
                    {
                        return itemStack;
                    }

                    if (!player.canPlayerEdit(i, j, k, movingobjectposition
                          .sideHit, itemStack))
                    {
                        return itemStack;
                    }

                    if (world.getBlock(i, j, k) instanceof BlockLiquid)
                    {
                        Entity entity = spawnEntity(world, i, j, k);

                        if (entity != null)
                        {
                            if (entity instanceof EntityLivingBase && itemStack
                                  .hasDisplayName())
                            {
                                ((EntityLiving)entity).setCustomNameTag(itemStack
                                      .getDisplayName());
                            }

                            if (!player.capabilities.isCreativeMode)
                            {
                                --itemStack.stackSize;
                            }
                        }
                    }
                    //adds sound effect if you hit entity
        	        
        	        world.playSoundAtEntity(player, "glistremod:sceptre_1", 1.0F, 2.0F);

                }
                return itemStack;
            }
        }
    }

    public Entity spawnEntity(World world, double posX, double posY, double posZ)
    {
     
       if (!world.isRemote) // never spawn entity on client side
       {
            entityToSpawnNameFull = Reference.MOD_ID + "." + entityToSpawnName;
            if (EntityList.stringToClassMapping.containsKey(entityToSpawnNameFull))
            {
                entityToSpawn = (EntityLiving) EntityList
                      .createEntityByName(entityToSpawnNameFull, world);
                entityToSpawn.setLocationAndAngles(posX, posY, posZ, 
                      MathHelper.wrapAngleTo180_float(world.rand.nextFloat()
                      * 360.0F), 0.0F);
                
                world.spawnEntityInWorld(entityToSpawn);
               
                entityToSpawn.onSpawnWithEgg((IEntityLivingData)null);
                entityToSpawn.playLivingSound();
            }
            else
            {
                //DEBUG
                System.out.println("Entity not found "+entityToSpawnName);
            }
        }
      
        return entityToSpawn;
    }


    /**
     * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
     */
    @Override
    @SideOnly(Side.CLIENT)
    public void getSubItems(Item parItem, CreativeTabs parTab, List parList)
    {
        parList.add(new ItemStack(parItem, 1, 0));     
    }

    @Override
    @SideOnly(Side.CLIENT)
    public int getColorFromItemStack(ItemStack par1ItemStack, int parColorType)
    {
        return (parColorType == 0) ? colorBase : colorSpots;
    }

    @Override
    @SideOnly(Side.CLIENT)
    public boolean requiresMultipleRenderPasses()
    {
        return true;
    }
    
    @Override
    // Doing this override means that there is no localization for language
    // unless you specifically check for localization here and convert
    public String getItemStackDisplayName(ItemStack par1ItemStack)
    {
        return (EnumChatFormatting.RED + "Spawn "+entityToSpawnName);
    }  


/*    @Override
    @SideOnly(Side.CLIENT)
    public void registerIcons(IIconRegister par1IconRegister)
    {
        super.registerIcons(par1IconRegister);
        theIcon = par1IconRegister.registerIcon(getIconString() + "sceptre_1");
    }*/
    
    @Override   
    @SideOnly(Side.CLIENT)

        public void registerIcons(IIconRegister iconRegister)
        {
    	this.itemIcon = iconRegister.registerIcon(Reference.MOD_ID +":" + "tobieQueenSceptre");
        }
    /**
     * Gets an icon index based on an item's damage value and the given render pass
     */
    @Override
    @SideOnly(Side.CLIENT)
    public IIcon getIconFromDamageForRenderPass(int parDamageVal, int parRenderPass)
    {
        return parRenderPass > 0 ? this.itemIcon : super.getIconFromDamageForRenderPass(parDamageVal, 
              parRenderPass);
    }
    
   public void setColors(int parColorBase, int parColorSpots)
    {
     colorBase = parColorBase;
     colorSpots = parColorSpots;
    }
    
    public int getColorBase()
    {
     return colorBase;
    }
    
    public int getColorSpots()
    {
     return colorSpots;
    }
    
    public void setEntityToSpawnName(String parEntityToSpawnName)
    {
        entityToSpawnName = parEntityToSpawnName;
        entityToSpawnNameFull = Reference.MOD_ID+"."+entityToSpawnName; 
    }

}

 

Posted

Solved . ..well, sorta ...I commented out this in #render

 

super.render(entity, limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks);

 

and everything works ..BUT 

 

don't think it's good to comment out the super

 

any thoughts??

Posted

Solved . ..well, sorta ...I commented out this in #render

 

super.render(entity, limbSwing, limbSwingAmount, rotFloat, rotYaw, rotPitch, partTicks);

 

and everything works ..BUT 

 

don't think it's good to comment out the super

 

any thoughts??

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.