Search in sources :

Example 1 with TileEntityEndGateway

use of net.minecraft.tileentity.TileEntityEndGateway in project Pearcel-Mod by MiningMark48.

the class EntityEnderPearcel method onImpact.

@Override
protected void onImpact(RayTraceResult result) {
    EntityLivingBase entitylivingbase = this.getThrower();
    if (result.entityHit != null) {
        if (result.entityHit == this.thrower) {
            return;
        }
        result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, entitylivingbase), 0.0F);
    }
    if (result.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos entityplayermp = result.getBlockPos();
        TileEntity event = this.world.getTileEntity(entityplayermp);
        if (event instanceof TileEntityEndGateway) {
            TileEntityEndGateway var9 = (TileEntityEndGateway) event;
            if (entitylivingbase != null) {
                var9.teleportEntity(entitylivingbase);
                this.setDead();
                return;
            }
            var9.teleportEntity(this);
            return;
        }
    }
    for (int var6 = 0; var6 < 32; ++var6) {
        this.world.spawnParticle(EnumParticleTypes.FIREWORKS_SPARK, this.posX, this.posY + this.rand.nextDouble() * 2.0D, this.posZ, this.rand.nextGaussian(), 0.0D, this.rand.nextGaussian(), new int[0]);
    }
    if (!this.world.isRemote) {
        if (entitylivingbase instanceof EntityPlayerMP) {
            EntityPlayerMP var7 = (EntityPlayerMP) entitylivingbase;
            if (var7.connection.getNetworkManager().isChannelOpen() && var7.world == this.world && !var7.isPlayerSleeping()) {
                EnderTeleportEvent var8 = new EnderTeleportEvent(var7, this.posX, this.posY, this.posZ, 5.0F);
                if (!MinecraftForge.EVENT_BUS.post(var8)) {
                    if (this.rand.nextFloat() < 0.05F && this.world.getGameRules().getBoolean("doMobSpawning")) {
                        EntityEndermite entityendermite = new EntityEndermite(this.world);
                        entityendermite.setSpawnedByPlayer(true);
                        entityendermite.setLocationAndAngles(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, entitylivingbase.rotationYaw, entitylivingbase.rotationPitch);
                        this.world.spawnEntity(entityendermite);
                    }
                    if (entitylivingbase.isRiding()) {
                        this.dismountRidingEntity();
                    }
                    entitylivingbase.setPositionAndUpdate(var8.getTargetX(), var8.getTargetY(), var8.getTargetZ());
                    entitylivingbase.fallDistance = 0.0F;
                }
            }
        } else if (entitylivingbase != null) {
            entitylivingbase.setPositionAndUpdate(this.posX, this.posY, this.posZ);
            entitylivingbase.fallDistance = 0.0F;
        }
        this.setDead();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) EnderTeleportEvent(net.minecraftforge.event.entity.living.EnderTeleportEvent) EntityLivingBase(net.minecraft.entity.EntityLivingBase) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) EntityEndermite(net.minecraft.entity.monster.EntityEndermite) TileEntityEndGateway(net.minecraft.tileentity.TileEntityEndGateway)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityEndermite (net.minecraft.entity.monster.EntityEndermite)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityEndGateway (net.minecraft.tileentity.TileEntityEndGateway)1 BlockPos (net.minecraft.util.math.BlockPos)1 EnderTeleportEvent (net.minecraftforge.event.entity.living.EnderTeleportEvent)1