EntityEnderPearl .java

net.minecraft.entity.item.EntityEnderPearl (class): members: field_181555_c, onImpact, onUpdate. strings: "doMobSpawning". imports: EntityThrowable.

net.minecraft.entity.itemclass109 linescommonextends EntityThrowable3.7 KB

API Surface (2)

void onImpact(MovingObjectPosition p_70184_1_)
void onUpdate()

Fields & Constants (1)

field_181555_c

String literals (1)

"doMobSpawning"

Full Source

EntityEnderPearl.java109 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.entity.item;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.entity.EntityLivingBase;
5
import net.minecraft.entity.monster.EntityEndermite;
6
import net.minecraft.entity.player.EntityPlayer;
7
import net.minecraft.entity.player.EntityPlayerMP;
8
import net.minecraft.entity.projectile.EntityThrowable;
9
import net.minecraft.util.DamageSource;
10
import net.minecraft.util.EnumParticleTypes;
11
import net.minecraft.util.MovingObjectPosition;
12
import net.minecraft.world.World;
13
14
public class EntityEnderPearl extends EntityThrowable
15
{
16
    private EntityLivingBase field_181555_c;
17
18
    public EntityEnderPearl(World worldIn)
19
    {
20
        super(worldIn);
21
    }
22
23
    public EntityEnderPearl(World worldIn, EntityLivingBase p_i1783_2_)
24
    {
25
        super(worldIn, p_i1783_2_);
26
        this.field_181555_c = p_i1783_2_;
27
    }
28
29
    public EntityEnderPearl(World worldIn, double x, double y, double z)
30
    {
31
        super(worldIn, x, y, z);
32
    }
33
34
    /**
35
     * Called when this EntityThrowable hits a block or entity.
36
     */
37
    protected void onImpact(MovingObjectPosition p_70184_1_)
38
    {
39
        EntityLivingBase entitylivingbase = this.getThrower();
40
41
        if (p_70184_1_.entityHit != null)
42
        {
43
            if (p_70184_1_.entityHit == this.field_181555_c)
44
            {
45
                return;
46
            }
47
48
            p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
49
        }
50
51
        for (int i = 0; i < 32; ++i)
52
        {
53
            this.worldObj.spawnParticle(EnumParticleTypes.PORTAL, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
54
        }
55
56
        if (!this.worldObj.isRemote)
57
        {
58
            if (entitylivingbase instanceof EntityPlayerMP)
59
            {
60
                EntityPlayerMP entityplayermp = (EntityPlayerMP)entitylivingbase;
61
62
                if (entityplayermp.playerNetServerHandler.getNetworkManager().isChannelOpen() && entityplayermp.worldObj == this.worldObj && !entityplayermp.isPlayerSleeping())
63
                {
64
                    if (this.rand.nextFloat() < 0.05F && this.worldObj.getGameRules().getBoolean("doMobSpawning"))
65
                    {
66
                        EntityEndermite entityendermite = new EntityEndermite(this.worldObj);
67
                        entityendermite.setSpawnedByPlayer(true);
68
                        entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
69
                        this.worldObj.spawnEntityInWorld(entityendermite);
70
                    }
71
72
                    if (entitylivingbase.isRiding())
73
                    {
74
                        entitylivingbase.mountEntity((Entity)null);
75
                    }
76
77
                    entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
78
                    entitylivingbase.fallDistance = 0.0F;
79
                    entitylivingbase.attackEntityFrom(DamageSource.fall, 5.0F);
80
                }
81
            }
82
            else if (entitylivingbase != null)
83
            {
84
                entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
85
                entitylivingbase.fallDistance = 0.0F;
86
            }
87
88
            this.setDead();
89
        }
90
    }
91
92
    /**
93
     * Called to update the entity's position/logic.
94
     */
95
    public void onUpdate()
96
    {
97
        EntityLivingBase entitylivingbase = this.getThrower();
98
99
        if (entitylivingbase != null && entitylivingbase instanceof EntityPlayer && !entitylivingbase.isEntityAlive())
100
        {
101
            this.setDead();
102
        }
103
        else
104
        {
105
            super.onUpdate();
106
        }
107
    }
108
}
109

Deobfuscated MCP 1.8.9 source of EntityEnderPearl from Marcelektro/MavenMCP-1.8.9 (net/minecraft/entity/item/EntityEnderPearl.java), stored verbatim.