proper angle calculation (yaw/pitch/(roll))

This commit is contained in:
bixilon 2020-06-16 14:37:42 +02:00
parent 423e48a57a
commit 5b424574ac
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
63 changed files with 115 additions and 119 deletions

View File

@ -27,11 +27,11 @@ public abstract class Entity implements EntityInterface {
final List<StatusEffect> effectList; final List<StatusEffect> effectList;
Location location; Location location;
Velocity velocity; Velocity velocity;
int yaw; short yaw;
int pitch; short pitch;
int headYaw; short headYaw;
public Entity(int id, Location location, int yaw, int pitch, Velocity velocity) { public Entity(int id, Location location, short yaw, short pitch, Velocity velocity) {
this.id = id; this.id = id;
this.location = location; this.location = location;
this.yaw = yaw; this.yaw = yaw;
@ -41,6 +41,16 @@ public abstract class Entity implements EntityInterface {
this.effectList = new ArrayList<>(); this.effectList = new ArrayList<>();
} }
public Entity(int id, Location location, int yaw, int pitch, Velocity velocity) {
this.id = id;
this.location = location;
this.yaw = (short) yaw;
this.pitch = (short) pitch;
this.velocity = velocity;
this.equipment = new HashMap<>();
this.effectList = new ArrayList<>();
}
public int getId() { public int getId() {
return id; return id;
@ -68,20 +78,20 @@ public abstract class Entity implements EntityInterface {
this.velocity = velocity; this.velocity = velocity;
} }
public int getYaw() { public short getYaw() {
return 0; return 0;
} }
public void setYaw(int yaw) { public void setYaw(short yaw) {
this.yaw = yaw; this.yaw = yaw;
} }
public int getPitch() { public short getPitch() {
return 0; return 0;
} }
public void setPitch(int pitch) { public void setPitch(short pitch) {
this.pitch = pitch; this.pitch = pitch;
} }
@ -95,11 +105,11 @@ public abstract class Entity implements EntityInterface {
} }
public int getHeadYaw() { public short getHeadYaw() {
return headYaw; return headYaw;
} }
public void setHeadYaw(int headYaw) { public void setHeadYaw(short headYaw) {
this.headYaw = headYaw; this.headYaw = headYaw;
} }

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.game.datatypes.entities;
public abstract class EntityObject extends Entity implements ObjectInterface { public abstract class EntityObject extends Entity implements ObjectInterface {
public EntityObject(int id, Location location, int yaw, int pitch, Velocity velocity) { public EntityObject(int id, Location location, short yaw, short pitch, Velocity velocity) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
} }

View File

@ -17,7 +17,7 @@ import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.game.datatypes.entities.meta.MobMetaData; import de.bixilon.minosoft.game.datatypes.entities.meta.MobMetaData;
public abstract class Mob extends Entity implements MobInterface { public abstract class Mob extends Entity implements MobInterface {
public Mob(int id, Location location, int yaw, int pitch, Velocity velocity) { public Mob(int id, Location location, short yaw, short pitch, Velocity velocity) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Bat extends Mob implements MobInterface { public class Bat extends Mob implements MobInterface {
BatMetaData metaData; BatMetaData metaData;
public Bat(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Bat(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new BatMetaData(buffer, v); this.metaData = new BatMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Blaze extends Mob implements MobInterface { public class Blaze extends Mob implements MobInterface {
BlazeMetaData metaData; BlazeMetaData metaData;
public Blaze(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Blaze(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new BlazeMetaData(buffer, v); this.metaData = new BlazeMetaData(buffer, v);
} }

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class CaveSpider extends Spider { public class CaveSpider extends Spider {
public CaveSpider(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public CaveSpider(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity, buffer, v); super(id, location, yaw, pitch, velocity, buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Chicken extends Mob implements MobInterface { public class Chicken extends Mob implements MobInterface {
AgeableMetaData metaData; AgeableMetaData metaData;
public Chicken(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Chicken(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new AgeableMetaData(buffer, v); this.metaData = new AgeableMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Cow extends Mob implements MobInterface { public class Cow extends Mob implements MobInterface {
AgeableMetaData metaData; AgeableMetaData metaData;
public Cow(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Cow(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new AgeableMetaData(buffer, v); this.metaData = new AgeableMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Creeper extends Mob implements MobInterface { public class Creeper extends Mob implements MobInterface {
CreeperMetaData metaData; CreeperMetaData metaData;
public Creeper(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Creeper(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new CreeperMetaData(buffer, v); this.metaData = new CreeperMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EnderDragon extends Mob implements MobInterface { public class EnderDragon extends Mob implements MobInterface {
MobMetaData metaData; MobMetaData metaData;
public EnderDragon(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public EnderDragon(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new MobMetaData(buffer, v); this.metaData = new MobMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EnderMan extends Mob implements MobInterface { public class EnderMan extends Mob implements MobInterface {
EndermanMetaData metaData; EndermanMetaData metaData;
public EnderMan(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public EnderMan(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new EndermanMetaData(buffer, v); this.metaData = new EndermanMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Ghast extends Mob implements MobInterface { public class Ghast extends Mob implements MobInterface {
GhastMetaData metaData; GhastMetaData metaData;
public Ghast(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Ghast(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new GhastMetaData(buffer, v); this.metaData = new GhastMetaData(buffer, v);
} }

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class GiantZombie extends Zombie { public class GiantZombie extends Zombie {
public GiantZombie(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public GiantZombie(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity, buffer, v); super(id, location, yaw, pitch, velocity, buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Horse extends Mob implements MobInterface { public class Horse extends Mob implements MobInterface {
HorseMetaData metaData; HorseMetaData metaData;
public Horse(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Horse(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new HorseMetaData(buffer, v); this.metaData = new HorseMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class IronGolem extends Mob implements MobInterface { public class IronGolem extends Mob implements MobInterface {
MobMetaData metaData; MobMetaData metaData;
public IronGolem(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public IronGolem(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new MobMetaData(buffer, v); this.metaData = new MobMetaData(buffer, v);
} }

View File

@ -21,7 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class MagmaCube extends Slime { public class MagmaCube extends Slime {
public MagmaCube(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public MagmaCube(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity, buffer, v); super(id, location, yaw, pitch, velocity, buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Mooshroom extends Mob implements MobInterface { public class Mooshroom extends Mob implements MobInterface {
AgeableMetaData metaData; AgeableMetaData metaData;
public Mooshroom(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Mooshroom(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new AgeableMetaData(buffer, v); this.metaData = new AgeableMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Ocelot extends Mob implements MobInterface { public class Ocelot extends Mob implements MobInterface {
OcelotMetaData metaData; OcelotMetaData metaData;
public Ocelot(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Ocelot(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new OcelotMetaData(buffer, v); this.metaData = new OcelotMetaData(buffer, v);
} }

View File

@ -29,7 +29,7 @@ public class OtherPlayer extends Mob implements MobInterface {
HumanMetaData metaData; HumanMetaData metaData;
Pose status = Pose.STANDING; Pose status = Pose.STANDING;
public OtherPlayer(int id, String name, UUID uuid, PlayerPropertyData[] properties, Location location, Velocity velocity, int yaw, int pitch, short currentItem, HumanMetaData metaData) { public OtherPlayer(int id, String name, UUID uuid, PlayerPropertyData[] properties, Location location, Velocity velocity, short yaw, short pitch, short currentItem, HumanMetaData metaData) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.name = name; this.name = name;
this.uuid = uuid; this.uuid = uuid;

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Pig extends Mob implements MobInterface { public class Pig extends Mob implements MobInterface {
PigMetaData metaData; PigMetaData metaData;
public Pig(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Pig(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new PigMetaData(buffer, v); this.metaData = new PigMetaData(buffer, v);
} }

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Sheep extends Mob implements MobInterface { public class Sheep extends Mob implements MobInterface {
SheepMetaData metaData; SheepMetaData metaData;
public Sheep(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Sheep(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new SheepMetaData(buffer, v); this.metaData = new SheepMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Silverfish extends Mob implements MobInterface { public class Silverfish extends Mob implements MobInterface {
MobMetaData metaData; MobMetaData metaData;
public Silverfish(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Silverfish(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new MobMetaData(buffer, v); this.metaData = new MobMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Skeleton extends Mob implements MobInterface { public class Skeleton extends Mob implements MobInterface {
SkeletonMetaData metaData; SkeletonMetaData metaData;
public Skeleton(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Skeleton(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new SkeletonMetaData(buffer, v); this.metaData = new SkeletonMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Slime extends Mob implements MobInterface { public class Slime extends Mob implements MobInterface {
SlimeMetaData metaData; SlimeMetaData metaData;
public Slime(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Slime(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new SlimeMetaData(buffer, v); this.metaData = new SlimeMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class SnowGolem extends Mob implements MobInterface { public class SnowGolem extends Mob implements MobInterface {
MobMetaData metaData; MobMetaData metaData;
public SnowGolem(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public SnowGolem(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new MobMetaData(buffer, v); this.metaData = new MobMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Spider extends Mob implements MobInterface { public class Spider extends Mob implements MobInterface {
SpiderMetaData metaData; SpiderMetaData metaData;
public Spider(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Spider(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new SpiderMetaData(buffer, v); this.metaData = new SpiderMetaData(buffer, v);
} }

View File

@ -23,7 +23,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Squid extends Mob implements MobInterface { public class Squid extends Mob implements MobInterface {
AgeableMetaData metaData; AgeableMetaData metaData;
public Squid(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Squid(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new AgeableMetaData(buffer, v); this.metaData = new AgeableMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Villager extends Mob implements MobInterface { public class Villager extends Mob implements MobInterface {
VillagerMetaData metaData; VillagerMetaData metaData;
public Villager(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Villager(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new VillagerMetaData(buffer, v); this.metaData = new VillagerMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Witch extends Mob implements MobInterface { public class Witch extends Mob implements MobInterface {
WitchMetaData metaData; WitchMetaData metaData;
public Witch(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Witch(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new WitchMetaData(buffer, v); this.metaData = new WitchMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Wither extends Mob implements MobInterface { public class Wither extends Mob implements MobInterface {
WitherMetaData metaData; WitherMetaData metaData;
public Wither(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Wither(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new WitherMetaData(buffer, v); this.metaData = new WitherMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Wolf extends Mob implements MobInterface { public class Wolf extends Mob implements MobInterface {
WolfMetaData metaData; WolfMetaData metaData;
public Wolf(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Wolf(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new WolfMetaData(buffer, v); this.metaData = new WolfMetaData(buffer, v);
} }

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Zombie extends Mob implements MobInterface { public class Zombie extends Mob implements MobInterface {
ZombieMetaData metaData; ZombieMetaData metaData;
public Zombie(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public Zombie(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity); super(id, location, yaw, pitch, velocity);
this.metaData = new ZombieMetaData(buffer, v); this.metaData = new ZombieMetaData(buffer, v);
} }

View File

@ -21,7 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class ZombiePigman extends Zombie { public class ZombiePigman extends Zombie {
public ZombiePigman(int id, Location location, int yaw, int pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) { public ZombiePigman(int id, Location location, short yaw, short pitch, Velocity velocity, InByteBuffer buffer, ProtocolVersion v) {
super(id, location, yaw, pitch, velocity, buffer, v); super(id, location, yaw, pitch, velocity, buffer, v);
} }

View File

@ -25,10 +25,9 @@ public class Arrow extends EntityObject implements ObjectInterface {
ArrowMetaData metaData; ArrowMetaData metaData;
int shooter; int shooter;
public Arrow(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Arrow(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.shooter = additionalInt; this.shooter = additionalInt;
} }

View File

@ -24,7 +24,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Boat extends EntityObject implements ObjectInterface { public class Boat extends EntityObject implements ObjectInterface {
BoatMetaData metaData; BoatMetaData metaData;
public Boat(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Boat(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// boat does not have any additional info // boat does not have any additional info

View File

@ -24,10 +24,9 @@ public class Egg extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int thrower; int thrower;
public Egg(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Egg(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt; this.thrower = additionalInt;
} }

View File

@ -24,10 +24,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EnderCrystal extends EntityObject implements ObjectInterface { public class EnderCrystal extends EntityObject implements ObjectInterface {
EnderCrystalMetaData metaData; EnderCrystalMetaData metaData;
public EnderCrystal(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public EnderCrystal(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Enderpearl extends EntityObject implements ObjectInterface { public class Enderpearl extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public Enderpearl(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Enderpearl(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class EyeOfEnder extends EntityObject implements ObjectInterface { public class EyeOfEnder extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public EyeOfEnder(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public EyeOfEnder(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -25,10 +25,9 @@ public class FallingBlock extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
Blocks block; Blocks block;
public FallingBlock(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FallingBlock(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12); block = Blocks.byLegacy(additionalInt & 0xFFF, additionalInt >> 12);
} }

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class FallingDragonEgg extends EntityObject implements ObjectInterface { public class FallingDragonEgg extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public FallingDragonEgg(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FallingDragonEgg(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -24,10 +24,9 @@ public class FireBall extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int thrower; int thrower;
public FireBall(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FireBall(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt; this.thrower = additionalInt;
} }

View File

@ -24,10 +24,9 @@ public class FireCharge extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int thrower; int thrower;
public FireCharge(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FireCharge(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt; this.thrower = additionalInt;
} }

View File

@ -24,10 +24,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class Firework extends EntityObject implements ObjectInterface { public class Firework extends EntityObject implements ObjectInterface {
FireworkMetaData metaData; FireworkMetaData metaData;
public Firework(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Firework(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -24,10 +24,9 @@ public class FishingFloat extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int owner; int owner;
public FishingFloat(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public FishingFloat(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.owner = additionalInt; this.owner = additionalInt;
} }

View File

@ -25,10 +25,9 @@ public class ItemFrame extends EntityObject implements ObjectInterface {
ItemFrameMetaData metaData; ItemFrameMetaData metaData;
FrameDirection direction; FrameDirection direction;
public ItemFrame(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public ItemFrame(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
direction = FrameDirection.byId(additionalInt); direction = FrameDirection.byId(additionalInt);
} }

View File

@ -24,10 +24,10 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class ItemStack extends EntityObject implements ObjectInterface { public class ItemStack extends EntityObject implements ObjectInterface {
ItemMetaData metaData; ItemMetaData metaData;
public ItemStack(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public ItemStack(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class LeashKnot extends EntityObject implements ObjectInterface { public class LeashKnot extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public LeashKnot(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public LeashKnot(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -25,7 +25,7 @@ public class Minecart extends EntityObject implements ObjectInterface {
MinecartType type; MinecartType type;
MinecartMetaData metaData; MinecartMetaData metaData;
public Minecart(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Minecart(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
type = MinecartType.byType(additionalInt); type = MinecartType.byType(additionalInt);
} }

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PrimedTNT extends EntityObject implements ObjectInterface { public class PrimedTNT extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public PrimedTNT(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public PrimedTNT(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -24,10 +24,9 @@ public class Snowball extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int thrower; int thrower;
public Snowball(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public Snowball(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt; this.thrower = additionalInt;
} }

View File

@ -23,10 +23,9 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class ThrownExpBottle extends EntityObject implements ObjectInterface { public class ThrownExpBottle extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
public ThrownExpBottle(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public ThrownExpBottle(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
} }
@Override @Override

View File

@ -24,10 +24,9 @@ public class ThrownPotion extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int potion; //ToDo int potion; //ToDo
public ThrownPotion(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public ThrownPotion(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additsional info from the following int // objects do not spawn with metadata... reading additsional info from the following int
// tnt does not have any additional info
this.potion = additionalInt; this.potion = additionalInt;
} }

View File

@ -24,10 +24,9 @@ public class WitherSkull extends EntityObject implements ObjectInterface {
EntityMetaData metaData; EntityMetaData metaData;
int thrower; int thrower;
public WitherSkull(int id, Location location, int yaw, int pitch, int additionalInt, ProtocolVersion v) { public WitherSkull(int id, Location location, short yaw, short pitch, int additionalInt, ProtocolVersion v) {
super(id, location, yaw, pitch, null); super(id, location, yaw, pitch, null);
// objects do not spawn with metadata... reading additional info from the following int // objects do not spawn with metadata... reading additional info from the following int
// tnt does not have any additional info
this.thrower = additionalInt; this.thrower = additionalInt;
} }

View File

@ -22,14 +22,14 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketEntityHeadRotation implements ClientboundPacket { public class PacketEntityHeadRotation implements ClientboundPacket {
int entityId; int entityId;
int headYaw; short headYaw;
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.headYaw = buffer.readByte(); this.headYaw = buffer.readAngle();
break; break;
} }
} }
@ -44,7 +44,7 @@ public class PacketEntityHeadRotation implements ClientboundPacket {
} }
public int getHeadYaw() { public short getHeadYaw() {
return headYaw; return headYaw;
} }

View File

@ -24,8 +24,8 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketEntityPositionAndRotation implements ClientboundPacket { public class PacketEntityPositionAndRotation implements ClientboundPacket {
int entityId; int entityId;
RelativeLocation location; RelativeLocation location;
int yaw; short yaw;
int pitch; short pitch;
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
@ -33,8 +33,8 @@ public class PacketEntityPositionAndRotation implements ClientboundPacket {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.location = new RelativeLocation(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte()); this.location = new RelativeLocation(buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte(), buffer.readFixedPointNumberByte());
this.yaw = buffer.readByte(); //ToDo dividing, ... this.yaw = buffer.readAngle();
this.pitch = buffer.readByte(); this.pitch = buffer.readAngle();
break; break;
} }
} }
@ -52,11 +52,11 @@ public class PacketEntityPositionAndRotation implements ClientboundPacket {
return location; return location;
} }
public int getYaw() { public short getYaw() {
return yaw; return yaw;
} }
public int getPitch() { public short getPitch() {
return pitch; return pitch;
} }

View File

@ -22,16 +22,16 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketEntityRotation implements ClientboundPacket { public class PacketEntityRotation implements ClientboundPacket {
int entityId; int entityId;
int yaw; short yaw;
int pitch; short pitch;
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
switch (v) { switch (v) {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.yaw = buffer.readByte(); this.yaw = buffer.readAngle();
this.pitch = buffer.readByte(); this.pitch = buffer.readAngle();
break; break;
} }
} }
@ -46,11 +46,11 @@ public class PacketEntityRotation implements ClientboundPacket {
} }
public int getYaw() { public short getYaw() {
return yaw; return yaw;
} }
public int getPitch() { public short getPitch() {
return pitch; return pitch;
} }

View File

@ -24,8 +24,8 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketEntityTeleport implements ClientboundPacket { public class PacketEntityTeleport implements ClientboundPacket {
int entityId; int entityId;
Location location; Location location;
int yaw; short yaw;
int pitch; short pitch;
@Override @Override
public void read(InPacketBuffer buffer, ProtocolVersion v) { public void read(InPacketBuffer buffer, ProtocolVersion v) {
@ -33,8 +33,8 @@ public class PacketEntityTeleport implements ClientboundPacket {
case VERSION_1_7_10: case VERSION_1_7_10:
this.entityId = buffer.readInteger(); this.entityId = buffer.readInteger();
this.location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); this.location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
this.yaw = buffer.readByte(); this.yaw = buffer.readAngle();
this.pitch = buffer.readByte(); this.pitch = buffer.readAngle();
break; break;
} }
} }
@ -52,11 +52,11 @@ public class PacketEntityTeleport implements ClientboundPacket {
return location; return location;
} }
public int getYaw() { public short getYaw() {
return yaw; return yaw;
} }
public int getPitch() { public short getPitch() {
return pitch; return pitch;
} }

View File

@ -36,14 +36,14 @@ public class PacketSpawnMob implements ClientboundPacket {
int entityId = buffer.readVarInt(); int entityId = buffer.readVarInt();
Mobs type = Mobs.byType(buffer.readByte()); Mobs type = Mobs.byType(buffer.readByte());
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
int yaw = buffer.readByte(); short yaw = buffer.readAngle();
int pitch = buffer.readByte(); short pitch = buffer.readAngle();
int headPitch = buffer.readByte(); int headpitch = buffer.readAngle();
Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort()); Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
assert type != null; assert type != null;
try { try {
mob = type.getClazz().getConstructor(int.class, Location.class, int.class, int.class, Velocity.class, InByteBuffer.class, ProtocolVersion.class).newInstance(entityId, location, yaw, pitch, velocity, buffer, v); mob = type.getClazz().getConstructor(int.class, Location.class, short.class, short.class, Velocity.class, InByteBuffer.class, ProtocolVersion.class).newInstance(entityId, location, yaw, pitch, velocity, buffer, v);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -34,12 +34,12 @@ public class PacketSpawnObject implements ClientboundPacket {
int entityId = buffer.readVarInt(); int entityId = buffer.readVarInt();
Objects type = Objects.byType(buffer.readByte()); Objects type = Objects.byType(buffer.readByte());
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
int pitch = buffer.readByte(); short pitch = buffer.readAngle();
int yaw = buffer.readByte(); short yaw = buffer.readAngle();
assert type != null; assert type != null;
try { try {
object = type.getClazz().getConstructor(int.class, Location.class, int.class, int.class, int.class, ProtocolVersion.class).newInstance(entityId, location, yaw, pitch, buffer.readInteger(), v); object = type.getClazz().getConstructor(int.class, Location.class, short.class, short.class, int.class, ProtocolVersion.class).newInstance(entityId, location, yaw, pitch, buffer.readInteger(), v);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -42,8 +42,8 @@ public class PacketSpawnPlayer implements ClientboundPacket {
properties[i] = new PlayerPropertyData(buffer.readString(), buffer.readString(), buffer.readString()); properties[i] = new PlayerPropertyData(buffer.readString(), buffer.readString(), buffer.readString());
} }
Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger()); Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
int yaw = buffer.readByte(); short yaw = buffer.readAngle();
int pitch = buffer.readByte(); short pitch = buffer.readAngle();
short currentItem = buffer.readShort(); short currentItem = buffer.readShort();
HumanMetaData metaData = new HumanMetaData(buffer, v); HumanMetaData metaData = new HumanMetaData(buffer, v);

View File

@ -13,15 +13,15 @@
package de.bixilon.minosoft.protocol.protocol; package de.bixilon.minosoft.protocol.protocol;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.game.datatypes.TextComponent;
import de.bixilon.minosoft.game.datatypes.Direction; import de.bixilon.minosoft.game.datatypes.Direction;
import de.bixilon.minosoft.game.datatypes.Slot; import de.bixilon.minosoft.game.datatypes.Slot;
import de.bixilon.minosoft.game.datatypes.TextComponent;
import de.bixilon.minosoft.game.datatypes.entities.Pose; import de.bixilon.minosoft.game.datatypes.entities.Pose;
import de.bixilon.minosoft.game.datatypes.particle.BlockParticle; import de.bixilon.minosoft.game.datatypes.particle.BlockParticle;
import de.bixilon.minosoft.game.datatypes.particle.OtherParticles; import de.bixilon.minosoft.game.datatypes.particle.OtherParticles;
import de.bixilon.minosoft.game.datatypes.particle.Particle; import de.bixilon.minosoft.game.datatypes.particle.Particle;
import de.bixilon.minosoft.game.datatypes.particle.Particles; import de.bixilon.minosoft.game.datatypes.particle.Particles;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.nbt.tag.CompoundTag; import de.bixilon.minosoft.nbt.tag.CompoundTag;
import de.bixilon.minosoft.nbt.tag.TagTypes; import de.bixilon.minosoft.nbt.tag.TagTypes;
import de.bixilon.minosoft.util.Util; import de.bixilon.minosoft.util.Util;
@ -195,6 +195,10 @@ public class InByteBuffer {
return this.pos; return this.pos;
} }
public void setPosition(int pos) {
this.pos = pos;
}
public int getLength() { public int getLength() {
return bytes.length; return bytes.length;
} }
@ -203,7 +207,6 @@ public class InByteBuffer {
return bytes.length - pos; return bytes.length - pos;
} }
public Direction readDirection() { public Direction readDirection() {
return Direction.byId(readVarInt()); return Direction.byId(readVarInt());
} }
@ -227,10 +230,6 @@ public class InByteBuffer {
return null; return null;
} }
public void setPosition(int pos) {
this.pos = pos;
}
public CompoundTag readNBT() { public CompoundTag readNBT() {
if (readByte() != TagTypes.COMPOUND.getId()) { // will be a Compound Tag if (readByte() != TagTypes.COMPOUND.getId()) { // will be a Compound Tag
@ -281,4 +280,8 @@ public class InByteBuffer {
public String getBase64() { public String getBase64() {
return getBase64(getPosition(), getBytesLeft()); return getBase64(getPosition(), getBytesLeft());
} }
public short readAngle() {
return (short) (readByte() * ProtocolDefinition.ANGLE_CALCULATION_CONSTANT);
}
} }

View File

@ -17,4 +17,5 @@ public final class ProtocolDefinition {
public static final int STRING_MAX_LEN = 32767; public static final int STRING_MAX_LEN = 32767;
public static final int DEFAULT_PORT = 25565; public static final int DEFAULT_PORT = 25565;
public static final int PROTOCOL_PACKET_MAX_SIZE = 2097152; public static final int PROTOCOL_PACKET_MAX_SIZE = 2097152;
public static final float ANGLE_CALCULATION_CONSTANT = 360.0F / 256.0F;
} }