use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.
the class ExtendedProperties method setEntityReference.
//=======================================================================================
// Utility Methods
//=======================================================================================
public void setEntityReference(EntityLivingBase entity) {
this.entity = entity;
setOriginalSize(new AMVector2(entity.width, entity.height));
hasInitialized = true;
isCritical = entity instanceof EntityPlayerMP;
yOffsetOrig = entity.yOffset;
if (isCritical)
ticksToRegen = 5;
else
ticksToRegen = 20;
if (isCritical) {
if (armorProcCooldowns[3] > 0) {
AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 3, armorProcCooldowns[3]);
}
if (armorProcCooldowns[1] > 0) {
AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 1, armorProcCooldowns[1]);
}
if (armorProcCooldowns[2] > 0) {
AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 2, armorProcCooldowns[2]);
}
if (armorProcCooldowns[0] > 0) {
AMCore.instance.proxy.blackoutArmorPiece((EntityPlayerMP) entity, 0, armorProcCooldowns[0]);
}
}
if (entity.worldObj != null && entity.worldObj.isRemote && entity instanceof EntityPlayer && AMCore.proxy.playerTracker.hasAA((EntityPlayer) entity)) {
EntityLivingBase localPlayer = AMCore.instance.proxy.getLocalPlayer();
if (entity != localPlayer)
AMNetHandler.INSTANCE.requestAuras((EntityPlayer) entity);
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.
the class BlockLectern method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
TileEntityLectern te = getTileEntity(world, x, y, z);
if (te == null) {
return true;
}
if (te.hasStack()) {
if (player.isSneaking()) {
if (!world.isRemote && ((player instanceof EntityPlayerMP) && ((EntityPlayerMP) player).theItemInWorldManager.getGameType() != GameType.ADVENTURE)) {
float f = world.rand.nextFloat() * 0.8F + 0.1F;
float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
float f2 = world.rand.nextFloat() * 0.8F + 0.1F;
ItemStack newItem = new ItemStack(te.getStack().getItem(), 1, te.getStack().getItemDamage());
if (te.getStack().stackTagCompound != null)
newItem.setTagCompound((NBTTagCompound) te.getStack().stackTagCompound.copy());
EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, newItem);
float f3 = 0.05F;
entityitem.motionX = (float) world.rand.nextGaussian() * f3;
entityitem.motionY = (float) world.rand.nextGaussian() * f3 + 0.2F;
entityitem.motionZ = (float) world.rand.nextGaussian() * f3;
world.spawnEntityInWorld(entityitem);
te.setStack(null);
}
} else {
te.getStack().getItem().onItemRightClick(te.getStack(), world, player);
}
} else {
if (player.getCurrentEquippedItem() != null) {
if (te.setStack(player.getCurrentEquippedItem())) {
player.getCurrentEquippedItem().stackSize--;
if (player.getCurrentEquippedItem().stackSize <= 0) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
}
}
return true;
}
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();
}
}
Aggregations