diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index 4c42c1ad..c8d921ce 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -29,10 +29,12 @@ import com.github.steveice10.mc.protocol.data.game.window.WindowType; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerTitlePacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityDestroyPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket; @@ -53,16 +55,18 @@ import org.geysermc.connector.network.translators.inventory.GenericInventoryTran import org.geysermc.connector.network.translators.inventory.InventoryTranslator; import org.geysermc.connector.network.translators.item.ItemTranslator; import org.geysermc.connector.network.translators.java.JavaChatTranslator; -import org.geysermc.connector.network.translators.java.JavaEntityPositionRotationTranslator; -import org.geysermc.connector.network.translators.java.JavaEntityPositionTranslator; -import org.geysermc.connector.network.translators.java.JavaEntityTeleportTranslator; -import org.geysermc.connector.network.translators.java.JavaEntityVelocityTranslator; import org.geysermc.connector.network.translators.java.JavaJoinGameTranslator; -import org.geysermc.connector.network.translators.java.JavaNotifyClientTranslator; +import org.geysermc.connector.network.translators.java.entity.JavaEntityDestroyTranslator; +import org.geysermc.connector.network.translators.java.entity.JavaEntityPositionRotationTranslator; +import org.geysermc.connector.network.translators.java.entity.JavaEntityPositionTranslator; +import org.geysermc.connector.network.translators.java.entity.JavaEntityTeleportTranslator; +import org.geysermc.connector.network.translators.java.entity.JavaEntityVelocityTranslator; +import org.geysermc.connector.network.translators.java.entity.spawn.JavaSpawnExpOrbTranslator; +import org.geysermc.connector.network.translators.java.world.JavaNotifyClientTranslator; import org.geysermc.connector.network.translators.java.JavaOpenWindowTranslator; import org.geysermc.connector.network.translators.java.JavaSetSlotTranslator; import org.geysermc.connector.network.translators.java.JavaTitleTranslator; -import org.geysermc.connector.network.translators.java.JavaUpdateTimeTranslator; +import org.geysermc.connector.network.translators.java.world.JavaUpdateTimeTranslator; import org.geysermc.connector.network.translators.java.JavaWindowItemsTranslator; import java.io.ByteArrayOutputStream; @@ -105,6 +109,8 @@ public class TranslatorsInit { Registry.registerJava(ServerEntityTeleportPacket.class, new JavaEntityTeleportTranslator()); Registry.registerJava(ServerEntityVelocityPacket.class, new JavaEntityVelocityTranslator()); Registry.registerJava(ServerNotifyClientPacket.class, new JavaNotifyClientTranslator()); + Registry.registerJava(ServerEntityDestroyPacket.class, new JavaEntityDestroyTranslator()); + Registry.registerJava(ServerSpawnExpOrbPacket.class, new JavaSpawnExpOrbTranslator()); Registry.registerJava(ServerWindowItemsPacket.class, new JavaWindowItemsTranslator()); Registry.registerJava(ServerOpenWindowPacket.class, new JavaOpenWindowTranslator()); Registry.registerJava(ServerSetSlotPacket.class, new JavaSetSlotTranslator()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityDestroyTranslator.java similarity index 66% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTimeTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityDestroyTranslator.java index 52faa89d..a9885d33 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityDestroyTranslator.java @@ -23,20 +23,23 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.entity; -import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket; -import com.nukkitx.protocol.bedrock.packet.SetTimePacket; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityDestroyPacket; +import com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; -public class JavaTimeTranslator extends PacketTranslator { +public class JavaEntityDestroyTranslator extends PacketTranslator { @Override - public void translate(ServerUpdateTimePacket packet, GeyserSession session) { - SetTimePacket setTimePacket = new SetTimePacket(); - setTimePacket.setTime((int) Math.abs(packet.getTime())); + public void translate(ServerEntityDestroyPacket packet, GeyserSession session) { + for (int entityId : packet.getEntityIds()) { + RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); + removeEntityPacket.setUniqueEntityId(entityId); - session.getUpstream().sendPacket(setTimePacket); + session.getUpstream().sendPacket(removeEntityPacket); + } } } + diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionRotationTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionRotationTranslator.java similarity index 97% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionRotationTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionRotationTranslator.java index e8414f48..713a2432 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionRotationTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionRotationTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.entity; import com.flowpowered.math.vector.Vector3f; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionTranslator.java similarity index 97% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionTranslator.java index ccdbb9d9..a79b9d72 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityPositionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityPositionTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.entity; import com.flowpowered.math.vector.Vector3f; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityTeleportTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityTeleportTranslator.java similarity index 97% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityTeleportTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityTeleportTranslator.java index 694c48f9..c5ec98fc 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityTeleportTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityTeleportTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.entity; import com.flowpowered.math.vector.Vector3f; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityVelocityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityVelocityTranslator.java similarity index 97% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityVelocityTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityVelocityTranslator.java index 43bfe355..ef96e2f5 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaEntityVelocityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityVelocityTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.entity; import com.flowpowered.math.vector.Vector3f; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnExpOrbTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnExpOrbTranslator.java new file mode 100644 index 00000000..c7f754dc --- /dev/null +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/spawn/JavaSpawnExpOrbTranslator.java @@ -0,0 +1,19 @@ +package org.geysermc.connector.network.translators.java.entity.spawn; + +import com.flowpowered.math.vector.Vector3f; +import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket; +import com.nukkitx.protocol.bedrock.packet.SpawnExperienceOrbPacket; +import org.geysermc.connector.network.session.GeyserSession; +import org.geysermc.connector.network.translators.PacketTranslator; + +public class JavaSpawnExpOrbTranslator extends PacketTranslator { + + @Override + public void translate(ServerSpawnExpOrbPacket packet, GeyserSession session) { + SpawnExperienceOrbPacket spawnExperienceOrbPacket = new SpawnExperienceOrbPacket(); + spawnExperienceOrbPacket.setPosition(new Vector3f(packet.getX(), packet.getY(), packet.getZ())); + spawnExperienceOrbPacket.setAmount(packet.getExp()); + + session.getUpstream().sendPacket(spawnExperienceOrbPacket); + } +} diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaNotifyClientTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java similarity index 98% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaNotifyClientTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java index 8aade7e3..65c25a1d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaNotifyClientTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaNotifyClientTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.world; import com.flowpowered.math.vector.Vector3f; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaUpdateTimeTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java similarity index 96% rename from connector/src/main/java/org/geysermc/connector/network/translators/java/JavaUpdateTimeTranslator.java rename to connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java index 27eb8151..3e9cc40c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaUpdateTimeTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaUpdateTimeTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.connector.network.translators.java; +package org.geysermc.connector.network.translators.java.world; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket; import com.nukkitx.protocol.bedrock.packet.SetTimePacket;