From acc32082810a25cde7d43049212c96a0a1cc52a6 Mon Sep 17 00:00:00 2001 From: Moresteck Date: Sat, 6 Jan 2024 01:27:41 +0100 Subject: [PATCH] Fix a1.1.2_01 compat code --- .../minecraft/server/Packet24MobSpawn.java | 12 ++-- .../server/Packet28EntityVelocity.java | 70 ++++++++++--------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/src/main/java/net/minecraft/server/Packet24MobSpawn.java b/src/main/java/net/minecraft/server/Packet24MobSpawn.java index 23a364cf..cf610995 100644 --- a/src/main/java/net/minecraft/server/Packet24MobSpawn.java +++ b/src/main/java/net/minecraft/server/Packet24MobSpawn.java @@ -23,10 +23,6 @@ public Packet24MobSpawn() { public Packet24MobSpawn(EntityLiving entityliving) { this.a = entityliving.id; this.b = (byte) EntityTypes.a(entityliving); - // uberbukkit - a1.1.2_01 doesn't recognize cows and sheep - if (this.pvn <= 2 && (this.b == 92 || this.b == 93)) - this.b = 91; - this.c = MathHelper.floor(entityliving.locX * 32.0D); this.d = MathHelper.floor(entityliving.locY * 32.0D); this.e = MathHelper.floor(entityliving.locZ * 32.0D); @@ -53,7 +49,13 @@ public void a(DataInputStream datainputstream) throws IOException { public void a(DataOutputStream dataoutputstream) throws IOException { dataoutputstream.writeInt(this.a); - dataoutputstream.writeByte(this.b); + + byte entityType = this.b; + // uberbukkit - a1.1.2_01 doesn't recognize cows and sheep + if (this.pvn <= 2 && (this.b == 92 || this.b == 93)) + entityType = 91; + + dataoutputstream.writeByte(entityType); dataoutputstream.writeInt(this.c); dataoutputstream.writeInt(this.d); dataoutputstream.writeInt(this.e); diff --git a/src/main/java/net/minecraft/server/Packet28EntityVelocity.java b/src/main/java/net/minecraft/server/Packet28EntityVelocity.java index d01f4356..037102fd 100644 --- a/src/main/java/net/minecraft/server/Packet28EntityVelocity.java +++ b/src/main/java/net/minecraft/server/Packet28EntityVelocity.java @@ -7,9 +7,9 @@ public class Packet28EntityVelocity extends Packet { public int a; - public int b; - public int c; - public int d; + public double b; + public double c; + public double d; public Packet28EntityVelocity() { } @@ -20,60 +20,62 @@ public Packet28EntityVelocity(Entity entity) { public Packet28EntityVelocity(int i, double d0, double d1, double d2) { this.a = i; + // uberbukkit - values are calculated on sending to achieve compatibility + // TODO: test impact on performance? + this.b = d0; + this.c = d1; + this.d = d2; + } + + public void a(DataInputStream datainputstream) throws IOException { + this.a = datainputstream.readInt(); + this.b = datainputstream.readShort(); + this.c = datainputstream.readShort(); + this.d = datainputstream.readShort(); + } + + public void a(DataOutputStream dataoutputstream) throws IOException { + dataoutputstream.writeInt(this.a); + + // uberbukkit start double d3 = 3.9D; - // uberbukkit if (this.pvn <= 5) d3 = 0.9D; - if (d0 < -d3) { - d0 = -d3; + if (this.b < -d3) { + this.b = -d3; } - if (d1 < -d3) { - d1 = -d3; + if (this.c < -d3) { + this.c = -d3; } - if (d2 < -d3) { - d2 = -d3; + if (this.d < -d3) { + this.d = -d3; } - if (d0 > d3) { - d0 = d3; + if (this.b > d3) { + this.b = d3; } - if (d1 > d3) { - d1 = d3; + if (this.c > d3) { + this.c = d3; } - if (d2 > d3) { - d2 = d3; + if (this.d > d3) { + this.d = d3; } - // uberbukkit start double multiplier = 8000.0D; if (this.pvn <= 5) multiplier = 32000.0D; - this.b = (int) (d0 * multiplier); - this.c = (int) (d1 * multiplier); - this.d = (int) (d2 * multiplier); + dataoutputstream.writeShort((int) (this.b * multiplier)); + dataoutputstream.writeShort((int) (this.c * multiplier)); + dataoutputstream.writeShort((int) (this.d * multiplier)); // uberbukkit end } - public void a(DataInputStream datainputstream) throws IOException { - this.a = datainputstream.readInt(); - this.b = datainputstream.readShort(); - this.c = datainputstream.readShort(); - this.d = datainputstream.readShort(); - } - - public void a(DataOutputStream dataoutputstream) throws IOException { - dataoutputstream.writeInt(this.a); - dataoutputstream.writeShort(this.b); - dataoutputstream.writeShort(this.c); - dataoutputstream.writeShort(this.d); - } - public void a(NetHandler nethandler) { nethandler.a(this); }