EntityLiving и EntityMob

397
8
33
В общем, если делать мирного моба, все хорошо, только я до текстуры не дошел :silly:
А вот, если перевести этого моба в "злой" режим, так сразу краш при его спавне. В чем хитрость, как исправить? 1.6.4 если необходимо - скину логи краша
 
Уно моменто
[merge_posts_bbcode]Добавлено: 05.03.2015 01:10:18[/merge_posts_bbcode]

По сути, вот. 
Код:
---- Minecraft Crash Report ----
// Quite honestly, I wouldn't worry myself about that.

Time: 04.03.15 13:12
Description: Ticking entity

java.lang.NullPointerException
    at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:900)
    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1818)
    at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:257)
    at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:45)
    at net.minecraft.entity.monster.EntityZombie.onUpdate(EntityZombie.java:283)
    at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
    at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
    at net.minecraft.world.World.updateEntity(World.java:2311)
    at net.minecraft.world.World.updateEntities(World.java:2157)
    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
    at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
    at net.minecraft.item.ItemStack.getAttributeModifiers(ItemStack.java:900)
    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1818)
    at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:257)
    at net.minecraft.entity.monster.EntityMob.onUpdate(EntityMob.java:45)
    at net.minecraft.entity.monster.EntityZombie.onUpdate(EntityZombie.java:283)
    at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2350)
    at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:719)
    at net.minecraft.world.World.updateEntity(World.java:2311)

-- Entity being ticked --
Details:
    Entity Type: Zombie (net.minecraft.entity.monster.EntityZombie)
    Entity ID: 459
    Entity Name: Зомби
    Entity's Exact location: 143,50, 28,00, 261,50
    Entity's Block location: World: (143,28,261), Chunk: (at 15,1,5 in 8,16; contains blocks 128,0,256 to 143,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Entity's Momentum: 0,00, 0,00, 0,00
Stacktrace:
    at net.minecraft.world.World.updateEntities(World.java:2157)
    at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:550)

-- Affected level --
Details:
    Level name: Новый мир
    All players: 1 total; [EntityPlayerMP['Player949'/288, l='Новый мир', x=91,50, y=62,00, z=249,50]]
    Chunk stats: ServerChunkCache: 626 Drop: 0
    Level seed: -1678944800253072489
    Level generator: ID 00 - default, ver 1. Features enabled: true
    Level generator options: 
    Level spawn location: World: (96,64,256), Chunk: (at 0,4,0 in 6,16; contains blocks 96,0,256 to 111,255,271), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
    Level time: 7 game time, 7 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 94478 (now: false), thunder time: 64827 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
Stacktrace:
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:668)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484)
    at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

