use of org.bukkit.craftbukkit.v1_18_R2.entity in project Citizens2 by CitizensDev.
the class PlayerlistTrackerEntry method updatePlayer.
@Override
public void updatePlayer(final EntityPlayer entityplayer) {
// prevent updates to NPC "viewers"
if (entityplayer instanceof EntityHumanNPC)
return;
Entity tracker = getTracker(this);
if (entityplayer != tracker && c(entityplayer)) {
if (!this.trackedPlayers.contains(entityplayer) && ((entityplayer.u().getPlayerChunkMap().a(entityplayer, tracker.ae, tracker.ag)) || (tracker.attachedToPlayer))) {
if ((tracker instanceof SkinnableEntity)) {
SkinnableEntity skinnable = (SkinnableEntity) tracker;
Player player = skinnable.getBukkitEntity();
if (!entityplayer.getBukkitEntity().canSee(player))
return;
skinnable.getSkinTracker().updateViewer(entityplayer.getBukkitEntity());
}
}
}
super.updatePlayer(entityplayer);
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project Village_Defense by Plajer.
the class RidableIronGolem method g.
@Override
public void g(float f, float f1) {
EntityLiving entityliving = (EntityLiving) bw();
if (entityliving == null) {
// search first human passenger
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.l((float) 0.12);
super.g(f, f1);
return;
}
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aQ = this.aO = this.yaw;
f = entityliving.be * 0.75F;
f1 = entityliving.bf;
if (f1 <= 0.0f) {
f1 *= 0.25F;
}
this.l((float) 0.12);
super.g(f, f1);
P = (float) 1.0;
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project Village_Defense by Plajer.
the class RidableIronGolem method a.
public void a(float f, float f1, float f2) {
EntityLiving entityliving = null;
for (final Entity e : passengers) {
if (e instanceof EntityHuman) {
entityliving = (EntityLiving) e;
break;
}
}
if (entityliving == null) {
this.P = 0.5F;
this.aR = 0.02F;
this.k((float) 0.12);
super.a(f, f1, f2);
return;
}
this.lastYaw = this.yaw = entityliving.yaw;
this.pitch = entityliving.pitch * 0.5F;
this.setYawPitch(this.yaw, this.pitch);
this.aO = this.aM = this.yaw;
f = entityliving.be * 0.5F * 0.75F;
f2 = entityliving.bg;
if (f2 <= 0.0f) {
f2 *= 0.25F;
}
k(0.12f);
super.a(f, f1, f2);
P = (float) 1.0;
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.
the class CompatibilityUtils method spawnFireworkEffect.
@Override
public Entity spawnFireworkEffect(Material fireworkMaterial, Server server, Location location, FireworkEffect effect, int power, Vector direction, Integer expectedLifespan, Integer ticksFlown, boolean silent) {
Entity entity = null;
try {
if (fireworkMaterial == null) {
return null;
}
ServerLevel level = ((CraftWorld) location.getWorld()).getHandle();
ItemStack itemStack = new ItemStack(fireworkMaterial);
FireworkMeta meta = (FireworkMeta) itemStack.getItemMeta();
meta.addEffect(effect);
meta.setPower(power);
itemStack.setItemMeta(meta);
Object item = platform.getItemUtils().getHandle(platform.getItemUtils().makeReal(itemStack));
final FireworkRocketEntity fireworkHandle = new FireworkRocketEntity(level, location.getX(), location.getY(), location.getZ(), (net.minecraft.world.item.ItemStack) item);
fireworkHandle.setSilent(silent);
if (direction != null) {
fireworkHandle.setDeltaMovement(new Vec3(direction.getX(), direction.getY(), direction.getZ()));
}
if (ticksFlown != null) {
ReflectionUtils.setPrivateNeedsFixing(platform.getLogger(), fireworkHandle, FireworkRocketEntity.class, "life", "e", ticksFlown);
}
if (expectedLifespan != null) {
fireworkHandle.lifetime = expectedLifespan;
}
if (direction == null) {
ClientboundAddEntityPacket fireworkPacket = new ClientboundAddEntityPacket(fireworkHandle, CompatibilityConstants.FIREWORK_TYPE);
int fireworkId = fireworkHandle.getId();
SynchedEntityData watcher = fireworkHandle.getEntityData();
ClientboundSetEntityDataPacket metadataPacket = new ClientboundSetEntityDataPacket(fireworkId, watcher, true);
ClientboundEntityEventPacket statusPacket = new ClientboundEntityEventPacket(fireworkHandle, (byte) 17);
ClientboundRemoveEntitiesPacket destroyPacket = new ClientboundRemoveEntitiesPacket(fireworkId);
Collection<? extends Player> players = server.getOnlinePlayers();
sendPacket(server, location, players, fireworkPacket);
sendPacket(server, location, players, metadataPacket);
sendPacket(server, location, players, statusPacket);
sendPacket(server, location, players, destroyPacket);
return null;
}
level.addFreshEntity(fireworkHandle, CreatureSpawnEvent.SpawnReason.CUSTOM);
entity = fireworkHandle.getBukkitEntity();
} catch (Exception ex) {
ex.printStackTrace();
}
return entity;
}
use of org.bukkit.craftbukkit.v1_18_R2.entity in project MagicPlugin by elBukkit.
the class CompatibilityUtils method addToWorld.
@Override
public boolean addToWorld(World world, Entity entity, CreatureSpawnEvent.SpawnReason reason) {
ServerLevel level = ((CraftWorld) world).getHandle();
net.minecraft.world.entity.Entity entityHandle = ((CraftEntity) entity).getHandle();
level.addFreshEntity(entityHandle, reason);
return true;
}
Aggregations