Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/EntityTrackerEntry.patch

180 Zeilen
8.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/EntityTrackerEntry.java
+++ b/net/minecraft/server/EntityTrackerEntry.java
2016-02-29 22:32:46 +01:00
@@ -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 {
2016-02-29 22:32:46 +01:00
private static final Logger c = LogManager.getLogger();
@@ -76,16 +81,17 @@
if (!list1.equals(this.w)) {
this.w = list1;
- this.broadcast(new PacketPlayOutMount(this.tracker));
+ this.broadcastIncludingSelf(new PacketPlayOutMount(this.tracker)); // CraftBukkit
}
2016-02-29 22:32:46 +01:00
- 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();
2016-11-17 02:41:03 +01:00
- if (itemstack.getItem() instanceof ItemWorldMap) {
+ if (this.a % 10 == 0 && itemstack.getItem() instanceof ItemWorldMap) { // CraftBukkit - Moved this.a % 10 logic here so item frames do not enter the other blocks
2018-07-15 02:00:00 +02:00
WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.tracker.world);
- Iterator iterator = list.iterator();
+ Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
2016-06-09 03:43:49 +02:00
@@ -136,6 +142,19 @@
boolean flag1 = l1 * l1 + i2 * i2 + j2 * j2 >= 128L || this.a % 60 == 0;
boolean flag2 = Math.abs(j1 - this.yRot) >= 1 || Math.abs(k1 - this.xRot) >= 1;
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - Code moved from below
2016-06-09 03:43:49 +02:00
+ if (flag1) {
+ this.xLoc = k;
+ this.yLoc = l;
+ this.zLoc = i1;
+ }
+
2016-06-09 03:43:49 +02:00
+ if (flag2) {
+ this.yRot = j1;
+ this.xRot = k1;
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
2016-02-29 22:32:46 +01:00
if (this.a > 0 || this.tracker instanceof EntityArrow) {
2016-06-09 03:43:49 +02:00
if (l1 >= -32768L && l1 < 32768L && i2 >= -32768L && i2 < 32768L && j2 >= -32768L && j2 < 32768L && this.v <= 400 && !this.x && this.y == this.tracker.onGround) {
if ((!flag1 || !flag2) && !(this.tracker instanceof EntityArrow)) {
@@ -150,6 +169,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
2016-02-29 22:32:46 +01:00
this.c();
object = new PacketPlayOutEntityTeleport(this.tracker);
}
2016-06-09 03:43:49 +02:00
@@ -181,6 +205,7 @@
}
2016-02-29 22:32:46 +01:00
this.d();
+ /* CraftBukkit start - Code moved up
2016-06-09 03:43:49 +02:00
if (flag1) {
this.xLoc = k;
this.yLoc = l;
@@ -191,6 +216,7 @@
this.yRot = j1;
this.xRot = k1;
}
+ // CraftBukkit end */
this.x = false;
2016-06-09 03:43:49 +02:00
}
2016-02-29 22:32:46 +01:00
@@ -206,7 +232,27 @@
2016-02-29 22:32:46 +01:00
++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;
}
2016-02-29 22:32:46 +01:00
@@ -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));
}
2016-02-29 22:32:46 +01:00
@@ -276,6 +327,16 @@
if (entityplayer != this.tracker) {
if (this.c(entityplayer)) {
2015-02-26 23:41:06 +01:00
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);
2016-02-29 22:32:46 +01:00
Packet packet = this.e();
2016-02-29 22:32:46 +01:00
@@ -290,6 +351,12 @@
AttributeMapServer attributemapserver = (AttributeMapServer) ((EntityLiving) this.tracker).getAttributeMap();
Collection collection = attributemapserver.c();
2015-02-26 23:41:06 +01:00
+ // 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
2015-02-26 23:41:06 +01:00
+
if (!collection.isEmpty()) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(this.tracker.getId(), collection));
2015-02-26 23:41:06 +01:00
}
2016-02-29 22:32:46 +01:00
@@ -328,6 +395,11 @@
}
}
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - Fix for nonsensical head yaw
2016-02-29 22:32:46 +01:00
+ this.headYaw = MathHelper.d(this.tracker.getHeadRotation() * 256.0F / 360.0F);
+ this.broadcast(new PacketPlayOutEntityHeadRotation(this.tracker, (byte) headYaw));
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
if (this.tracker instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) this.tracker;
2015-02-26 23:41:06 +01:00
Iterator iterator = entityliving.getEffects().iterator();
2016-11-17 02:41:03 +01:00
@@ -380,7 +452,10 @@
2016-02-29 22:32:46 +01:00
private Packet<?> e() {
if (this.tracker.dead) {
2016-02-29 22:32:46 +01:00
- EntityTrackerEntry.c.warn("Fetching addPacket for removed entity");
+ // CraftBukkit start - Remove useless error spam, just return
2016-02-29 22:32:46 +01:00
+ // EntityTrackerEntry.d.warn("Fetching addPacket for removed entity");
+ return null;
+ // CraftBukkit end
}
2016-11-17 02:41:03 +01:00
if (this.tracker instanceof EntityPlayer) {