mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 14:33:56 +01:00
176 lines
7.8 KiB
Diff
176 lines
7.8 KiB
Diff
--- a/net/minecraft/server/EntityTrackerEntry.java
|
|
+++ b/net/minecraft/server/EntityTrackerEntry.java
|
|
@@ -9,6 +9,11 @@
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.player.PlayerVelocityEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class EntityTrackerEntry {
|
|
|
|
private static final Logger c = LogManager.getLogger();
|
|
@@ -79,13 +84,14 @@
|
|
this.broadcast(new PacketPlayOutMount(this.tracker));
|
|
}
|
|
|
|
- if (this.tracker instanceof EntityItemFrame && this.a % 10 == 0) {
|
|
+ // PAIL : rename
|
|
+ if (this.tracker instanceof EntityItemFrame /*&& this.a % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
|
|
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
|
|
ItemStack itemstack = entityitemframe.getItem();
|
|
|
|
- if (itemstack != null && itemstack.getItem() instanceof ItemWorldMap) {
|
|
+ if (this.a % 10 == 0 && itemstack != null && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks
|
|
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, this.tracker.world);
|
|
- Iterator iterator = list.iterator();
|
|
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
|
|
|
|
while (iterator.hasNext()) {
|
|
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
|
@@ -120,6 +126,19 @@
|
|
boolean flag = k1 * k1 + l1 * l1 + i2 * i2 >= 128L || this.a % 60 == 0;
|
|
boolean flag1 = Math.abs(i1 - this.yRot) >= 1 || Math.abs(j1 - this.xRot) >= 1;
|
|
|
|
+ // CraftBukkit start - Code moved from below
|
|
+ if (flag) {
|
|
+ this.xLoc = j;
|
|
+ this.yLoc = k;
|
|
+ this.zLoc = l;
|
|
+ }
|
|
+
|
|
+ if (flag1) {
|
|
+ this.yRot = i1;
|
|
+ this.xRot = j1;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
if (this.a > 0 || this.tracker instanceof EntityArrow) {
|
|
if (k1 >= -32768L && k1 < 32768L && l1 >= -32768L && l1 < 32768L && i2 >= -32768L && i2 < 32768L && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
|
|
if ((!flag || !flag1) && !(this.tracker instanceof EntityArrow)) {
|
|
@@ -134,6 +153,11 @@
|
|
} else {
|
|
this.y = this.tracker.onGround;
|
|
this.v = 0;
|
|
+ // CraftBukkit start - Refresh list of who can see a player before sending teleport packet
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ this.scanPlayers(new java.util.ArrayList(this.trackedPlayers));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.c();
|
|
object = new PacketPlayOutEntityTeleport(this.tracker);
|
|
}
|
|
@@ -165,6 +189,7 @@
|
|
}
|
|
|
|
this.d();
|
|
+ /* CraftBukkit start - Code moved up
|
|
if (flag) {
|
|
this.xLoc = j;
|
|
this.yLoc = k;
|
|
@@ -175,6 +200,7 @@
|
|
this.yRot = i1;
|
|
this.xRot = j1;
|
|
}
|
|
+ // CraftBukkit end */
|
|
|
|
this.x = false;
|
|
} else {
|
|
@@ -206,7 +232,27 @@
|
|
|
|
++this.a;
|
|
if (this.tracker.velocityChanged) {
|
|
- this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
|
+ // CraftBukkit start - Create PlayerVelocity event
|
|
+ boolean cancelled = false;
|
|
+
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ Player player = (Player) this.tracker.getBukkitEntity();
|
|
+ org.bukkit.util.Vector velocity = player.getVelocity();
|
|
+
|
|
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
|
|
+ this.tracker.world.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (event.isCancelled()) {
|
|
+ cancelled = true;
|
|
+ } else if (!velocity.equals(event.getVelocity())) {
|
|
+ player.setVelocity(event.getVelocity());
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!cancelled) {
|
|
+ this.broadcastIncludingSelf(new PacketPlayOutEntityVelocity(this.tracker));
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.tracker.velocityChanged = false;
|
|
}
|
|
|
|
@@ -224,6 +270,11 @@
|
|
Set set = attributemapserver.getAttributes();
|
|
|
|
if (!set.isEmpty()) {
|
|
+ // CraftBukkit start - Send scaled max health
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(set, false);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.broadcastIncludingSelf(new PacketPlayOutUpdateAttributes(this.tracker.getId(), set));
|
|
}
|
|
|
|
@@ -276,6 +327,16 @@
|
|
if (entityplayer != this.tracker) {
|
|
if (this.c(entityplayer)) {
|
|
if (!this.trackedPlayers.contains(entityplayer) && (this.e(entityplayer) || this.tracker.attachedToPlayer)) {
|
|
+ // CraftBukkit start - respect vanish API
|
|
+ if (this.tracker instanceof EntityPlayer) {
|
|
+ Player player = ((EntityPlayer) this.tracker).getBukkitEntity();
|
|
+ if (!entityplayer.getBukkitEntity().canSee(player)) {
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ entityplayer.removeQueue.remove(Integer.valueOf(this.tracker.getId()));
|
|
+ // CraftBukkit end
|
|
this.trackedPlayers.add(entityplayer);
|
|
Packet packet = this.e();
|
|
|
|
@@ -290,6 +351,12 @@
|
|
AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap();
|
|
Collection collection = attributemapserver.c();
|
|
|
|
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
|
|
+ if (this.tracker.getId() == entityplayer.getId()) {
|
|
+ ((EntityPlayer) this.tracker).getBukkitEntity().injectScaledMaxHealth(collection, false);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
if (!collection.isEmpty()) {
|
|
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection));
|
|
}
|
|
@@ -328,6 +395,11 @@
|
|
}
|
|
}
|
|
|
|
+ // CraftBukkit start - Fix for nonsensical head yaw
|
|
+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
|
|
+ this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw));
|
|
+ // CraftBukkit end
|
|
+
|
|
if (this.tracker instanceof EntityLiving) {
|
|
EntityLiving entityliving = (EntityLiving) this.tracker;
|
|
Iterator iterator = entityliving.getEffects().iterator();
|
|
@@ -372,7 +444,10 @@
|
|
|
|
private Packet<?> e() {
|
|
if (this.tracker.dead) {
|
|
- EntityTrackerEntry.c.warn("Fetching addPacket for removed entity");
|
|
+ // CraftBukkit start - Remove useless error spam, just return
|
|
+ // EntityTrackerEntry.d.warn("Fetching addPacket for removed entity");
|
|
+ return null;
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
if (this.tracker instanceof EntityItem) {
|