Jump to content

[1.8.9] Entity creates lag in game and walks into blocks


Recommended Posts

Posted

As stated in subject line:  my custom entity walks right into blocks.  I have tried a few methods such as #getCollisionBox, #getEntityBoundingBox, and #getCollisionBoundingBox from AxisAlignedBB

 

When my custom mob walks through any block the game lags, nearly stalls.  Please let me know and I can post any code

 

EntityBlackTobo class:

 

package com.glistre.glistremod.entities.blacktobie;

 

import java.util.Calendar;

import java.util.Iterator;

import java.util.List;

 

import com.glistre.glistremod.GlistreMod;

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

import com.glistre.glistremod.entities.wolf.EntityGlistreWolf;

import com.glistre.glistremod.init.GlistreEntityRegistry;

import com.glistre.glistremod.init.ItemRegistry;

import com.glistre.glistremod.projectiles.blaster.EntityBlasterBolt;

 

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

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.item.EntityItem;

//import net.minecraft.entity.item.EntityItem;

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.monster.IMob;

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

import net.minecraft.util.ChatComponentText;

import net.minecraft.util.DamageSource;

import net.minecraft.util.EnumChatFormatting;

import net.minecraft.util.EnumParticleTypes;

import net.minecraft.util.MathHelper;

import net.minecraft.world.DifficultyInstance;

import net.minecraft.world.World;

import net.minecraft.world.WorldProviderHell;

 

public class EntityBlackTobo extends EntityMob implements IRangedAttackMob

{

    private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);

//returning false fourth parameter will remove that entity 

    private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);

    private static final ItemStack defaultHeldItem = new ItemStack(ItemRegistry.tobie_gun_1, 1);

 

    public AxisAlignedBB boundingBox;

    private int attackTimer;

   

    public EntityBlackTobo(World world)

    {

        super(world);

        //trying to make immune to fire damage not working

 

//      this.isImmuneToFire();

 

        //trying to raise the hit box

        setSize(1.0F, 4.5F);

//        this.boundingBox.setBounds(minX,minY,minZ,maxX,maxY,maxZ);

        this.getEntityBoundingBox().fromBounds(0D, 0D, 0D, .5D, .5D, .5D);

 

        this.setSkeletonType(0);

        this.targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));

        this.tasks.addTask(0, new EntityAISwimming(this));

        //should match same method above for Double and fourth parameter no need for Player set to false above

//      this.tasks.addTask(1,  new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));

        this.tasks.addTask(1,  new EntityAIAttackOnCollide(this, EntityTobieSkel.class, 1.0D, true));     

        this.tasks.addTask(3, new EntityAIRestrictSun(this));

        this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D));

        this.tasks.addTask(0, new EntityAIWander(this, 1.0D));

        this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

        this.tasks.addTask(0, new EntityAIWatchClosest(this, EntityTobieSkel.class, 8.0F));

       

        this.tasks.addTask(4, new EntityAILookIdle(this));

        this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, true));

        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityTobieSkel.class, 2, true, false, IMob.mobSelector));

        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityGlistreWolf.class, 3, true, false, IMob.mobSelector));

     

 

        if (world != null && !world.isRemote)

        {

            this.setCombatTask();

        }

    }

 

 

  @Override

public AxisAlignedBB getCollisionBox(Entity par1Entity) {

   

return boundingBox;

}

 

@Override

//#getBoundingBox changed to #getCollisionBoundingBox 1.8.9  //collision defines hitbox //selected defines area around

public AxisAlignedBB getCollisionBoundingBox() {

return boundingBox;

}

@Override

    protected void applyEntityAttributes()

    {

        super.applyEntityAttributes();

//      this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);

        this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(100.0D);

        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.34000000417232513D);

        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);

        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(65.0D);

        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(10.0D);

    }