-- System Details --
Details:
    Minecraft Version: 1.6.4
    Operating System: Windows 8.1 (amd64) version 6.3
    Java Version: 1.7.0_67, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 801306768 bytes (764 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    AABB Pool Size: 3226 (180656 bytes; 0 MB) allocated, 3226 (180656 bytes; 0 MB) used
    Suspicious classes: FML and Forge are installed
    IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 63
    FML: MCP v8.11 FML v6.4.49.965 Minecraft Forge 9.11.1.965 4 mods loaded, 4 mods active
    mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FML{6.4.49.965} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Forge{9.11.1.965} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    gothicmod{1.01} [GothicMod Minecraft] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 852 (47712 bytes; 0 MB) allocated, 852 (47712 bytes; 0 MB) used
    Player Count: 1 / 8; [EntityPlayerMP['Player949'/288, l='Новый мир', x=91,50, y=62,00, z=249,50]]
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge'
 
Да код банально с паука скопировал. attackEntity прятал, потому что проверял на мирном.
Код:
public class mob_crawler extends EntityLiving
{
    private Object entityToAttack;

    public mob_crawler(World par1World)
    {
        super(par1World);
        this.setSize(1.4F, 0.9F);
    }

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

    /**
     * Called to update the entity's position/logic.
     */
    public void onUpdate()
    {
        super.onUpdate();

        if (!this.worldObj.isRemote)
        {
            this.setBesideClimbableBlock(this.isCollidedHorizontally);
        }
    }

    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(16.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.800000011920929D);
    }

    /**
     * Finds the closest player within 16 blocks to attack, or null if this Entity isn't interested in attacking
     * (Animals, Spiders at day, peaceful PigZombies).
     */
    protected Entity findPlayerToAttack()
    {
        float f = this.getBrightness(1.0F);

        if (f < 0.5F)
        {
            double d0 = 16.0D;
            return this.worldObj.getClosestVulnerablePlayerToEntity(this, d0);
        }
        else
        {
            return null;
        }
    }

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

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

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.spider.death";
    }

    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.playSound("mob.spider.step", 0.15F, 1.0F);
    }

    /**
     * Basic mob attack. Default to touch of death in EntityCreature. Overridden by each mob to define their attack.
     */
    /* protected void attackEntity(Entity par1Entity, float par2)
    {
        float f1 = this.getBrightness(1.0F);

        if (f1 > 0.5F && this.rand.nextInt(100) == 0)
        {
            this.entityToAttack = null;
        }
        else
        {
            if (par2 > 2.0F && par2 < 6.0F && this.rand.nextInt(10) == 0)
            {
                if (this.onGround)
                {
                    double d0 = par1Entity.posX - this.posX;
                    double d1 = par1Entity.posZ - this.posZ;
                    float f2 = MathHelper.sqrt_double(d0 * d0 + d1 * d1);
                    this.motionX = d0 / (double)f2 * 0.5D * 0.800000011920929D + this.motionX * 0.20000000298023224D;
                    this.motionZ = d1 / (double)f2 * 0.5D * 0.800000011920929D + this.motionZ * 0.20000000298023224D;
                    this.motionY = 0.4000000059604645D;
                }
            }
            else
            {
                super.attackEntity(par1Entity, par2);
            }
        }
    }*/

    /**
     * Returns the item ID for the item the mob drops on death.
     */
    protected int getDropItemId()
    {
        return Item.silk.itemID;
    }

    /**
     * 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 par1, int par2)
    {
        super.dropFewItems(par1, par2);

        if (par1 && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + par2) > 0))
        {
            this.dropItem(Item.spiderEye.itemID, 1);
        }
    }

    /**
     * returns true if this entity is by a ladder, false otherwise
     */
    public boolean isOnLadder()
    {
        return this.isBesideClimbableBlock();
    }

    /**
     * Sets the Entity inside a web block.
     */
    public void setInWeb() {}

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

    public boolean isPotionApplicable(PotionEffect par1PotionEffect)
    {
        return par1PotionEffect.getPotionID() == Potion.poison.id ? false : super.isPotionApplicable(par1PotionEffect);
    }

    /**
     * Returns true if the WatchableObject (Byte) is 0x01 otherwise returns false. The WatchableObject is updated using
     * setBesideClimableBlock.
     */
    public boolean isBesideClimbableBlock()
    {
        return (this.dataWatcher.getWatchableObjectByte(16) & 1) != 0;
    }

    /**
     * Updates the WatchableObject (Byte) created in entityInit(), setting it to 0x01 if par1 is true or 0x00 if it is
     * false.
     */
    public void setBesideClimbableBlock(boolean par1)
    {
        byte b0 = this.dataWatcher.getWatchableObjectByte(16);

        if (par1)
        {
            b0 = (byte)(b0 | 1);
        }
        else
        {
            b0 &= -2;
        }

        this.dataWatcher.updateObject(16, Byte.valueOf(b0));
    }

    public EntityLivingData onSpawnWithEgg(EntityLivingData par1EntityLivingData)
    {
        Object par1EntityLivingData1 = super.onSpawnWithEgg(par1EntityLivingData);

        if (this.worldObj.rand.nextInt(100) == 0)
        {
            EntitySkeleton entityskeleton = new EntitySkeleton(this.worldObj);
            entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
            entityskeleton.onSpawnWithEgg((EntityLivingData)null);
            this.worldObj.spawnEntityInWorld(entityskeleton);
            entityskeleton.mountEntity(this);
        }

        if (par1EntityLivingData1 == null)
        {
            par1EntityLivingData1 = new SpiderEffectsGroupData();

            if (this.worldObj.difficultySetting > 2 && this.worldObj.rand.nextFloat() < 0.1F * this.worldObj.getLocationTensionFactor(this.posX, this.posY, this.posZ))
            {
                ((SpiderEffectsGroupData)par1EntityLivingData1).func_111104_a(this.worldObj.rand);
            }
        }

        if (par1EntityLivingData1 instanceof SpiderEffectsGroupData)
        {
            int i = ((SpiderEffectsGroupData)par1EntityLivingData1).field_111105_a;

            if (i > 0 && Potion.potionTypes[i] != null)
            {
                this.addPotionEffect(new PotionEffect(i, Integer.MAX_VALUE));
            }
        }

        return (EntityLivingData)par1EntityLivingData1;
    }
}
 
[font=Verdana, Helvetica, Arial, sans-serif]Я думаю,что ты забыл урон ему повесить[/font]
 
Назад
Сверху