Search in sources :

Example 46 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.

the class DimensionUtilities method doDimensionTransfer.

public static void doDimensionTransfer(EntityLivingBase entity, int dimension) {
    if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        new AMTeleporter(player.mcServer.worldServerForDimension(dimension)).teleport(entity);
    } else {
        entity.worldObj.theProfiler.startSection("changeDimension");
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        int j = entity.dimension;
        WorldServer worldserver = minecraftserver.worldServerForDimension(j);
        WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimension);
        entity.dimension = dimension;
        entity.worldObj.removeEntity(entity);
        entity.isDead = false;
        entity.worldObj.theProfiler.startSection("reposition");
        minecraftserver.getConfigurationManager().transferEntityToWorld(entity, j, worldserver, worldserver1, new AMTeleporter(worldserver1));
        entity.worldObj.theProfiler.endStartSection("reloading");
        Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);
        if (e != null) {
            e.copyDataFrom(entity, true);
            worldserver1.spawnEntityInWorld(e);
        }
        entity.isDead = true;
        entity.worldObj.theProfiler.endSection();
        worldserver.resetUpdateEntityTick();
        worldserver1.resetUpdateEntityTick();
        entity.worldObj.theProfiler.endSection();
    }
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) WorldServer(net.minecraft.world.WorldServer) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 47 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project minecolonies by Minecolonies.

the class AbstractMessage method onMessage.

@Nullable
@Override
public B onMessage(final A message, final MessageContext ctx) {
    final EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    player.getServerWorld().addScheduledTask(() -> messageOnServerThread(message, player));
    return null;
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Nullable(org.jetbrains.annotations.Nullable)

Example 48 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP 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)

Example 49 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.

the class PlayerTracker method onPlayerLogin.

@SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent event) {
    if (hasAA(event.player)) {
        AMNetHandler.INSTANCE.requestClientAuras((EntityPlayerMP) event.player);
    }
    int[] disabledSkills = SkillTreeManager.instance.getDisabledSkillIDs();
    AMDataWriter writer = new AMDataWriter();
    writer.add(AMCore.config.getSkillTreeSecondaryTierCap()).add(disabledSkills);
    writer.add(AMCore.config.getManaCap());
    byte[] data = writer.generate();
    AMNetHandler.INSTANCE.syncLoginData((EntityPlayerMP) event.player, data);
    if (ServerTickHandler.lastWorldName != null)
        AMNetHandler.INSTANCE.syncWorldName((EntityPlayerMP) event.player, ServerTickHandler.lastWorldName);
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) AMDataWriter(am2.network.AMDataWriter) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 50 with EntityPlayerMP

use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.

the class ArmorEventHandler method doInfusions.

private void doInfusions(ImbuementApplicationTypes type, Event event, EntityPlayer player) {
    ExtendedProperties props = ExtendedProperties.For(player);
    for (int i = 0; i < 4; ++i) {
        IArmorImbuement[] infusions = ArmorHelper.getInfusionsOnArmor(player, i);
        int cd = props.armorProcCooldowns[i];
        for (IArmorImbuement inf : infusions) {
            if (inf == null)
                continue;
            if (inf.getApplicationTypes().contains(type)) {
                if (cd == 0 || inf.canApplyOnCooldown()) {
                    if (inf.applyEffect(player, player.worldObj, player.getCurrentArmor(i), type, event)) {
                        if (inf.getCooldown() > 0) {
                            if (props.armorProcCooldowns[i] < inf.getCooldown()) {
                                props.armorProcCooldowns[i] = inf.getCooldown();
                                if (player instanceof EntityPlayerMP)
                                    AMCore.proxy.blackoutArmorPiece((EntityPlayerMP) player, i, inf.getCooldown());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) IArmorImbuement(am2.api.items.armor.IArmorImbuement) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)163 EntityPlayer (net.minecraft.entity.player.EntityPlayer)32 ItemStack (net.minecraft.item.ItemStack)23 TileEntity (net.minecraft.tileentity.TileEntity)18 Entity (net.minecraft.entity.Entity)17 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)14 BlockPos (net.minecraft.util.math.BlockPos)14 Block (net.minecraft.block.Block)11 IBlockState (net.minecraft.block.state.IBlockState)8 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 World (net.minecraft.world.World)8 WrongUsageException (net.minecraft.command.WrongUsageException)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)7 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)5 TileEntityReceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityReceiver)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)5