@Override

    protected void entityInit()

    {

        super.entityInit();

        //changed 13 to 26 can go up to 31 better to use packets

        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);

    }

 

    @SideOnly(Side.CLIENT)

    public int getAttackTimer()

    {

        return this.attackTimer;

    }

   

    public boolean attackEntityAsMob(Entity targetEntity)

    {

      if (super.attackEntityAsMob(targetEntity))

      {

                  /*  if (this.getSkeletonType() == 1 && targetEntity instanceof EntityLivingBase)

                    {

                        ((EntityLivingBase)targetEntity).addPotionEffect(new PotionEffect(Potion.wither.id, 200));

                    }*/

        this.attackTimer = 10;

        this.worldObj.setEntityState(this, (byte)4);

        boolean flag = targetEntity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)(7 + this.rand.nextInt(15)));

 

        if (flag)

        {

          targetEntity.motionY += 0.4000000059604645D;

        }

 

                    this.playSound("mob.irongolem.throw", 1.0F, 1.0F);

                    return flag;

                }

                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(8);

                }

            }

        }

 

        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 source)

    {

        super.onDeath(source);

//source.getSourceOfDamage() instanceof EntityBlasterBolt &&

        if ( source.getEntity() instanceof EntityPlayer)

        {

            EntityPlayer entityplayer = (EntityPlayer)source.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.ender_gun;

    }

   

 

    /**

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

    */

    @Override

    protected void dropFewItems(boolean hasPlayerHit, int lootingLev)

    {

    World world = worldObj;

        int j;

        int k;

       

        if (this.getSkeletonType() == 0)

        {   

        final String KEY = "activated";

            ItemStack toDrop = new ItemStack(ItemRegistry.mighty_sword, 1);

            if(toDrop.getTagCompound() == null)

            {

                toDrop.setTagCompound(new NBTTagCompound());

                toDrop.getTagCompound().setBoolean(KEY, false);

 

            }

    //      j = this.rand.nextInt(3 + lootingLev) - 1;

    //    for (k = 0; k < j; ++k)

             

    //        {

            if (!(worldObj.isRemote)){

            EntityItem dropItem = new EntityItem(worldObj, this.posX, this.posY, this.posZ, toDrop);

 

            worldObj.spawnEntityInWorld(dropItem);

            }

 

        j = this.rand.nextInt(3 + lootingLev) - 1;

             

            for (k = 0; k < j; ++k)

            {

          this.entityDropItem(new ItemStack(ItemRegistry.glistre_sword, 1, 1), 1.0F);

            }

       

        j = this.rand.nextInt(3 + lootingLev) - 1;

 

        for (k = 0; k < j; ++k)

        {

            this.dropItem(ItemRegistry.nausea_protection, 1);

        }

       

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

 

        for (k = 0; k < j; ++k)

        {

        ItemRegistry instance = new ItemRegistry();

        ItemStack ancientBook = instance.getAncientBook();

        ancientBook.getItem();

        this.entityDropItem(ancientBook, 1.0F);

        }

       

        j = this.rand.nextInt(3 + lootingLev) - 1;

 

        for (k = 0; k < j; ++k)

        {

        this.dropItem(GlistreEntityRegistry.splash_poison_protection, 1);

        }

 

        //1.8 way to make 40% chance of drop

        if(rand.nextInt(100)<40){

        int p;

                int q;

               

            p = this.rand.nextInt(3 + lootingLev) + 1;

 

        for (q = 0; q < p; ++q)

            // what does float do here?  likelihood of drop?         

              {

           

            this.entityDropItem(new ItemStack(GlistreEntityRegistry.tobie_worst_projectile_1, 1, 1), 1.0F);

              }

        for (q = 0; q < p; ++q)

                // what does float do here?  likelihood of drop?         

                  {

               

                this.entityDropItem(new ItemStack(ItemRegistry.chain_helmet_1, 1, 1), 1.0F);

                  }

        p = this.rand.nextInt(3 + lootingLev);

 

        for (q = 0; q < p; ++q)

            {

            this.dropItem(ItemRegistry.custom_bow_1, 1);

            }

        }

        }

       

    }

 

/*  @Override

    protected void dropRareDrop(int num)

    {

       

        if (this.getSkeletonType() == 0){

        int j;

            int k;

           

        j = this.rand.nextInt(3 + num) + 1;

 

    for (k = 0; k < j; ++k)

        // what does float do here?  likelihood of drop?         

          {

       

        this.entityDropItem(new ItemStack(GlistreEntityRegistry.tobie_worst_projectile_1, 1, 1), 1.0F);

          }

    for (k = 0; k < j; ++k)

            // what does float do here?  likelihood of drop?         

              {

           

            this.entityDropItem(new ItemStack(ItemRegistry.chain_helmet_1, 1, 1), 1.0F);

              }

       

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

 

    for (k = 0; k < j; ++k)

        {

        this.dropItem(ItemRegistry.item_spawn_egg_3, 1);

        }

        } 

    }*/

 

   

    /**

    * Makes entity wear random armor based on difficulty

    */

 

  protected void addRandomArmor()

    {

//      super.addRandomArmor();

      this.setCurrentItemOrArmor(0, new ItemStack(ItemRegistry.tobie_gun_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;

    }

  @Override

  //1.8.9 changed func_180482_a to #onInitialSpawn

  public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData entitylivingdata)

    {

  entitylivingdata = super.onInitialSpawn(difficulty, entitylivingdata);

 

        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(1.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.tobie_gun_1));

            this.enchantEquipment();

        }

 

        this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * difficulty.getClampedAdditionalDifficulty());

