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();
}
}
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;
}
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();
}
}
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);
}
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());
}
}
}
}
}
}
}
}
Aggregations