Skip to content

Commit

Permalink
Fix a1.1.2_01 compat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Moresteck committed Jan 6, 2024
1 parent 011f498 commit acc3208
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
12 changes: 7 additions & 5 deletions src/main/java/net/minecraft/server/Packet24MobSpawn.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
70 changes: 36 additions & 34 deletions src/main/java/net/minecraft/server/Packet28EntityVelocity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
}
Expand All @@ -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);
}
Expand Down

0 comments on commit acc3208

Please sign in to comment.