//      this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * this.worldObj.(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 entitylivingdata;

    }

  /**

    * Enchants the entity's armor and held item based on difficulty

    */

  public void enchantEquipment()

  {

      float f = 1.0F;

 

      if (this.getHeldItem() != null && this.rand.nextFloat() < 0.25F * f)

      {

          EnchantmentHelper.addRandomEnchantment(this.rand, this.getHeldItem(), (int)(5.0F + f * (float)this.rand.nextInt(18)));

      }

 

  //    for (int i = 0; i < 4; ++i)

  //    {

     

//1.8 update not doubt this probably will not work :  change func_130225_q(i) to this getHeldItem  and dleteled for loop        for (int i = 0; i < 4; ++i)

    //      {  

          ItemStack itemstack = this.getHeldItem();

 

          if (itemstack != null && this.rand.nextFloat() < 0.5F * f)

          {

              EnchantmentHelper.addRandomEnchantment(this.rand, itemstack, (int)(5.0F + f * (float)this.rand.nextInt(18)));

          }

//      }

  }

 

 

    /**

    * sets this entity's combat AI.

    */

//  @Override

    public void setCombatTask()

    {

        this.tasks.removeTask(this.aiAttackOnCollide);

        this.tasks.removeTask(this.aiArrowAttack);

        ItemStack itemstack = this.getHeldItem();

 

        if (itemstack != null && itemstack.getItem() == ItemRegistry.tobie_gun_1)

        {

            this.tasks.addTask(0, this.aiArrowAttack);

        }

        else

        {

            this.tasks.addTask(1, this.aiAttackOnCollide);

        }

    }

 

    /**

    * Attack the specified entity using a ranged attack.

    */

    @Override

    public void attackEntityWithRangedAttack(EntityLivingBase target, float distance)

    {

/*      EntityBlasterBolt entityblasterbolt = new EntityBlasterBolt(this.worldObj, this, target, 1.6F, (float)(14 - this.worldObj.getDifficulty().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.getDifficulty().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);

        }*/

    EntityBlasterBolt entityblasterbolt = new EntityBlasterBolt(this.worldObj, this, target, 500F, (float)(100));

        double d0 = target.posX - this.posX;

        double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - (this.posY + (double)(this.height / 2.0F));

 

//      double d1 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D - entityblasterbolt.posY;

        double d2 = target.posZ - this.posZ;

        float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;

        entityblasterbolt.setThrowableHeading(d0, d1 + (double)f1, d2, 0.6F, 12.0F);

 

        this.playSound("glistremod:laser_blaster", 1.2F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

        this.worldObj.spawnEntityInWorld(entityblasterbolt);

       

 

        }

 

/*    @Override

    public void onLivingUpdate()

    {

      if (this.getHealth() < this.getMaxHealth() && this.ticksExisted % 400 == 0)

      {

      // this.heal(1.0F);

          this.playSound("mob.blaze.hit", 1.2F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

     

      worldObj.spawnParticle(EnumParticleTypes.PORTAL, posX + (rand.nextDouble() - 0.5D) * (double)width, posY + (rand.nextDouble() * (double)height), posZ + (rand.nextDouble() - 0.5D) * (double)width, 1.0D, 0.0D, 0.0D);

 

      }

      else if (this.getHealth() == 0 ){

          this.playSound("glistremod:sceptre_1", 1.2F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));

          Minecraft.getMinecraft().thePlayer.addChatMessage(

new ChatComponentText(EnumChatFormatting.DARK_RED + "You have AWAKENED TOBIE KING!"));

          worldObj.spawnParticle(EnumParticleTypes.PORTAL, posX + (rand.nextDouble() - 0.5D) * (double)width, posY + (rand.nextDouble() * (double)height), posZ + (rand.nextDouble() - 0.5D) * (double)width, 1.0D, 0.0D, 0.0D);

      }

     

      super.onLivingUpdate();

    }*/

 

  @Override

    public void onUpdate(){

    super.onUpdate();

    if (!(worldObj.isRemote && this.ticksExisted < 400)){

 

List<EntityPlayer> playerList = worldObj.getEntitiesWithinAABB(EntityPlayer.class, this.getEntityBoundingBox().expand(45.0D, 35.0D, 45.0D));

Iterator<EntityPlayer> i1 = playerList.iterator();

EntityPlayer entityplayer;

 

              while (i1.hasNext())

              {

                entityplayer = (EntityPlayer)i1.next();

double inRange = this.getDistanceSqToEntity(entityplayer);

 

if ( inRange < 1600.0D & inRange > 1580.0D)

 

if(entityplayer.getHeldItem() !=null &&  entityplayer.getHeldItem().getItem() == ItemRegistry.mighty_sword){

 

        entityplayer.addChatComponentMessage(

                    new ChatComponentText(EnumChatFormatting.DARK_GREEN + "Corrupt Tobie in Range location "

                    + EnumChatFormatting.DARK_RED + " X: " + (int)Math.round(this.posX)

                    + EnumChatFormatting.GOLD + " | Y: " + (int)Math.round(this.posY)

                    + EnumChatFormatting.DARK_AQUA +" | Z: " + (int)Math.round(this.posZ)));

}

 

            }}

    }           

           

   

 

    /**

    * Return this skeleton's type.

    */

    public int getSkeletonType()

    {

        return this.dataWatcher.getWatchableObjectByte(13);

    }

 

    /**

    * Set this skeleton's type.

    */

    public void setSkeletonType(int type)

    {

        this.dataWatcher.updateObject(13, Byte.valueOf((byte)type));

        this.isImmuneToFire = type == 1;

 

        if (type == 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 compound)

    {

        super.readEntityFromNBT(compound);

 

        if (compound.hasKey("SkeletonType", 99))

        {

            byte b0 = compound.getByte("SkeletonType");

            this.setSkeletonType(b0);

        }

 

        this.setCombatTask();

 

    }

    /**

    * (abstract) Protected helper method to write subclass entity data to NBT.

    */

    public void writeEntityToNBT(NBTTagCompound compound)

    {

        super.writeEntityToNBT(compound);

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

    }

//  needs to be false or by the time the Player gets to location the Tobie will be gone   

    @Override

    public boolean canDespawn(){

return false;

    }

   

    @Override

    public ItemStack getHeldItem()

    {

        return defaultHeldItem;

    }

/*   

    @Override

public void setPosition(double par1, double par2, double par3) {

AxisAlignedBB b = this.getEntityBoundingBox();

double boxSX = b.maxX - b.minX;

double boxSY = b.maxY - b.minY;

double boxSZ = b.maxZ - b.minZ;

this.getEntityBoundingBox().fromBounds(posX - boxSX/2D, posY, posZ - boxSZ/2D, posX + boxSX/2D, posY + boxSY, posZ + boxSZ/2D);

}*/

}

 

 

I hope 1.8.9 still supported here , I really need to fix several bugs in my mod before updating to 1.10! 

Posted

That seems to have helped a bit

 

I am still very laggy in the custom biome / dimension ...for ex, I hit the entity after the fifth time the game literally freezes ....

 

Is there a way to run a report on my mod to find out what is causing this ...ie,: how much is chunk generation, how much is entity , how much is errors from rendering or something like that  ..?

 

 

 

Posted

Shift F3

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

gameRenderer == 53%

display_update == 34%

 

 

Edit:

Found one problem in Renderer where I did not override    @Override // 1.8 changed func_82422_c() transformHeldFull3DItemLayer()

 

Now it seems to just stalls loading chunks 68% display_update, 28% gameRenderer

 

 

 

 

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

    • Hello all. I'm currently grappling with the updateShape method in a custom class extending Block.  My code currently looks like this: The conditionals in CheckState are there to switch blockstate properties, which is working fine, as it functions correctly every time in getStateForPlacement.  The problem I'm running into is that when I update a state, the blocks seem to call CheckState with the position of the block which was changed updated last.  If I build a wall I can see the same change propagate across. My question thus is this: is updateShape sending its return to the neighbouring block?  Is each block not independently executing the updateShape method, thus inserting its own current position?  The first statement appears to be true, and the second false (each block is not independently executing the method). I have tried to fix this by saving the block's own position to a variable myPos at inception, and then feeding this in as CheckState(myPos) but this causes a worse outcome, where all blocks take the update of the first modified block, rather than just their neighbour.  This raises more questions than it answers, obviously: how is a different instance's variable propagating here?  I also tried changing it so that CheckState did not take a BlockPos, but had myPos built into the body - same problem. I have previously looked at neighbourUpdate and onNeighbourUpdate, but could not find a way to get this to work at all.  One post on here about updatePostPlacement and other methods has proven itself long superceded.  All other sources on the net seem to be out of date. Many thanks in advance for any help you might offer me, it's been several days now of trying to get this work and several weeks of generally trying to get round this roadblock.  - Sandermall
    • sorry, I might be stupid, but how do I open it? because the only options I have are too X out, copy it, which doesn't work and send crash report, which doesn't show it to me, also, sorry for taking so long.
    • Can you reproduce this with version 55.0.21? A whole lot of plant placement issues were just fixed in this PR.
    • Necro'ing that thread to ask if you found a solution ? I'm encountering the same crash on loading the world. I created the world in Creative to test my MP, went into survival to test combat, died, crashed on respawn and since then crash on loading the world. Deactivating Oculus isn't fixing it either, and I don't have Optifine (Twilight forest is incompatible)
  • Topics

×
×
  • Create New...

Important Information

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