diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/entities/ExperienceOrb.java b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/ExperienceOrb.java
new file mode 100644
index 000000000..d45c9bf2b
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/game/datatypes/entities/ExperienceOrb.java
@@ -0,0 +1,56 @@
+/*
+ * Codename Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.game.datatypes.entities;
+
+import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
+
+public class ExperienceOrb extends Entity {
+ EntityMetaData metaData;
+ short count;
+
+
+ public ExperienceOrb(int id, Location location, short count) {
+ super(id, location, 0, 0, null);
+ this.count = count;
+ }
+
+ @Override
+ public EntityMetaData getMetaData() {
+ return metaData;
+ }
+
+ @Override
+ public void setMetaData(EntityMetaData metaData) {
+ this.metaData = metaData;
+ }
+
+ @Override
+ public float getWidth() {
+ return 0.5F;
+ }
+
+ @Override
+ public float getHeight() {
+ return 0.5F;
+ }
+
+ @Override
+ public Class extends EntityMetaData> getMetaDataClass() {
+ return EntityMetaData.class;
+ }
+
+ public short getCount() {
+ return count;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnExperienceOrb.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnExperienceOrb.java
new file mode 100644
index 000000000..95d212986
--- /dev/null
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnExperienceOrb.java
@@ -0,0 +1,53 @@
+/*
+ * Codename Minosoft
+ * Copyright (C) 2020 Moritz Zwerger
+ *
+ * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with this program. If not, see .
+ *
+ * This software is not affiliated with Mojang AB, the original developer of Minecraft.
+ */
+
+package de.bixilon.minosoft.protocol.packets.clientbound.play;
+
+import de.bixilon.minosoft.game.datatypes.entities.ExperienceOrb;
+import de.bixilon.minosoft.game.datatypes.entities.Location;
+import de.bixilon.minosoft.logging.Log;
+import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
+import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
+import de.bixilon.minosoft.protocol.protocol.PacketHandler;
+import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
+
+public class PacketSpawnExperienceOrb implements ClientboundPacket {
+ ExperienceOrb orb;
+
+
+ @Override
+ public void read(InPacketBuffer buffer, ProtocolVersion v) {
+ switch (v) {
+ case VERSION_1_7_10:
+ int entityId = buffer.readVarInt();
+ Location location = new Location(buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger(), buffer.readFixedPointNumberInteger());
+ short count = buffer.readShort();
+ orb = new ExperienceOrb(entityId, location, count);
+ break;
+ }
+ }
+
+ @Override
+ public void log() {
+ Log.protocol(String.format("Experience orb spawned (entityId=%d, count=%d, at %s)", orb.getId(), orb.getCount(), orb.getLocation().toString()));
+ }
+
+ @Override
+ public void handle(PacketHandler h) {
+ h.handle(this);
+ }
+
+ public ExperienceOrb getOrb() {
+ return orb;
+ }
+}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnLocation.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnLocation.java
index 006866251..18ee181de 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnLocation.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnLocation.java
@@ -38,7 +38,7 @@ public class PacketSpawnLocation implements ClientboundPacket {
@Override
public void log() {
- Log.protocol(String.format("Received spawn location %s %s %s", loc.getX(), loc.getY(), loc.getZ()));
+ Log.protocol(String.format("Received spawn location %s", loc.toString()));
}
public Location getSpawnLocation() {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java
index 66c1de181..2c432e857 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSpawnMob.java
@@ -43,7 +43,7 @@ public class PacketSpawnMob implements ClientboundPacket {
assert type != null;
try {
- mob = (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, int.class, int.class, Velocity.class, InByteBuffer.class, ProtocolVersion.class).newInstance(entityId, location, yaw, pitch, velocity, buffer, v);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
@@ -53,7 +53,7 @@ public class PacketSpawnMob implements ClientboundPacket {
@Override
public void log() {
- Log.protocol(String.format("Mob spawned (entityId=%d, type=%s, at %s %s %s)", mob.getId(), mob.getEntityType().name(), mob.getLocation().getX(), mob.getLocation().getY(), mob.getLocation().getZ()));
+ Log.protocol(String.format("Mob spawned (entityId=%d, type=%s, at %s)", mob.getId(), mob.getEntityType().name(), mob.getLocation().toString()));
}
public Mob getMob() {
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
index bcef2e11a..960773b03 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java
@@ -231,4 +231,8 @@ public class PacketHandler {
public void handle(PacketSpawnObject pkg) {
connection.getPlayer().getWorld().addEntity(pkg.getObject());
}
+
+ public void handle(PacketSpawnExperienceOrb pkg) {
+ connection.getPlayer().getWorld().addEntity(pkg.getOrb());
+ }
}
diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
index 81911d671..3893e3512 100644
--- a/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
+++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/Protocol.java
@@ -79,5 +79,6 @@ public interface Protocol {
packetClassMapping.put(Packets.Clientbound.PLAY_RESPAWN, PacketRespawn.class);
packetClassMapping.put(Packets.Clientbound.PLAY_OPEN_SIGN_EDITOR, PacketOpenSignEditor.class);
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_OBJECT, PacketSpawnObject.class);
+ packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_EXPERIENCE_ORB, PacketSpawnExperienceOrb.class);
}
}
\ No newline at end of file