From aaf95effc4b7c6ab3b8bdc9a29f4e4e7ae6b096e Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Mon, 21 Oct 2024 13:50:41 -0400 Subject: [PATCH] IT BOOOOOOOOOTS --- .../registry/loader/RecipeRegistryLoader.java | 8 ++- .../populator/BlockRegistryPopulator.java | 2 +- .../populator/ItemRegistryPopulator.java | 3 +- .../geyser/session/GeyserSession.java | 3 +- .../JavaEntityPositionSyncTranslator.java | 52 +++++++++++++++++++ .../entity/JavaTeleportEntityTranslator.java | 14 +---- .../player/JavaPlayerPositionTranslator.java | 22 ++++---- .../JavaContainerSetSlotTranslator.java | 5 +- 8 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaEntityPositionSyncTranslator.java diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/RecipeRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/RecipeRegistryLoader.java index f1d0c456f..1af6a8661 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/RecipeRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/RecipeRegistryLoader.java @@ -49,6 +49,7 @@ import java.io.DataInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Base64; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -60,6 +61,9 @@ public final class RecipeRegistryLoader implements RegistryLoader> load(String input) { + if (true) { + return Collections.emptyMap(); + } Map> deserializedRecipes = new Object2ObjectOpenHashMap<>(); List recipes; @@ -96,7 +100,7 @@ public final class RecipeRegistryLoader implements RegistryLoader rawInputs = recipe.getList("inputs", NbtType.COMPOUND); Ingredient[] javaInputs = new Ingredient[rawInputs.size()]; for (int i = 0; i < rawInputs.size(); i++) { - javaInputs[i] = new Ingredient(new ItemStack[] {toItemStack(rawInputs.get(i), helper)}); + //javaInputs[i] = new Ingredient(new ItemStack[] {toItemStack(rawInputs.get(i), helper)}); } deserializedRecipes.add(new GeyserShapelessRecipe(javaInputs, output)); } @@ -121,7 +125,7 @@ public final class RecipeRegistryLoader implements RegistryLoader { + + @Override + public void translate(GeyserSession session, ClientboundEntityPositionSyncPacket packet) { + Entity entity = session.getEntityCache().getEntityByJavaId(packet.getId()); + if (entity == null) return; + + Vector3d pos = packet.getPosition(); + + if (entity instanceof ClientVehicle clientVehicle) { + clientVehicle.getVehicleComponent().moveAbsolute(pos.getX(), pos.getY(), pos.getZ()); + } + + entity.teleport(pos.toFloat(), packet.getXRot(), packet.getYRot(), packet.isOnGround()); + } +} diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaTeleportEntityTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaTeleportEntityTranslator.java index 47c61eb8e..eda195a8f 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaTeleportEntityTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/JavaTeleportEntityTranslator.java @@ -25,26 +25,16 @@ package org.geysermc.geyser.translator.protocol.java.entity; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket; -import org.cloudburstmc.math.vector.Vector3f; -import org.geysermc.geyser.entity.type.Entity; -import org.geysermc.geyser.entity.vehicle.ClientVehicle; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket; @Translator(packet = ClientboundTeleportEntityPacket.class) public class JavaTeleportEntityTranslator extends PacketTranslator { @Override public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) { - Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId()); - if (entity == null) return; - - if (entity instanceof ClientVehicle clientVehicle) { - clientVehicle.getVehicleComponent().moveAbsolute(packet.getX(), packet.getY(), packet.getZ()); - } - - entity.teleport(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), packet.isOnGround()); + session.getGeyser().getLogger().info(packet.toString()); } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerPositionTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerPositionTranslator.java index 5fc7f7200..e73e25a93 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerPositionTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerPositionTranslator.java @@ -25,6 +25,7 @@ package org.geysermc.geyser.translator.protocol.java.entity.player; +import org.cloudburstmc.math.vector.Vector3d; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PositionElement; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket; @@ -50,14 +51,15 @@ public class JavaPlayerPositionTranslator extends PacketTranslator