use of net.minecraft.entity.player.EntityPlayerMP in project Overloaded by CJ-MC-Mods.
the class MultiToolRightClickHandler method onMessage.
/**
* Called when a message is received of the appropriate type. You can optionally return a reply message, or null if no reply
* is needed.
*
* @param message The message
* @param ctx the context of the message
* @return an optional return message
*/
@Override
@Nullable
public IMessage onMessage(MultiToolRightClickMessage message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
WorldServer world = player.getServerWorld();
world.addScheduledTask(() -> ModItems.itemMultiTool.rightClickWithItem(world, player, message.getPos(), message.getHitSide(), message.getHitX(), message.getHitY(), message.getHitZ()));
// Nothing to send to client from here
return null;
}
use of net.minecraft.entity.player.EntityPlayerMP in project ICBM-Classic by BuiltBrokenModding.
the class BlastEnderman method doExplode.
@Override
public void doExplode() {
if (this.world().isRemote) {
int r = (int) (this.getRadius() - ((double) this.callCount / (double) this.duration) * this.getRadius());
for (int x = -r; x < r; x++) {
for (int z = -r; z < r; z++) {
for (int y = -r; y < r; y++) {
Location targetPosition = position.add(new Pos(x, y, z));
double distance = targetPosition.distance(position);
if (distance < r && distance > r - 1) {
if (targetPosition.getBlock(world()) != Blocks.air)
continue;
if (this.world().rand.nextFloat() < Math.max(0.001 * r, 0.01)) {
float velX = (float) ((targetPosition.x() - position.x()) * 0.6);
float velY = (float) ((targetPosition.y() - position.y()) * 0.6);
float velZ = (float) ((targetPosition.z() - position.z()) * 0.6);
ICBMClassic.proxy.spawnParticle("portal", world(), targetPosition, velX, velY, velZ, 5f, 1);
}
}
}
}
}
}
int radius = (int) this.getRadius();
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(position.x() - radius, position.y() - radius, position.z() - radius, position.x() + radius, position.y() + radius, position.z() + radius);
List<Entity> allEntities = world().getEntitiesWithinAABB(Entity.class, bounds);
boolean explosionCreated = false;
for (Entity entity : allEntities) {
if (entity != this.controller) {
double xDifference = entity.posX - position.x();
double yDifference = entity.posY - position.y();
double zDifference = entity.posZ - position.z();
int r = (int) this.getRadius();
if (xDifference < 0)
r = (int) -this.getRadius();
entity.motionX -= (r - xDifference) * Math.abs(xDifference) * 0.0006;
r = (int) this.getRadius();
if (entity.posY > position.y())
r = (int) -this.getRadius();
entity.motionY += (r - yDifference) * Math.abs(yDifference) * 0.0011;
r = (int) this.getRadius();
if (zDifference < 0)
r = (int) -this.getRadius();
entity.motionZ -= (r - zDifference) * Math.abs(zDifference) * 0.0006;
if (new Pos(entity.posX, entity.posY, entity.posZ).distance(position) < 4) {
if (!explosionCreated && callCount % 5 == 0) {
world().spawnParticle("hugeexplosion", entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
explosionCreated = true;
}
try {
/** If a target doesn't exist, search for a random one within 100 block
* range. */
if (this.teleportTarget == null) {
int checkY;
int checkX = this.world().rand.nextInt(300) - 150 + (int) this.controller.posX;
int checkZ = this.world().rand.nextInt(300) - 150 + (int) this.controller.posZ;
for (checkY = 63; !this.world().isAirBlock(checkX, checkY, checkZ) && !this.world().isAirBlock(checkX, checkY + 1, checkZ); ++checkY) {
;
}
this.teleportTarget = new Pos(checkX, checkY, checkZ);
}
this.world().playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F);
if (entity instanceof EntityPlayerMP) {
((EntityPlayerMP) entity).playerNetServerHandler.setPlayerLocation(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5, entity.rotationYaw, entity.rotationPitch);
} else {
entity.setPosition(this.teleportTarget.x() + 0.5, this.teleportTarget.y() + 0.5, this.teleportTarget.z() + 0.5);
}
} catch (Exception e) {
ICBMClassic.INSTANCE.logger().error("Failed to teleport entity to the End.", e);
}
}
}
}
this.world().playSound(this.position.x(), this.position.y(), this.position.z(), "portal.portal", 2F, world().rand.nextFloat() * 0.4F + 0.8F, false);
if (this.callCount > this.duration) {
this.controller.endExplosion();
}
}
use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.
the class DumpNBT method processCommand.
@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
EntityPlayerMP player = getCommandSenderAsPlayer(icommandsender);
if (player.getCurrentEquippedItem() == null) {
player.addChatMessage(new ChatComponentText("This command dumps the NBT of your current equipped item...see the problem here?"));
return;
}
if (!player.getCurrentEquippedItem().hasTagCompound()) {
player.addChatMessage(new ChatComponentText("No NBT exists on this item."));
return;
}
AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP) player, AMPacketIDs.NBT_DUMP, new byte[0]);
}
use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.
the class GiveSkillPoints method processCommand.
@Override
public void processCommand(ICommandSender var1, String[] var2) {
if (var2.length != 4 && var2.length != 3) {
throw new WrongUsageException(this.getCommandUsage(var1), new Object[0]);
}
EntityPlayer player = null;
int target_blue = parseIntBounded(var1, var2[0], 0, 50);
int target_green = parseIntBounded(var1, var2[1], 0, 50);
int target_red = parseIntBounded(var1, var2[2], 0, 50);
if (var2.length == 4) {
if (var2[3].equals("@a")) {
EntityPlayerMP[] players = PlayerSelector.matchPlayers(var1, var2[3]);
if (players != null) {
for (EntityPlayerMP p : players) {
doGiveSkillPoints(var1, p, target_blue, target_green, target_red);
}
}
} else {
player = getPlayer(var1, var2[3]);
}
} else {
player = getCommandSenderAsPlayer(var1);
}
doGiveSkillPoints(var1, player, target_blue, target_green, target_red);
}
use of net.minecraft.entity.player.EntityPlayerMP in project ArsMagica2 by Mithion.
the class SpellHelper method applyStageToEntity.
public SpellCastResult applyStageToEntity(ItemStack stack, EntityLivingBase caster, World world, Entity target, int stage, boolean shiftAffinityAndXP) {
ISpellShape stageShape = SpellUtils.instance.getShapeForStage(stack, 0);
if (stageShape == null)
return SpellCastResult.MALFORMED_SPELL_STACK;
if ((!AMCore.config.getAllowCreativeTargets()) && target instanceof EntityPlayerMP && ((EntityPlayerMP) target).capabilities.isCreativeMode) {
return SpellCastResult.EFFECT_FAILED;
}
ISpellComponent[] components = SpellUtils.instance.getComponentsForStage(stack, 0);
boolean appliedOneComponent = false;
for (ISpellComponent component : components) {
if (SkillTreeManager.instance.isSkillDisabled(component))
continue;
if (component.applyEffectEntity(stack, world, caster, target)) {
appliedOneComponent = true;
if (world.isRemote) {
int color = -1;
if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, stack, 0)) {
ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(stack, 0);
int ordinalCount = 0;
for (ISpellModifier mod : mods) {
if (mod instanceof Colour) {
byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(stack, mod, 0, ordinalCount++);
color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
}
}
}
component.spawnParticles(world, target.posX, target.posY + target.getEyeHeight(), target.posZ, caster, target, world.rand, color);
}
if (shiftAffinityAndXP)
SpellUtils.instance.doAffinityShift(caster, component, stageShape);
}
}
if (appliedOneComponent)
return SpellCastResult.SUCCESS;
else
return SpellCastResult.EFFECT_FAILED;
}
Aggregations