mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-27 15:00:28 +01:00
Update to latest MCProtocolLib with Mojang mappings
This commit is contained in:
parent
5d58394bc0
commit
768b09e7fd
150 changed files with 652 additions and 662 deletions
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.platform.spigot.world;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.value.PistonValueType;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.value.PistonValueType;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
|
|
|
@ -147,9 +147,9 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC</groupId>
|
||||
<artifactId>MCProtocolLib</artifactId>
|
||||
<version>c2985e8</version>
|
||||
<groupId>com.github.steveice10</groupId>
|
||||
<artifactId>mcprotocollib</artifactId>
|
||||
<version>1.17.1-3-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.command.defaults;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandSender;
|
||||
import org.geysermc.connector.command.GeyserCommand;
|
||||
|
@ -46,7 +46,7 @@ public class OffhandCommand extends GeyserCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, BlockUtils.POSITION_ZERO,
|
||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.SWAP_HANDS, BlockUtils.POSITION_ZERO,
|
||||
BlockFace.DOWN);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.command.defaults;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.command.CommandSender;
|
||||
import org.geysermc.connector.command.GeyserCommand;
|
||||
|
@ -43,8 +43,8 @@ public class StatisticsCommand extends GeyserCommand {
|
|||
if (session == null) return;
|
||||
|
||||
session.setWaitingForStatistics(true);
|
||||
ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.STATS);
|
||||
session.sendDownstreamPacket(clientRequestPacket);
|
||||
ServerboundClientCommandPacket ServerboundClientCommandPacket = new ServerboundClientCommandPacket(ClientRequest.STATS);
|
||||
session.sendDownstreamPacket(ServerboundClientCommandPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.particle.Particle;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.particle.Particle;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
|
|
@ -72,7 +72,7 @@ public class BoatEntity extends Entity {
|
|||
|
||||
MoveEntityAbsolutePacket moveEntityPacket = new MoveEntityAbsolutePacket();
|
||||
moveEntityPacket.setRuntimeEntityId(geyserId);
|
||||
// Minimal glitching when ServerVehicleMovePacket is sent
|
||||
// Minimal glitching when ClientboundMoveVehiclePacket is sent
|
||||
moveEntityPacket.setPosition(session.getRidingVehicleEntity() == this ? position.up(EntityType.PLAYER.getOffset() - this.entityType.getOffset()) : this.position);
|
||||
moveEntityPacket.setRotation(getBedrockRotation());
|
||||
moveEntityPacket.setOnGround(isOnGround);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.entity.living.monster;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
|
|
@ -40,12 +40,12 @@ import com.github.steveice10.mc.protocol.data.game.entity.metadata.Pose;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.Recipe;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.Statistic;
|
||||
import com.github.steveice10.mc.protocol.packet.handshake.client.HandshakePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.LoginPluginResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.handshake.serverbound.ClientIntentionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundCustomQueryPacket;
|
||||
import com.github.steveice10.packetlib.BuiltinFlags;
|
||||
import com.github.steveice10.packetlib.event.session.*;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
|
@ -376,7 +376,7 @@ public class GeyserSession implements CommandSender {
|
|||
private long lastMovementTimestamp = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* Used to send a ClientVehicleMovePacket for every PlayerInputPacket after idling on a boat/horse for more than 100ms
|
||||
* Used to send a ServerboundMoveVehiclePacket for every PlayerInputPacket after idling on a boat/horse for more than 100ms
|
||||
*/
|
||||
@Setter
|
||||
private long lastVehicleMoveTimestamp = System.currentTimeMillis();
|
||||
|
@ -737,7 +737,7 @@ public class GeyserSession implements CommandSender {
|
|||
@Override
|
||||
public void packetSending(PacketSendingEvent event) {
|
||||
//todo move this somewhere else
|
||||
if (event.getPacket() instanceof HandshakePacket) {
|
||||
if (event.getPacket() instanceof ClientIntentionPacket) {
|
||||
String addressSuffix;
|
||||
if (floodgate) {
|
||||
byte[] encryptedData;
|
||||
|
@ -778,21 +778,16 @@ public class GeyserSession implements CommandSender {
|
|||
addressSuffix = "";
|
||||
}
|
||||
|
||||
HandshakePacket handshakePacket = event.getPacket();
|
||||
ClientIntentionPacket intentionPacket = event.getPacket();
|
||||
|
||||
String address;
|
||||
if (connector.getConfig().getRemote().isForwardHost()) {
|
||||
address = clientData.getServerAddress().split(":")[0];
|
||||
} else {
|
||||
address = handshakePacket.getHostname();
|
||||
address = intentionPacket.getHostname();
|
||||
}
|
||||
|
||||
event.setPacket(new HandshakePacket(
|
||||
handshakePacket.getProtocolVersion(),
|
||||
address + addressSuffix,
|
||||
handshakePacket.getPort(),
|
||||
handshakePacket.getIntent()
|
||||
));
|
||||
event.setPacket(intentionPacket.withHostname(address + addressSuffix));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -963,7 +958,7 @@ public class GeyserSession implements CommandSender {
|
|||
Vector3d position = collisionManager.adjustBedrockPosition(playerEntity.getPosition(), playerEntity.isOnGround(), false);
|
||||
// A null return value cancels the packet
|
||||
if (position != null) {
|
||||
ClientPlayerPositionPacket packet = new ClientPlayerPositionPacket(playerEntity.isOnGround(),
|
||||
ServerboundMovePlayerPosPacket packet = new ServerboundMovePlayerPosPacket(playerEntity.isOnGround(),
|
||||
position.getX(), position.getY(), position.getZ());
|
||||
sendDownstreamPacket(packet);
|
||||
}
|
||||
|
@ -1242,10 +1237,10 @@ public class GeyserSession implements CommandSender {
|
|||
TeleportCache entry = it.next().getValue();
|
||||
int nextID = entry.getTeleportConfirmId();
|
||||
if (nextID <= teleportID) {
|
||||
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(nextID);
|
||||
ServerboundAcceptTeleportationPacket teleportConfirmPacket = new ServerboundAcceptTeleportationPacket(nextID);
|
||||
sendDownstreamPacket(teleportConfirmPacket);
|
||||
// Servers (especially ones like Hypixel) expect exact coordinates given back to them.
|
||||
ClientPlayerPositionRotationPacket positionPacket = new ClientPlayerPositionRotationPacket(playerEntity.isOnGround(),
|
||||
ServerboundMovePlayerPosRotPacket positionPacket = new ServerboundMovePlayerPosRotPacket(playerEntity.isOnGround(),
|
||||
entry.getX(), entry.getY(), entry.getZ(), entry.getYaw(), entry.getPitch());
|
||||
sendDownstreamPacket(positionPacket);
|
||||
it.remove();
|
||||
|
@ -1320,7 +1315,7 @@ public class GeyserSession implements CommandSender {
|
|||
}
|
||||
|
||||
private void sendDownstreamPacket0(Packet packet) {
|
||||
if (protocol.getSubProtocol().equals(SubProtocol.GAME) || packet.getClass() == LoginPluginResponsePacket.class) {
|
||||
if (protocol.getSubProtocol().equals(SubProtocol.GAME) || packet.getClass() == ServerboundCustomQueryPacket.class) {
|
||||
downstream.send(packet);
|
||||
} else {
|
||||
connector.getLogger().debug("Tried to send downstream packet " + packet.getClass().getSimpleName() + " before connected to the server");
|
||||
|
@ -1400,7 +1395,7 @@ public class GeyserSession implements CommandSender {
|
|||
if (spectator && !flying) {
|
||||
// We're "flying locked" in this gamemode
|
||||
flying = true;
|
||||
ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(true);
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(true);
|
||||
sendDownstreamPacket(abilitiesPacket);
|
||||
}
|
||||
flags.add(AdventureSetting.FLYING);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.session.cache;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientAdvancementTabPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSeenAdvancementsPacket;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -113,7 +113,7 @@ public class AdvancementsCache {
|
|||
buildAndShowListForm();
|
||||
} else {
|
||||
// Send a packet indicating that we intend to open this particular advancement window
|
||||
ClientAdvancementTabPacket packet = new ClientAdvancementTabPacket(id);
|
||||
ServerboundSeenAdvancementsPacket packet = new ServerboundSeenAdvancementsPacket(id);
|
||||
session.sendDownstreamPacket(packet);
|
||||
// Wait for a response there
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class AdvancementsCache {
|
|||
SimpleFormResponse response = form.parseResponse(responseData);
|
||||
if (!response.isCorrect()) {
|
||||
// Indicate that we have closed the current advancement tab
|
||||
session.sendDownstreamPacket(new ClientAdvancementTabPacket());
|
||||
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class AdvancementsCache {
|
|||
} else {
|
||||
buildAndShowMenuForm();
|
||||
// Indicate that we have closed the current advancement tab
|
||||
session.sendDownstreamPacket(new ClientAdvancementTabPacket());
|
||||
session.sendDownstreamPacket(new ServerboundSeenAdvancementsPacket());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.session.cache;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientEditBookPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundEditBookPacket;
|
||||
import lombok.Setter;
|
||||
import org.geysermc.connector.inventory.GeyserItemStack;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -39,7 +39,7 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
public class BookEditCache {
|
||||
private final GeyserSession session;
|
||||
@Setter
|
||||
private ClientEditBookPacket packet;
|
||||
private ServerboundEditBookPacket packet;
|
||||
/**
|
||||
* Stores the last time a book update packet was sent to the server.
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.session.cache;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareTagsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateTagsPacket;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntLists;
|
||||
import org.geysermc.connector.registry.type.BlockMapping;
|
||||
|
@ -34,7 +34,7 @@ import org.geysermc.connector.registry.type.ItemMapping;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Manages information sent from the {@link ServerDeclareTagsPacket}. If that packet is not sent, all lists here
|
||||
* Manages information sent from the {@link ClientboundUpdateTagsPacket}. If that packet is not sent, all lists here
|
||||
* will remain empty, matching Java Edition behavior.
|
||||
*/
|
||||
public class TagCache {
|
||||
|
@ -61,7 +61,7 @@ public class TagCache {
|
|||
clear();
|
||||
}
|
||||
|
||||
public void loadPacket(ServerDeclareTagsPacket packet) {
|
||||
public void loadPacket(ClientboundUpdateTagsPacket packet) {
|
||||
Map<String, int[]> blockTags = packet.getTags().get("minecraft:block");
|
||||
this.leaves = IntList.of(blockTags.get("minecraft:leaves"));
|
||||
this.wool = IntList.of(blockTags.get("minecraft:wool"));
|
||||
|
|
|
@ -33,7 +33,7 @@ import lombok.RequiredArgsConstructor;
|
|||
* Represents a teleport ID and corresponding coordinates that need to be confirmed. <br>
|
||||
*
|
||||
* The vanilla Java client, after getting a
|
||||
* {@link com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket},
|
||||
* {@link com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket},
|
||||
* adjusts the player's positions and immediately sends a teleport back. However, we want to acknowledge that the
|
||||
* Bedrock player actually moves close to that point, so we store the teleport until we get a movement packet from
|
||||
* Bedrock that the teleport was successful.
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.network.translators;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPlayerListDataPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerUpdateLightPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundTabListPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLightUpdatePacket;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||
import io.netty.channel.EventLoop;
|
||||
|
@ -73,8 +73,8 @@ public class PacketTranslatorRegistry<T> {
|
|||
}
|
||||
}
|
||||
|
||||
IGNORED_PACKETS.add(ServerUpdateLightPacket.class); // Light is handled on Bedrock for us
|
||||
IGNORED_PACKETS.add(ServerPlayerListDataPacket.class); // Cant be implemented in bedrock
|
||||
IGNORED_PACKETS.add(ClientboundLightUpdatePacket.class); // Light is handled on Bedrock for us
|
||||
IGNORED_PACKETS.add(ClientboundTabListPacket.class); // Cant be implemented in Bedrock
|
||||
}
|
||||
|
||||
private PacketTranslatorRegistry() {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerAbilitiesPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.AdventureSetting;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.packet.AdventureSettingsPacket;
|
||||
|
@ -47,7 +47,7 @@ public class BedrockAdventureSettingsTranslator extends PacketTranslator<Adventu
|
|||
}
|
||||
|
||||
session.setFlying(isFlying);
|
||||
ClientPlayerAbilitiesPacket abilitiesPacket = new ClientPlayerAbilitiesPacket(isFlying);
|
||||
ServerboundPlayerAbilitiesPacket abilitiesPacket = new ServerboundPlayerAbilitiesPacket(isFlying);
|
||||
session.sendDownstreamPacket(abilitiesPacket);
|
||||
|
||||
if (isFlying && session.getPlayerEntity().getMetadata().getFlags().getFlag(EntityFlag.SWIMMING)) {
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerBoatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundPaddleBoatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSwingPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -49,7 +49,7 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
|||
case SWING_ARM ->
|
||||
// Delay so entity damage can be processed first
|
||||
session.scheduleInEventLoop(() ->
|
||||
session.sendDownstreamPacket(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
|
||||
session.sendDownstreamPacket(new ServerboundSwingPacket(Hand.MAIN_HAND)),
|
||||
25,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
@ -57,12 +57,12 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
|||
case ROW_LEFT -> {
|
||||
// Packet value is a float of how long one has been rowing, so we convert that into a boolean
|
||||
session.setSteeringLeft(packet.getRowingTime() > 0.0);
|
||||
ClientSteerBoatPacket steerLeftPacket = new ClientSteerBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
ServerboundPaddleBoatPacket steerLeftPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
session.sendDownstreamPacket(steerLeftPacket);
|
||||
}
|
||||
case ROW_RIGHT -> {
|
||||
session.setSteeringRight(packet.getRowingTime() > 0.0);
|
||||
ClientSteerBoatPacket steerRightPacket = new ClientSteerBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
ServerboundPaddleBoatPacket steerRightPacket = new ServerboundPaddleBoatPacket(session.isSteeringLeft(), session.isSteeringRight());
|
||||
session.sendDownstreamPacket(steerRightPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientUpdateJigsawBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSetJigsawBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundSignUpdatePacket;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.protocol.bedrock.packet.BlockEntityDataPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -105,8 +105,8 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
|||
// Put the final line on since it isn't done in the for loop
|
||||
if (iterator < lines.length) lines[iterator] = newMessage.toString();
|
||||
Position pos = new Position(tag.getInt("x"), tag.getInt("y"), tag.getInt("z"));
|
||||
ClientUpdateSignPacket clientUpdateSignPacket = new ClientUpdateSignPacket(pos, lines);
|
||||
session.sendDownstreamPacket(clientUpdateSignPacket);
|
||||
ServerboundSignUpdatePacket signUpdatePacket = new ServerboundSignUpdatePacket(pos, lines);
|
||||
session.sendDownstreamPacket(signUpdatePacket);
|
||||
|
||||
// We set the sign text cached in the session to null to indicate there is no work-in-progress sign
|
||||
session.setLastSignMessage(null);
|
||||
|
@ -119,7 +119,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
|||
String pool = tag.getString("target_pool");
|
||||
String finalState = tag.getString("final_state");
|
||||
String joint = tag.getString("joint");
|
||||
ClientUpdateJigsawBlockPacket jigsawPacket = new ClientUpdateJigsawBlockPacket(pos, name, target, pool,
|
||||
ServerboundSetJigsawBlockPacket jigsawPacket = new ServerboundSetJigsawBlockPacket(pos, name, target, pool,
|
||||
finalState, joint);
|
||||
session.sendDownstreamPacket(jigsawPacket);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientEditBookPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundEditBookPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
|
@ -137,7 +137,7 @@ public class BedrockBookEditTranslator extends PacketTranslator<BookEditPacket>
|
|||
title = null;
|
||||
}
|
||||
|
||||
session.getBookEditCache().setPacket(new ClientEditBookPacket(session.getPlayerInventory().getHeldItemSlot(), networkPages, title));
|
||||
session.getBookEditCache().setPacket(new ServerboundEditBookPacket(session.getPlayerInventory().getHeldItemSlot(), networkPages, title));
|
||||
// There won't be any more book updates after this, so we can try sending the edit packet immediately
|
||||
if (packet.getAction() == BookEditPacket.Action.SIGN_BOOK) {
|
||||
session.getBookEditCache().checkForSend();
|
||||
|
|
|
@ -26,9 +26,9 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.CommandBlockMode;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientUpdateCommandBlockMinecartPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientUpdateCommandBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSetCommandMinecartPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSetCommandBlockPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.CommandBlockUpdatePacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -52,12 +52,12 @@ public class BedrockCommandBlockUpdateTranslator extends PacketTranslator<Comman
|
|||
};
|
||||
boolean isConditional = packet.isConditional();
|
||||
boolean automatic = !packet.isRedstoneMode(); // Automatic = Always Active option in Java
|
||||
ClientUpdateCommandBlockPacket commandBlockPacket = new ClientUpdateCommandBlockPacket(
|
||||
ServerboundSetCommandBlockPacket commandBlockPacket = new ServerboundSetCommandBlockPacket(
|
||||
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
|
||||
command, mode, outputTracked, isConditional, automatic);
|
||||
session.sendDownstreamPacket(commandBlockPacket);
|
||||
} else {
|
||||
ClientUpdateCommandBlockMinecartPacket commandMinecartPacket = new ClientUpdateCommandBlockMinecartPacket(
|
||||
ServerboundSetCommandMinecartPacket commandMinecartPacket = new ServerboundSetCommandMinecartPacket(
|
||||
(int) session.getEntityCache().getEntityByGeyserId(packet.getMinecartRuntimeEntityId()).getEntityId(),
|
||||
command, outputTracked
|
||||
);
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
|||
return;
|
||||
}
|
||||
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(message);
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(message);
|
||||
session.sendDownstreamPacket(chatPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerClosePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.ContainerClosePacket;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.inventory.MerchantContainer;
|
||||
|
@ -53,7 +53,7 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
|
|||
Inventory openInventory = session.getOpenInventory();
|
||||
if (openInventory != null) {
|
||||
if (windowId == openInventory.getId()) {
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(windowId);
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, windowId, false);
|
||||
} else if (openInventory.isPending()) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientRenameItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundRenameItemPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.FilterTextPacket;
|
||||
import org.geysermc.connector.inventory.AnvilContainer;
|
||||
import org.geysermc.connector.inventory.CartographyContainer;
|
||||
|
@ -51,7 +51,7 @@ public class BedrockFilterTextTranslator extends PacketTranslator<FilterTextPack
|
|||
|
||||
if (session.getOpenInventory() instanceof AnvilContainer) {
|
||||
// Java Edition sends a packet every time an item is renamed even slightly in GUI. Fortunately, this works out for us now
|
||||
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(packet.getText());
|
||||
ServerboundRenameItemPacket renameItemPacket = new ServerboundRenameItemPacket(packet.getText());
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,11 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
|
@ -89,7 +89,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
}
|
||||
|
||||
boolean dropAll = worldAction.getToItem().getCount() > 1;
|
||||
ClientPlayerActionPacket dropAllPacket = new ClientPlayerActionPacket(
|
||||
ServerboundPlayerActionPacket dropAllPacket = new ServerboundPlayerActionPacket(
|
||||
dropAll ? PlayerAction.DROP_ITEM_STACK : PlayerAction.DROP_ITEM,
|
||||
BlockUtils.POSITION_ZERO,
|
||||
BlockFace.DOWN
|
||||
|
@ -128,9 +128,9 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
if (itemFrameEntity != null) {
|
||||
int entityId = (int) itemFrameEntity.getEntityId();
|
||||
Vector3f vector = packet.getClickPosition();
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket(entityId,
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket(entityId,
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
||||
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket(entityId,
|
||||
ServerboundInteractPacket interactAtPacket = new ServerboundInteractPacket(entityId,
|
||||
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamPacket(interactAtPacket);
|
||||
|
@ -190,13 +190,13 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
if (blockState == BlockStateValues.JAVA_WATER_ID) {
|
||||
// Otherwise causes multiple mobs to spawn - just send a use item packet
|
||||
// TODO when we fix mobile bucket rotation, use it for this, too
|
||||
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(itemPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ClientPlayerPlaceBlockPacket blockPacket = new ClientPlayerPlaceBlockPacket(
|
||||
ServerboundUseItemOnPacket blockPacket = new ServerboundUseItemOnPacket(
|
||||
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
|
||||
BlockFace.values()[packet.getBlockFace()],
|
||||
Hand.MAIN_HAND,
|
||||
|
@ -207,7 +207,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
if (packet.getItemInHand() != null) {
|
||||
// Otherwise boats will not be able to be placed in survival and buckets won't work on mobile
|
||||
if (session.getItemMappings().getBoatIds().contains(packet.getItemInHand().getId())) {
|
||||
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(itemPacket);
|
||||
} else if (session.getItemMappings().getBucketIds().contains(packet.getItemInHand().getId())) {
|
||||
// Let the server decide if the bucket item should change, not the client, and revert the changes the client made
|
||||
|
@ -216,7 +216,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
slotPacket.setSlot(packet.getHotbarSlot());
|
||||
slotPacket.setItem(packet.getItemInHand());
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
// Don't send ClientPlayerUseItemPacket for powder snow buckets
|
||||
// Don't send ServerboundUseItemPacket for powder snow buckets
|
||||
if (packet.getItemInHand().getId() != session.getItemMappings().getStoredItems().powderSnowBucket().getBedrockId()) {
|
||||
// Special check for crafting tables since clients don't send BLOCK_INTERACT when interacting
|
||||
int blockState = session.getConnector().getWorldManager().getBlockAt(session, packet.getBlockPosition());
|
||||
|
@ -224,7 +224,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
// Delay the interaction in case the client doesn't intend to actually use the bucket
|
||||
// See BedrockActionTranslator.java
|
||||
session.setBucketScheduledFuture(session.scheduleInEventLoop(() -> {
|
||||
ClientPlayerUseItemPacket itemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
ServerboundUseItemPacket itemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(itemPacket);
|
||||
}, 5, TimeUnit.MILLISECONDS));
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
}
|
||||
}
|
||||
|
||||
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
ServerboundUseItemPacket useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
||||
session.sendDownstreamPacket(useItemPacket);
|
||||
}
|
||||
case 2 -> {
|
||||
|
@ -317,7 +317,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
|
||||
Entity itemFrameEntity = ItemFrameEntity.getItemFrameEntity(session, packet.getBlockPosition());
|
||||
if (itemFrameEntity != null) {
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) itemFrameEntity.getEntityId(),
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket((int) itemFrameEntity.getEntityId(),
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
break;
|
||||
|
@ -325,7 +325,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
|
||||
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
|
||||
Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
|
||||
ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getBlockFace()]);
|
||||
ServerboundPlayerActionPacket breakPacket = new ServerboundPlayerActionPacket(action, pos, BlockFace.values()[packet.getBlockFace()]);
|
||||
session.sendDownstreamPacket(breakPacket);
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
case ITEM_RELEASE:
|
||||
if (packet.getActionType() == 0) {
|
||||
// Followed to the Minecraft Protocol specification outlined at wiki.vg
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, BlockUtils.POSITION_ZERO,
|
||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, BlockUtils.POSITION_ZERO,
|
||||
BlockFace.DOWN);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
}
|
||||
|
@ -359,9 +359,9 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
break;
|
||||
}
|
||||
Vector3f vector = packet.getClickPosition().sub(entity.getPosition());
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
||||
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket interactAtPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamPacket(interactAtPacket);
|
||||
|
@ -372,11 +372,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
|||
if (entity.getEntityType() == EntityType.ENDER_DRAGON) {
|
||||
// Redirects the attack to its body entity, this only happens when
|
||||
// attacking the underbelly of the ender dragon
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId() + 3,
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket((int) entity.getEntityId() + 3,
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
} else {
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.ATTACK, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.bedrock;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.ItemFrameDropItemPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.ItemFrameEntity;
|
||||
|
@ -47,7 +47,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
|
|||
public void translate(GeyserSession session, ItemFrameDropItemPacket packet) {
|
||||
Entity entity = ItemFrameEntity.getItemFrameEntity(session, packet.getBlockPosition());
|
||||
if (entity != null) {
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
}
|
||||
|
|
|
@ -27,10 +27,10 @@ package org.geysermc.connector.network.translators.bedrock;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemOnPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerButtonClickPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerClosePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.LecternUpdatePacket;
|
||||
import org.geysermc.connector.inventory.LecternContainer;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -52,7 +52,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
|||
session.setDroppingLecternBook(true);
|
||||
|
||||
// Emulate an interact packet
|
||||
ClientPlayerPlaceBlockPacket blockPacket = new ClientPlayerPlaceBlockPacket(
|
||||
ServerboundUseItemOnPacket blockPacket = new ServerboundUseItemOnPacket(
|
||||
new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()),
|
||||
BlockFace.DOWN,
|
||||
Hand.MAIN_HAND,
|
||||
|
@ -68,7 +68,7 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
|||
|
||||
if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) {
|
||||
// The same page means Bedrock is closing the window
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(lecternContainer.getId());
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, lecternContainer.getId(), false);
|
||||
} else {
|
||||
|
@ -82,12 +82,12 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
|
|||
// is a byte when transmitted over the network and therefore this stops us at 128
|
||||
if (newJavaPage > currentJavaPage) {
|
||||
for (int i = currentJavaPage; i < newJavaPage; i++) {
|
||||
ClientClickWindowButtonPacket clickButtonPacket = new ClientClickWindowButtonPacket(session.getOpenInventory().getId(), 2);
|
||||
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getId(), 2);
|
||||
session.sendDownstreamPacket(clickButtonPacket);
|
||||
}
|
||||
} else {
|
||||
for (int i = currentJavaPage; i > newJavaPage; i--) {
|
||||
ClientClickWindowButtonPacket clickButtonPacket = new ClientClickWindowButtonPacket(session.getOpenInventory().getId(), 1);
|
||||
ServerboundContainerButtonClickPacket clickButtonPacket = new ServerboundContainerButtonClickPacket(session.getOpenInventory().getId(), 1);
|
||||
session.sendDownstreamPacket(clickButtonPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundSetCarriedItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundUseItemPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobEquipmentPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -54,14 +54,14 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
|
|||
|
||||
session.getPlayerInventory().setHeldItemSlot(packet.getHotbarSlot());
|
||||
|
||||
ClientPlayerChangeHeldItemPacket changeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(packet.getHotbarSlot());
|
||||
session.sendDownstreamPacket(changeHeldItemPacket);
|
||||
ServerboundSetCarriedItemPacket setCarriedItemPacket = new ServerboundSetCarriedItemPacket(packet.getHotbarSlot());
|
||||
session.sendDownstreamPacket(setCarriedItemPacket);
|
||||
|
||||
if (session.isSneaking() && session.getPlayerInventory().getItemInHand().getJavaId() == session.getItemMappings().getStoredItems().shield().getJavaId()) {
|
||||
// Activate shield since we are already sneaking
|
||||
// (No need to send a release item packet - Java doesn't do this when swapping items)
|
||||
// Required to do it a tick later or else it doesn't register
|
||||
session.getConnector().getGeneralThreadPool().schedule(() -> session.sendDownstreamPacket(new ClientPlayerUseItemPacket(Hand.MAIN_HAND)),
|
||||
session.getConnector().getGeneralThreadPool().schedule(() -> session.sendDownstreamPacket(new ServerboundUseItemPacket(Hand.MAIN_HAND)),
|
||||
50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundMoveVehiclePacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.MoveEntityAbsolutePacket;
|
||||
import org.geysermc.connector.entity.BoatEntity;
|
||||
|
@ -66,10 +66,10 @@ public class BedrockMoveEntityAbsoluteTranslator extends PacketTranslator<MoveEn
|
|||
// Remove the offset to prevents boats from looking like they're floating in water
|
||||
y -= EntityType.BOAT.getOffset();
|
||||
}
|
||||
ClientVehicleMovePacket clientVehicleMovePacket = new ClientVehicleMovePacket(
|
||||
ServerboundMoveVehiclePacket ServerboundMoveVehiclePacket = new ServerboundMoveVehiclePacket(
|
||||
packet.getPosition().getX(), y, packet.getPosition().getZ(),
|
||||
packet.getRotation().getY() - 90, packet.getRotation().getX()
|
||||
);
|
||||
session.sendDownstreamPacket(clientVehicleMovePacket);
|
||||
session.sendDownstreamPacket(ServerboundMoveVehiclePacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundKeepAlivePacket;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import com.nukkitx.protocol.bedrock.packet.NetworkStackLatencyPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
|
@ -59,7 +59,7 @@ public class BedrockNetworkStackLatencyTranslator extends PacketTranslator<Netwo
|
|||
// negative timestamps are used as hack to fix the url image loading bug
|
||||
if (packet.getTimestamp() > 0) {
|
||||
if (session.getConnector().getConfig().isForwardPlayerPing()) {
|
||||
ClientKeepAlivePacket keepAlivePacket = new ClientKeepAlivePacket(pingId);
|
||||
ServerboundKeepAlivePacket keepAlivePacket = new ServerboundKeepAlivePacket(pingId);
|
||||
session.sendDownstreamPacket(keepAlivePacket);
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientSteerVehiclePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundPlayerInputPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundMoveVehiclePacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayerInputPacket;
|
||||
|
@ -47,11 +47,11 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
|
|||
|
||||
@Override
|
||||
public void translate(GeyserSession session, PlayerInputPacket packet) {
|
||||
ClientSteerVehiclePacket clientSteerVehiclePacket = new ClientSteerVehiclePacket(
|
||||
ServerboundPlayerInputPacket playerInputPacket = new ServerboundPlayerInputPacket(
|
||||
packet.getInputMotion().getX(), packet.getInputMotion().getY(), packet.isJumping(), packet.isSneaking()
|
||||
);
|
||||
|
||||
session.sendDownstreamPacket(clientSteerVehiclePacket);
|
||||
session.sendDownstreamPacket(playerInputPacket);
|
||||
|
||||
// Bedrock only sends movement vehicle packets while moving
|
||||
// This allows horses to take damage while standing on magma
|
||||
|
@ -82,11 +82,11 @@ public class BedrockPlayerInputTranslator extends PacketTranslator<PlayerInputPa
|
|||
vehiclePosition = vehiclePosition.down(EntityType.BOAT.getOffset());
|
||||
}
|
||||
|
||||
ClientVehicleMovePacket clientVehicleMovePacket = new ClientVehicleMovePacket(
|
||||
ServerboundMoveVehiclePacket moveVehiclePacket = new ServerboundMoveVehiclePacket(
|
||||
vehiclePosition.getX(), vehiclePosition.getY(), vehiclePosition.getZ(),
|
||||
vehicleRotation.getX() - 90, vehicleRotation.getY()
|
||||
);
|
||||
session.sendDownstreamPacket(clientVehicleMovePacket);
|
||||
session.sendDownstreamPacket(moveVehiclePacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.RespawnPacket;
|
||||
|
@ -68,7 +68,7 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
|
|||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientRequest.RESPAWN);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.ClientRequest;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientCommandPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.ShowCreditsPacket;
|
||||
|
||||
@Translator(packet = ShowCreditsPacket.class)
|
||||
|
@ -39,7 +39,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPa
|
|||
@Override
|
||||
public void translate(GeyserSession session, ShowCreditsPacket packet) {
|
||||
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
ServerboundClientCommandPacket javaRespawnPacket = new ServerboundClientCommandPacket(ClientRequest.RESPAWN);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
@Translator(packet = TextPacket.class)
|
||||
|
@ -49,7 +48,7 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
|||
return;
|
||||
}
|
||||
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(message);
|
||||
ServerboundChatPacket chatPacket = new ServerboundChatPacket(message);
|
||||
session.sendDownstreamPacket(chatPacket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.window.VillagerTrade;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientSelectTradePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSelectTradePacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.packet.EntityEventPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
|
@ -51,7 +51,7 @@ public class BedrockEntityEventTranslator extends PacketTranslator<EntityEventPa
|
|||
return;
|
||||
}
|
||||
case COMPLETE_TRADE -> {
|
||||
ClientSelectTradePacket selectTradePacket = new ClientSelectTradePacket(packet.getData());
|
||||
ServerboundSelectTradePacket selectTradePacket = new ServerboundSelectTradePacket(packet.getData());
|
||||
session.sendDownstreamPacket(selectTradePacket);
|
||||
|
||||
session.scheduleInEventLoop(() -> {
|
||||
|
|
|
@ -27,8 +27,8 @@ package org.geysermc.connector.network.translators.bedrock.entity.player;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.*;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.*;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.*;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
|
@ -80,27 +80,27 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
session.sendUpstreamPacket(attributesPacket);
|
||||
break;
|
||||
case START_SWIMMING:
|
||||
ClientPlayerStatePacket startSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
ServerboundPlayerCommandPacket startSwimPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.sendDownstreamPacket(startSwimPacket);
|
||||
|
||||
session.setSwimming(true);
|
||||
break;
|
||||
case STOP_SWIMMING:
|
||||
ClientPlayerStatePacket stopSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
ServerboundPlayerCommandPacket stopSwimPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.sendDownstreamPacket(stopSwimPacket);
|
||||
|
||||
session.setSwimming(false);
|
||||
break;
|
||||
case START_GLIDE:
|
||||
// Otherwise gliding will not work in creative
|
||||
ClientPlayerAbilitiesPacket playerAbilitiesPacket = new ClientPlayerAbilitiesPacket(false);
|
||||
ServerboundPlayerAbilitiesPacket playerAbilitiesPacket = new ServerboundPlayerAbilitiesPacket(false);
|
||||
session.sendDownstreamPacket(playerAbilitiesPacket);
|
||||
case STOP_GLIDE:
|
||||
ClientPlayerStatePacket glidePacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
|
||||
ServerboundPlayerCommandPacket glidePacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
|
||||
session.sendDownstreamPacket(glidePacket);
|
||||
break;
|
||||
case START_SNEAK:
|
||||
ClientPlayerStatePacket startSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
ServerboundPlayerCommandPacket startSneakPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
session.sendDownstreamPacket(startSneakPacket);
|
||||
|
||||
// Toggle the shield, if relevant
|
||||
|
@ -108,12 +108,12 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
ItemMapping shield = session.getItemMappings().getMapping("minecraft:shield");
|
||||
if ((playerInv.getItemInHand().getJavaId() == shield.getJavaId()) ||
|
||||
(playerInv.getOffhand().getJavaId() == shield.getJavaId())) {
|
||||
ClientPlayerUseItemPacket useItemPacket;
|
||||
ServerboundUseItemPacket useItemPacket;
|
||||
if (playerInv.getItemInHand().getJavaId() == shield.getJavaId()) {
|
||||
useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
useItemPacket = new ServerboundUseItemPacket(Hand.MAIN_HAND);
|
||||
} else {
|
||||
// Else we just assume it's the offhand, to simplify logic and to assure the packet gets sent
|
||||
useItemPacket = new ClientPlayerUseItemPacket(Hand.OFF_HAND);
|
||||
useItemPacket = new ServerboundUseItemPacket(Hand.OFF_HAND);
|
||||
}
|
||||
session.sendDownstreamPacket(useItemPacket);
|
||||
session.getPlayerEntity().getMetadata().getFlags().setFlag(EntityFlag.BLOCKING, true);
|
||||
|
@ -123,12 +123,12 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
session.setSneaking(true);
|
||||
break;
|
||||
case STOP_SNEAK:
|
||||
ClientPlayerStatePacket stopSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING);
|
||||
ServerboundPlayerCommandPacket stopSneakPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING);
|
||||
session.sendDownstreamPacket(stopSneakPacket);
|
||||
|
||||
// Stop shield, if necessary
|
||||
if (session.getPlayerEntity().getMetadata().getFlags().getFlag(EntityFlag.BLOCKING)) {
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, BlockUtils.POSITION_ZERO, BlockFace.DOWN);
|
||||
ServerboundPlayerActionPacket releaseItemPacket = new ServerboundPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, BlockUtils.POSITION_ZERO, BlockFace.DOWN);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
session.getPlayerEntity().getMetadata().getFlags().setFlag(EntityFlag.BLOCKING, false);
|
||||
// metadata will be updated when sneaking
|
||||
|
@ -137,21 +137,21 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
session.setSneaking(false);
|
||||
break;
|
||||
case START_SPRINT:
|
||||
ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
ServerboundPlayerCommandPacket startSprintPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.sendDownstreamPacket(startSprintPacket);
|
||||
session.setSprinting(true);
|
||||
break;
|
||||
case STOP_SPRINT:
|
||||
ClientPlayerStatePacket stopSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
ServerboundPlayerCommandPacket stopSprintPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.sendDownstreamPacket(stopSprintPacket);
|
||||
session.setSprinting(false);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
ClientPlayerActionPacket dropItemPacket = new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]);
|
||||
ServerboundPlayerActionPacket dropItemPacket = new ServerboundPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]);
|
||||
session.sendDownstreamPacket(dropItemPacket);
|
||||
break;
|
||||
case STOP_SLEEP:
|
||||
ClientPlayerStatePacket stopSleepingPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.LEAVE_BED);
|
||||
ServerboundPlayerCommandPacket stopSleepingPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.LEAVE_BED);
|
||||
session.sendDownstreamPacket(stopSleepingPacket);
|
||||
break;
|
||||
case BLOCK_INTERACT:
|
||||
|
@ -180,7 +180,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
int blockUp = session.getConnector().getWorldManager().getBlockAt(session, fireBlockPos);
|
||||
String identifier = BlockRegistries.JAVA_IDENTIFIERS.get().get(blockUp);
|
||||
if (identifier.startsWith("minecraft:fire") || identifier.startsWith("minecraft:soul_fire")) {
|
||||
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(fireBlockPos.getX(),
|
||||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, new Position(fireBlockPos.getX(),
|
||||
fireBlockPos.getY(), fireBlockPos.getZ()), BlockFace.values()[packet.getFace()]);
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
if (session.getGameMode() == GameMode.CREATIVE) {
|
||||
|
@ -188,7 +188,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
}
|
||||
}
|
||||
|
||||
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, position, BlockFace.values()[packet.getFace()]);
|
||||
ServerboundPlayerActionPacket startBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, position, BlockFace.values()[packet.getFace()]);
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
break;
|
||||
case CONTINUE_BREAK:
|
||||
|
@ -216,14 +216,14 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
|||
// Survival also sends START_BREAK, but by attaching our process here adventure mode also works
|
||||
Entity itemFrameEntity = ItemFrameEntity.getItemFrameEntity(session, packet.getBlockPosition());
|
||||
if (itemFrameEntity != null) {
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) itemFrameEntity.getEntityId(),
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket((int) itemFrameEntity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, position, BlockFace.DOWN);
|
||||
ServerboundPlayerActionPacket abortBreakingPacket = new ServerboundPlayerActionPacket(PlayerAction.CANCEL_DIGGING, position, BlockFace.DOWN);
|
||||
session.sendDownstreamPacket(abortBreakingPacket);
|
||||
LevelEventPacket stopBreak = new LevelEventPacket();
|
||||
stopBreak.setType(LevelEventType.BLOCK_STOP_BREAK);
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.bedrock.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.BlockFace;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerActionPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.EmotePacket;
|
||||
import org.geysermc.connector.configuration.EmoteOffhandWorkaroundOption;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
|
@ -43,7 +43,7 @@ public class BedrockEmoteTranslator extends PacketTranslator<EmotePacket> {
|
|||
public void translate(GeyserSession session, EmotePacket packet) {
|
||||
if (session.getConnector().getConfig().getEmoteOffhandWorkaround() != EmoteOffhandWorkaroundOption.DISABLED) {
|
||||
// Activate the workaround - we should trigger the offhand now
|
||||
ClientPlayerActionPacket swapHandsPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, BlockUtils.POSITION_ZERO,
|
||||
ServerboundPlayerActionPacket swapHandsPacket = new ServerboundPlayerActionPacket(PlayerAction.SWAP_HANDS, BlockUtils.POSITION_ZERO,
|
||||
BlockFace.DOWN);
|
||||
session.sendDownstreamPacket(swapHandsPacket);
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ package org.geysermc.connector.network.translators.bedrock.entity.player;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundInteractPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
|
@ -62,17 +62,17 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||
if (session.getPlayerInventory().getItemInHand().getJavaId() == session.getItemMappings().getStoredItems().shield().getJavaId()) {
|
||||
break;
|
||||
}
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket interactPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
break;
|
||||
case DAMAGE:
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
ServerboundInteractPacket attackPacket = new ServerboundInteractPacket((int) entity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND, session.isSneaking());
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
break;
|
||||
case LEAVE_VEHICLE:
|
||||
ClientPlayerStatePacket sneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
ServerboundPlayerCommandPacket sneakPacket = new ServerboundPlayerCommandPacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
session.sendDownstreamPacket(sneakPacket);
|
||||
session.setRidingVehicleEntity(null);
|
||||
break;
|
||||
|
@ -101,7 +101,7 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
|||
if (ridingEntity instanceof AbstractHorseEntity) {
|
||||
if (ridingEntity.getMetadata().getFlags().getFlag(EntityFlag.TAMED)) {
|
||||
// We should request to open the horse inventory instead
|
||||
ClientPlayerStatePacket openHorseWindowPacket = new ClientPlayerStatePacket((int) session.getPlayerEntity().getEntityId(), PlayerState.OPEN_HORSE_INVENTORY);
|
||||
ServerboundPlayerCommandPacket openHorseWindowPacket = new ServerboundPlayerCommandPacket((int) session.getPlayerEntity().getEntityId(), PlayerState.OPEN_HORSE_INVENTORY);
|
||||
session.sendDownstreamPacket(openHorseWindowPacket);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.bedrock.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerPosRotPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerRotPacket;
|
||||
import com.github.steveice10.packetlib.packet.Packet;
|
||||
import com.nukkitx.math.vector.Vector3d;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
@ -81,7 +81,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
|||
// This isn't needed, but it makes the packets closer to vanilla
|
||||
// It also means you can't "lag back" while only looking, in theory
|
||||
if (!positionChanged && rotationChanged) {
|
||||
ClientPlayerRotationPacket playerRotationPacket = new ClientPlayerRotationPacket(
|
||||
ServerboundMovePlayerRotPacket playerRotationPacket = new ServerboundMovePlayerRotPacket(
|
||||
packet.isOnGround(), packet.getRotation().getY(), packet.getRotation().getX());
|
||||
|
||||
entity.setRotation(rotation);
|
||||
|
@ -99,12 +99,12 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
|||
Packet movePacket;
|
||||
if (rotationChanged) {
|
||||
// Send rotation updates as well
|
||||
movePacket = new ClientPlayerPositionRotationPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ(),
|
||||
movePacket = new ServerboundMovePlayerPosRotPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ(),
|
||||
packet.getRotation().getY(), packet.getRotation().getX());
|
||||
entity.setRotation(rotation);
|
||||
} else {
|
||||
// Rotation did not change; don't send an update with rotation
|
||||
movePacket = new ClientPlayerPositionPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ());
|
||||
movePacket = new ServerboundMovePlayerPosPacket(packet.isOnGround(), position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
// Compare positions here for void floor fix below before the player's position variable is set to the packet position
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.bedrock.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.player.ServerboundPlayerCommandPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.RiderJumpPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.living.animal.horse.AbstractHorseEntity;
|
||||
|
@ -40,8 +40,8 @@ public class BedrockRiderJumpTranslator extends PacketTranslator<RiderJumpPacket
|
|||
public void translate(GeyserSession session, RiderJumpPacket packet) {
|
||||
Entity vehicle = session.getRidingVehicleEntity();
|
||||
if (vehicle instanceof AbstractHorseEntity) {
|
||||
ClientPlayerStatePacket playerStatePacket = new ClientPlayerStatePacket((int) vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength());
|
||||
session.sendDownstreamPacket(playerStatePacket);
|
||||
ServerboundPlayerCommandPacket playerCommandPacket = new ServerboundPlayerCommandPacket((int) vehicle.getEntityId(), PlayerState.START_HORSE_JUMP, packet.getJumpStrength());
|
||||
session.sendDownstreamPacket(playerCommandPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelEventPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
||||
/**
|
||||
|
@ -33,10 +33,10 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
*/
|
||||
public interface Effect {
|
||||
/**
|
||||
* Translates the given {@link ServerPlayEffectPacket} into bedrock and sends it upstream.
|
||||
* Translates the given {@link ClientboundLevelEventPacket} into bedrock and sends it upstream.
|
||||
*
|
||||
* @param session GeyserSession
|
||||
* @param packet the effect packet to handle
|
||||
*/
|
||||
void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet);
|
||||
void handleEffectPacket(GeyserSession session, ClientboundLevelEventPacket packet);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelEventPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlaySoundPacket;
|
||||
import lombok.Value;
|
||||
|
@ -68,7 +68,7 @@ public class PlaySoundEffect implements Effect {
|
|||
boolean relative;
|
||||
|
||||
@Override
|
||||
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
|
||||
public void handleEffectPacket(GeyserSession session, ClientboundLevelEventPacket packet) {
|
||||
Random rand = ThreadLocalRandom.current();
|
||||
PlaySoundPacket playSoundPacket = new PlaySoundPacket();
|
||||
playSoundPacket.setSound(name);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelEventPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
|
@ -50,7 +50,7 @@ public class SoundEventEffect implements Effect {
|
|||
int extraData;
|
||||
|
||||
@Override
|
||||
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
|
||||
public void handleEffectPacket(GeyserSession session, ClientboundLevelEventPacket packet) {
|
||||
LevelSoundEventPacket levelSoundEvent = new LevelSoundEventPacket();
|
||||
levelSoundEvent.setSound(soundEvent);
|
||||
levelSoundEvent.setIdentifier(identifier);
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.effect;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundLevelEventPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
|
@ -45,7 +45,7 @@ public class SoundLevelEffect implements Effect {
|
|||
int data;
|
||||
|
||||
@Override
|
||||
public void handleEffectPacket(GeyserSession session, ServerPlayEffectPacket packet) {
|
||||
public void handleEffectPacket(GeyserSession session, ClientboundLevelEventPacket packet) {
|
||||
LevelEventPacket eventPacket = new LevelEventPacket();
|
||||
eventPacket.setType(levelEventType);
|
||||
eventPacket.setData(data);
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.inventory.click;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowAction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerClickPacket;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
|
@ -122,7 +122,7 @@ public class ClickPlan {
|
|||
affectedSlots.put(simulatedSlot.getIntKey(), simulatedSlot.getValue().getItemStack());
|
||||
}
|
||||
|
||||
ClientWindowActionPacket clickPacket = new ClientWindowActionPacket(
|
||||
ServerboundContainerClickPacket clickPacket = new ServerboundContainerClickPacket(
|
||||
inventory.getId(),
|
||||
inventory.getStateId(),
|
||||
action.slot,
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientSetBeaconEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSetBeaconPacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
@ -114,7 +114,7 @@ public class BeaconInventoryTranslator extends AbstractBlockInventoryTranslator
|
|||
public ItemStackResponsePacket.Response translateSpecialRequest(GeyserSession session, Inventory inventory, ItemStackRequest request) {
|
||||
// Input a beacon payment
|
||||
BeaconPaymentStackRequestActionData beaconPayment = (BeaconPaymentStackRequestActionData) request.getActions()[0];
|
||||
ClientSetBeaconEffectPacket packet = new ClientSetBeaconEffectPacket(beaconPayment.getPrimaryEffect(), beaconPayment.getSecondaryEffect());
|
||||
ServerboundSetBeaconPacket packet = new ServerboundSetBeaconPacket(beaconPayment.getPrimaryEffect(), beaconPayment.getSecondaryEffect());
|
||||
session.sendDownstreamPacket(packet);
|
||||
return acceptRequest(request, makeContainerEntries(session, inventory, Collections.emptySet()));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerButtonClickPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.*;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.CraftRecipeStackRequestActionData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.StackRequestActionData;
|
||||
|
@ -128,7 +128,7 @@ public class EnchantingInventoryTranslator extends AbstractBlockInventoryTransla
|
|||
// Slot should be determined as 0, 1, or 2
|
||||
return rejectRequest(request);
|
||||
}
|
||||
ClientClickWindowButtonPacket packet = new ClientClickWindowButtonPacket(inventory.getId(), javaSlot);
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), javaSlot);
|
||||
session.sendDownstreamPacket(packet);
|
||||
return acceptRequest(request, makeContainerEntries(session, inventory, Collections.emptySet()));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerButtonClickPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerClosePacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
|
@ -99,7 +99,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||
LecternContainer lecternContainer = (LecternContainer) inventory;
|
||||
if (session.isDroppingLecternBook()) {
|
||||
// We have to enter the inventory GUI to eject the book
|
||||
ClientClickWindowButtonPacket packet = new ClientClickWindowButtonPacket(inventory.getId(), 3);
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), 3);
|
||||
session.sendDownstreamPacket(packet);
|
||||
session.setDroppingLecternBook(false);
|
||||
InventoryUtils.closeInventory(session, inventory.getId(), false);
|
||||
|
@ -150,7 +150,7 @@ public class LecternInventoryTranslator extends BaseInventoryTranslator {
|
|||
BlockEntityUtils.updateBlockEntity(session, blockEntityTag, position);
|
||||
session.getLecternCache().add(position);
|
||||
// Close the window - we will reopen it once the client has this data synced
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(lecternContainer.getId());
|
||||
ServerboundContainerClosePacket closeWindowPacket = new ServerboundContainerClosePacket(lecternContainer.getId());
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, inventory.getId(), false);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.inventory.translators;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerButtonClickPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
|
@ -154,7 +154,7 @@ public class LoomInventoryTranslator extends AbstractBlockInventoryTranslator {
|
|||
// Java's formula: 4 * row + col
|
||||
// And the Java loom window has a fixed row/width of four
|
||||
// So... Number / 4 = row (so we don't have to bother there), and number % 4 is our column, which leads us back to our index. :)
|
||||
ClientClickWindowButtonPacket packet = new ClientClickWindowButtonPacket(inventory.getId(), index);
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), index);
|
||||
session.sendDownstreamPacket(packet);
|
||||
|
||||
GeyserItemStack inputCopy = inventory.getItem(0).copy(1);
|
||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.connector.network.translators.inventory.translators;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundSetCreativeModeSlotPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.*;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.stackrequestactions.*;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
|
||||
|
@ -327,7 +327,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
return rejectRequest(request);
|
||||
}
|
||||
|
||||
ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, sourceItem.getItemStack(dropAction.getCount()));
|
||||
ServerboundSetCreativeModeSlotPacket creativeDropPacket = new ServerboundSetCreativeModeSlotPacket(-1, sourceItem.getItemStack(dropAction.getCount()));
|
||||
session.sendDownstreamPacket(creativeDropPacket);
|
||||
|
||||
sourceItem.sub(dropAction.getCount());
|
||||
|
@ -456,7 +456,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
|||
GeyserItemStack item = inventory.getItem(slot);
|
||||
ItemStack itemStack = item.isEmpty() ? new ItemStack(-1, 0, null) : item.getItemStack();
|
||||
|
||||
ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(slot, itemStack);
|
||||
ServerboundSetCreativeModeSlotPacket creativePacket = new ServerboundSetCreativeModeSlotPacket(slot, itemStack);
|
||||
session.sendDownstreamPacket(creativePacket);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.inventory.translators;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||
import com.github.steveice10.mc.protocol.data.game.window.WindowType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.window.ServerboundContainerButtonClickPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerSlotType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ContainerType;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemStackRequest;
|
||||
|
@ -79,7 +79,7 @@ public class StonecutterInventoryTranslator extends AbstractBlockInventoryTransl
|
|||
// If we've already pressed the button with this item, no need to press it again!
|
||||
if (container.getStonecutterButton() != button) {
|
||||
// Getting the index of the item in the Java stonecutter list
|
||||
ClientClickWindowButtonPacket packet = new ClientClickWindowButtonPacket(inventory.getId(), button);
|
||||
ServerboundContainerButtonClickPacket packet = new ServerboundContainerButtonClickPacket(inventory.getId(), button);
|
||||
session.sendDownstreamPacket(packet);
|
||||
container.setStonecutterButton(button);
|
||||
if (inventory.getItem(1).getJavaId() != javaOutput.getId()) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementTabPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSelectAdvancementsTabPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.session.cache.AdvancementsCache;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -34,10 +34,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
/**
|
||||
* Indicates that the client should open a particular advancement tab
|
||||
*/
|
||||
@Translator(packet = ServerAdvancementTabPacket.class)
|
||||
public class JavaAdvancementsTabTranslator extends PacketTranslator<ServerAdvancementTabPacket> {
|
||||
@Translator(packet = ClientboundSelectAdvancementsTabPacket.class)
|
||||
public class JavaAdvancementsTabTranslator extends PacketTranslator<ClientboundSelectAdvancementsTabPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerAdvancementTabPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSelectAdvancementsTabPacket packet) {
|
||||
AdvancementsCache advancementsCache = session.getAdvancementsCache();
|
||||
advancementsCache.setCurrentAdvancementCategoryId(packet.getTabId());
|
||||
advancementsCache.buildAndShowListForm();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateAdvancementsPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetTitlePacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -38,11 +38,11 @@ import org.geysermc.connector.utils.LocaleUtils;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
@Translator(packet = ServerAdvancementsPacket.class)
|
||||
public class JavaAdvancementsTranslator extends PacketTranslator<ServerAdvancementsPacket> {
|
||||
@Translator(packet = ClientboundUpdateAdvancementsPacket.class)
|
||||
public class JavaAdvancementsTranslator extends PacketTranslator<ClientboundUpdateAdvancementsPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerAdvancementsPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundUpdateAdvancementsPacket packet) {
|
||||
AdvancementsCache advancementsCache = session.getAdvancementsCache();
|
||||
if (packet.isReset()) {
|
||||
advancementsCache.getStoredAdvancements().clear();
|
||||
|
@ -72,7 +72,7 @@ public class JavaAdvancementsTranslator extends PacketTranslator<ServerAdvanceme
|
|||
/**
|
||||
* Handle all advancements progress updates
|
||||
*/
|
||||
public void sendToolbarAdvancementUpdates(GeyserSession session, ServerAdvancementsPacket packet) {
|
||||
public void sendToolbarAdvancementUpdates(GeyserSession session, ClientboundUpdateAdvancementsPacket packet) {
|
||||
if (packet.isReset()) {
|
||||
// Advancements are being cleared, so they can't be granted
|
||||
return;
|
||||
|
|
|
@ -30,12 +30,12 @@ import org.geysermc.connector.network.session.cache.BossBar;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerBossBarPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundBossEventPacket;
|
||||
|
||||
@Translator(packet = ServerBossBarPacket.class)
|
||||
public class JavaBossBarTranslator extends PacketTranslator<ServerBossBarPacket> {
|
||||
@Translator(packet = ClientboundBossEventPacket.class)
|
||||
public class JavaBossBarTranslator extends PacketTranslator<ClientboundBossEventPacket> {
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerBossBarPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundBossEventPacket packet) {
|
||||
BossBar bossBar = session.getEntityCache().getBossBar(packet.getUuid());
|
||||
switch (packet.getAction()) {
|
||||
case ADD:
|
||||
|
|
|
@ -25,18 +25,18 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChatPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TextPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
@Translator(packet = ServerChatPacket.class)
|
||||
public class JavaChatTranslator extends PacketTranslator<ServerChatPacket> {
|
||||
@Translator(packet = ClientboundChatPacket.class)
|
||||
public class JavaChatTranslator extends PacketTranslator<ClientboundChatPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerChatPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundChatPacket packet) {
|
||||
TextPacket textPacket = new TextPacket();
|
||||
textPacket.setPlatformChatId("");
|
||||
textPacket.setSourceName("");
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.java;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.command.CommandNode;
|
||||
import com.github.steveice10.mc.protocol.data.game.command.CommandParser;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareCommandsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandsPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandEnumData;
|
||||
import com.nukkitx.protocol.bedrock.data.command.CommandParam;
|
||||
|
@ -53,8 +53,8 @@ import org.geysermc.connector.utils.EntityUtils;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
@Translator(packet = ServerDeclareCommandsPacket.class)
|
||||
public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclareCommandsPacket> {
|
||||
@Translator(packet = ClientboundCommandsPacket.class)
|
||||
public class JavaDeclareCommandsTranslator extends PacketTranslator<ClientboundCommandsPacket> {
|
||||
|
||||
private static final String[] ALL_EFFECT_IDENTIFIERS = EntityUtils.getAllEffectIdentifiers();
|
||||
private static final String[] ENUM_BOOLEAN = {"true", "false"};
|
||||
|
@ -98,7 +98,7 @@ public class JavaDeclareCommandsTranslator extends PacketTranslator<ServerDeclar
|
|||
}
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerDeclareCommandsPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundCommandsPacket packet) {
|
||||
// Don't send command suggestions if they are disabled
|
||||
if (!session.getConnector().getConfig().isCommandSuggestions()) {
|
||||
session.getConnector().getLogger().debug("Not sending translated command suggestions as they are disabled.");
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.github.steveice10.mc.protocol.data.game.recipe.RecipeType;
|
|||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapedRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.ShapelessRecipeData;
|
||||
import com.github.steveice10.mc.protocol.data.game.recipe.data.StoneCuttingRecipeData;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareRecipesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateRecipesPacket;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.CraftingData;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
|
@ -58,8 +58,8 @@ import static org.geysermc.connector.utils.InventoryUtils.LAST_RECIPE_NET_ID;
|
|||
*
|
||||
* Bedrock REQUIRES a CraftingDataPacket to be sent in order to craft anything.
|
||||
*/
|
||||
@Translator(packet = ServerDeclareRecipesPacket.class)
|
||||
public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclareRecipesPacket> {
|
||||
@Translator(packet = ClientboundUpdateRecipesPacket.class)
|
||||
public class JavaDeclareRecipesTranslator extends PacketTranslator<ClientboundUpdateRecipesPacket> {
|
||||
/**
|
||||
* Required to use the specified cartography table recipes
|
||||
*/
|
||||
|
@ -71,7 +71,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
|
|||
);
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerDeclareRecipesPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundUpdateRecipesPacket packet) {
|
||||
Map<RecipeType, List<CraftingData>> recipeTypes = Registries.CRAFTING_DATA.forVersion(session.getUpstream().getProtocolVersion());
|
||||
// Get the last known network ID (first used for the pregenerated recipes) and increment from there.
|
||||
int netId = InventoryUtils.LAST_RECIPE_NET_ID + 1;
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareTagsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundUpdateTagsPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerDeclareTagsPacket.class)
|
||||
public class JavaDeclareTagsTranslator extends PacketTranslator<ServerDeclareTagsPacket> {
|
||||
@Translator(packet = ClientboundUpdateTagsPacket.class)
|
||||
public class JavaDeclareTagsTranslator extends PacketTranslator<ClientboundUpdateTagsPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerDeclareTagsPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundUpdateTagsPacket packet) {
|
||||
session.getTagCache().loadPacket(packet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,18 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundChangeDifficultyPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDifficultyPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetDifficultyPacket;
|
||||
|
||||
@Translator(packet = ServerDifficultyPacket.class)
|
||||
public class JavaDifficultyTranslator extends PacketTranslator<ServerDifficultyPacket> {
|
||||
@Translator(packet = ClientboundChangeDifficultyPacket.class)
|
||||
public class JavaDifficultyTranslator extends PacketTranslator<ClientboundChangeDifficultyPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerDifficultyPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundChangeDifficultyPacket packet) {
|
||||
SetDifficultyPacket setDifficultyPacket = new SetDifficultyPacket();
|
||||
setDifficultyPacket.setDifficulty(packet.getDifficulty().ordinal());
|
||||
session.sendUpstreamPacket(setDifficultyPacket);
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDisconnectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundDisconnectPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
@Translator(packet = ServerDisconnectPacket.class)
|
||||
public class JavaDisconnectPacket extends PacketTranslator<ServerDisconnectPacket> {
|
||||
@Translator(packet = ClientboundDisconnectPacket.class)
|
||||
public class JavaDisconnectPacket extends PacketTranslator<ClientboundDisconnectPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerDisconnectPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundDisconnectPacket packet) {
|
||||
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginSuccessPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundGameProfilePacket;
|
||||
import org.geysermc.connector.common.AuthType;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -34,11 +34,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.skin.SkinManager;
|
||||
|
||||
@Translator(packet = LoginSuccessPacket.class)
|
||||
public class JavaLoginSuccessTranslator extends PacketTranslator<LoginSuccessPacket> {
|
||||
@Translator(packet = ClientboundGameProfilePacket.class)
|
||||
public class JavaGameProfileTranslator extends PacketTranslator<ClientboundGameProfilePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, LoginSuccessPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundGameProfilePacket packet) {
|
||||
PlayerEntity playerEntity = session.getPlayerEntity();
|
||||
AuthType remoteAuthType = session.getRemoteAuthType();
|
||||
|
|
@ -28,9 +28,9 @@ package org.geysermc.connector.network.translators.java;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.HandPreference;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.SkinPart;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientSettingsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundClientInformationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.GameRuleData;
|
||||
import com.nukkitx.protocol.bedrock.data.PlayerPermission;
|
||||
import com.nukkitx.protocol.bedrock.packet.*;
|
||||
|
@ -47,12 +47,12 @@ import org.geysermc.connector.utils.PluginMessageUtils;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Translator(packet = ServerJoinGamePacket.class)
|
||||
public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacket> {
|
||||
@Translator(packet = ClientboundLoginPacket.class)
|
||||
public class JavaJoinGameTranslator extends PacketTranslator<ClientboundLoginPacket> {
|
||||
private static final List<SkinPart> SKIN_PART_VALUES = Arrays.asList(SkinPart.values());
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerJoinGamePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundLoginPacket packet) {
|
||||
PlayerEntity entity = session.getPlayerEntity();
|
||||
entity.setEntityId(packet.getEntityId());
|
||||
|
||||
|
@ -100,14 +100,14 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
|||
|
||||
// We need to send our skin parts to the server otherwise java sees us with no hat, jacket etc
|
||||
String locale = session.getLocale();
|
||||
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, SKIN_PART_VALUES, HandPreference.RIGHT_HAND, false);
|
||||
session.sendDownstreamPacket(clientSettingsPacket);
|
||||
ServerboundClientInformationPacket infoPacket = new ServerboundClientInformationPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, SKIN_PART_VALUES, HandPreference.RIGHT_HAND, false);
|
||||
session.sendDownstreamPacket(infoPacket);
|
||||
|
||||
session.sendDownstreamPacket(new ClientPluginMessagePacket("minecraft:brand", PluginMessageUtils.getGeyserBrandData()));
|
||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:brand", PluginMessageUtils.getGeyserBrandData()));
|
||||
|
||||
// register the plugin messaging channels used in Floodgate
|
||||
if (session.getRemoteAuthType() == AuthType.FLOODGATE) {
|
||||
session.sendDownstreamPacket(new ClientPluginMessagePacket("minecraft:register", PluginMessageUtils.getFloodgateRegisterData()));
|
||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket("minecraft:register", PluginMessageUtils.getFloodgateRegisterData()));
|
||||
}
|
||||
|
||||
if (!newDimension.equals(session.getDimension())) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundKeepAlivePacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.NetworkStackLatencyPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -34,11 +34,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
/**
|
||||
* Used to forward the keep alive packet to the client in order to get back a reliable ping.
|
||||
*/
|
||||
@Translator(packet = ServerKeepAlivePacket.class)
|
||||
public class JavaKeepAliveTranslator extends PacketTranslator<ServerKeepAlivePacket> {
|
||||
@Translator(packet = ClientboundKeepAlivePacket.class)
|
||||
public class JavaKeepAliveTranslator extends PacketTranslator<ClientboundKeepAlivePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerKeepAlivePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundKeepAlivePacket packet) {
|
||||
if (!session.getConnector().getConfig().isForwardPlayerPing()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginDisconnectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundLoginDisconnectPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||
|
||||
@Translator(packet = LoginDisconnectPacket.class)
|
||||
public class JavaLoginDisconnectTranslator extends PacketTranslator<LoginDisconnectPacket> {
|
||||
@Translator(packet = ClientboundLoginDisconnectPacket.class)
|
||||
public class JavaLoginDisconnectTranslator extends PacketTranslator<ClientboundLoginDisconnectPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, LoginDisconnectPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundLoginDisconnectPacket packet) {
|
||||
// The client doesn't manually get disconnected so we have to do it ourselves
|
||||
session.disconnect(MessageTranslator.convertMessage(packet.getReason(), session.getLocale()));
|
||||
}
|
||||
|
|
|
@ -25,21 +25,20 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.login.clientbound.ClientboundCustomQueryPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.serverbound.ServerboundCustomQueryPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.login.client.LoginPluginResponsePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.login.server.LoginPluginRequestPacket;
|
||||
|
||||
@Translator(packet = LoginPluginRequestPacket.class)
|
||||
public class JavaLoginPluginRequestTranslator extends PacketTranslator<LoginPluginRequestPacket> {
|
||||
@Translator(packet = ClientboundCustomQueryPacket.class)
|
||||
public class JavaLoginPluginRequestTranslator extends PacketTranslator<ClientboundCustomQueryPacket> {
|
||||
@Override
|
||||
public void translate(GeyserSession session, LoginPluginRequestPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundCustomQueryPacket packet) {
|
||||
// A vanilla client doesn't know any PluginMessage in the Login state, so we don't know any either.
|
||||
// Note: Fabric Networking API v1 will not let the client log in without sending this
|
||||
session.sendDownstreamPacket(
|
||||
new LoginPluginResponsePacket(packet.getMessageId(), null)
|
||||
new ServerboundCustomQueryPacket(packet.getMessageId(), null)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,18 +25,18 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPongPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPingPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundPongPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPingPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
// Why does this packet exist? Whatever, we better implement it
|
||||
@Translator(packet = ServerPingPacket.class)
|
||||
public class JavaPingPacket extends PacketTranslator<ServerPingPacket> {
|
||||
@Translator(packet = ClientboundPingPacket.class)
|
||||
public class JavaPingPacket extends PacketTranslator<ClientboundPingPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPingPacket packet) {
|
||||
session.sendDownstreamPacket(new ClientPongPacket(packet.getId()));
|
||||
public void translate(GeyserSession session, ClientboundPingPacket packet) {
|
||||
session.sendDownstreamPacket(new ServerboundPongPacket(packet.getId()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundCustomPayloadPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCustomPayloadPacket;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.nukkitx.protocol.bedrock.packet.TransferPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
@ -41,12 +41,12 @@ import org.geysermc.cumulus.util.FormType;
|
|||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Translator(packet = ServerPluginMessagePacket.class)
|
||||
public class JavaPluginMessageTranslator extends PacketTranslator<ServerPluginMessagePacket> {
|
||||
@Translator(packet = ClientboundCustomPayloadPacket.class)
|
||||
public class JavaPluginMessageTranslator extends PacketTranslator<ClientboundCustomPayloadPacket> {
|
||||
private final GeyserLogger logger = GeyserConnector.getInstance().getLogger();
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPluginMessagePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundCustomPayloadPacket packet) {
|
||||
// The only plugin messages it has to listen for are Floodgate plugin messages
|
||||
if (session.getRemoteAuthType() != AuthType.FLOODGATE) {
|
||||
return;
|
||||
|
@ -77,7 +77,7 @@ public class JavaPluginMessageTranslator extends PacketTranslator<ServerPluginMe
|
|||
finalData[1] = data[2];
|
||||
System.arraycopy(raw, 0, finalData, 2, raw.length);
|
||||
|
||||
session.sendDownstreamPacket(new ClientPluginMessagePacket(channel, finalData));
|
||||
session.sendDownstreamPacket(new ServerboundCustomPayloadPacket(channel, finalData));
|
||||
});
|
||||
session.sendForm(form);
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.UnlockRecipesAction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerUnlockRecipesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRecipePacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
@ -36,11 +36,11 @@ import java.util.Arrays;
|
|||
/**
|
||||
* Used to list recipes that we can definitely use the recipe book for (and therefore save on packet usage)
|
||||
*/
|
||||
@Translator(packet = ServerUnlockRecipesPacket.class)
|
||||
public class JavaUnlockRecipesTranslator extends PacketTranslator<ServerUnlockRecipesPacket> {
|
||||
@Translator(packet = ClientboundRecipePacket.class)
|
||||
public class JavaRecipeTranslator extends PacketTranslator<ClientboundRecipePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerUnlockRecipesPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundRecipePacket packet) {
|
||||
if (packet.getAction() == UnlockRecipesAction.REMOVE) {
|
||||
session.getUnlockedRecipes().removeAll(Arrays.asList(packet.getRecipes()));
|
||||
} else {
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundRespawnPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
|
@ -39,11 +39,11 @@ import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
|||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
import org.geysermc.connector.utils.DimensionUtils;
|
||||
|
||||
@Translator(packet = ServerRespawnPacket.class)
|
||||
public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket> {
|
||||
@Translator(packet = ClientboundRespawnPacket.class)
|
||||
public class JavaRespawnTranslator extends PacketTranslator<ClientboundRespawnPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerRespawnPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundRespawnPacket packet) {
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
|
||||
entity.setHealth(entity.getMaxHealth());
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerStatisticsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundAwardStatsPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.StatisticsUtils;
|
||||
|
||||
@Translator(packet = ServerStatisticsPacket.class)
|
||||
public class JavaStatisticsTranslator extends PacketTranslator<ServerStatisticsPacket> {
|
||||
@Translator(packet = ClientboundAwardStatsPacket.class)
|
||||
public class JavaStatisticsTranslator extends PacketTranslator<ClientboundAwardStatsPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerStatisticsPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAwardStatsPacket packet) {
|
||||
session.updateStatistics(packet.getStatistics());
|
||||
|
||||
if (session.isWaitingForStatistics()) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityAnimationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundAnimatePacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.AnimateEntityPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.AnimatePacket;
|
||||
|
@ -36,11 +36,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.DimensionUtils;
|
||||
|
||||
@Translator(packet = ServerEntityAnimationPacket.class)
|
||||
public class JavaEntityAnimationTranslator extends PacketTranslator<ServerEntityAnimationPacket> {
|
||||
@Translator(packet = ClientboundAnimatePacket.class)
|
||||
public class JavaEntityAnimationTranslator extends PacketTranslator<ClientboundAnimatePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityAnimationPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAnimatePacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
@ -56,7 +56,7 @@ public class JavaEntityAnimationTranslator extends PacketTranslator<ServerEntity
|
|||
case SWING_ARM:
|
||||
animatePacket.setAction(AnimatePacket.Action.SWING_ARM);
|
||||
break;
|
||||
case EAT_FOOD: // ACTUALLY SWING OFF HAND
|
||||
case SWING_OFFHAND:
|
||||
// Use the OptionalPack to trigger the animation
|
||||
AnimateEntityPacket offHandPacket = new AnimateEntityPacket();
|
||||
offHandPacket.setAnimation("animation.player.attack.rotations.offhand");
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityLinkPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityFlag;
|
||||
|
@ -38,11 +38,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
/**
|
||||
* Called when a leash is attached, removed or updated from an entity
|
||||
*/
|
||||
@Translator(packet = ServerEntityAttachPacket.class)
|
||||
public class JavaEntityAttachTranslator extends PacketTranslator<ServerEntityAttachPacket> {
|
||||
@Translator(packet = ClientboundSetEntityLinkPacket.class)
|
||||
public class JavaEntityAttachTranslator extends PacketTranslator<ClientboundSetEntityLinkPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityAttachPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetEntityLinkPacket packet) {
|
||||
|
||||
Entity holderId;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityCollectItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTakeItemEntityPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.TakeItemEntityPacket;
|
||||
|
@ -40,11 +40,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
* In Java, this is called for item entities, experience orbs and arrows
|
||||
* Bedrock uses it for arrows and item entities, but not experience orbs.
|
||||
*/
|
||||
@Translator(packet = ServerEntityCollectItemPacket.class)
|
||||
public class JavaEntityCollectItemTranslator extends PacketTranslator<ServerEntityCollectItemPacket> {
|
||||
@Translator(packet = ClientboundTakeItemEntityPacket.class)
|
||||
public class JavaEntityCollectItemTranslator extends PacketTranslator<ClientboundTakeItemEntityPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityCollectItemPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundTakeItemEntityPacket packet) {
|
||||
// Collected entity is the other entity
|
||||
Entity collectedEntity = session.getEntityCache().getEntityByJavaId(packet.getCollectedEntityId());
|
||||
if (collectedEntity == null) return;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundUpdateMobEffectPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobEffectPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -33,11 +33,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.EntityUtils;
|
||||
|
||||
@Translator(packet = ServerEntityEffectPacket.class)
|
||||
public class JavaEntityEffectTranslator extends PacketTranslator<ServerEntityEffectPacket> {
|
||||
@Translator(packet = ClientboundUpdateMobEffectPacket.class)
|
||||
public class JavaEntityEffectTranslator extends PacketTranslator<ClientboundUpdateMobEffectPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityEffectPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundUpdateMobEffectPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Equipment;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityEquipmentPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEquipmentPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.inventory.ItemData;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.LivingEntity;
|
||||
|
@ -35,11 +35,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.item.ItemTranslator;
|
||||
|
||||
@Translator(packet = ServerEntityEquipmentPacket.class)
|
||||
public class JavaEntityEquipmentTranslator extends PacketTranslator<ServerEntityEquipmentPacket> {
|
||||
@Translator(packet = ClientboundSetEquipmentPacket.class)
|
||||
public class JavaEntityEquipmentTranslator extends PacketTranslator<ClientboundSetEquipmentPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityEquipmentPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetEquipmentPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,20 +25,22 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityHeadLookPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRotateHeadPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerEntityHeadLookPacket.class)
|
||||
public class JavaEntityHeadLookTranslator extends PacketTranslator<ServerEntityHeadLookPacket> {
|
||||
@Translator(packet = ClientboundRotateHeadPacket.class)
|
||||
public class JavaEntityHeadLookTranslator extends PacketTranslator<ClientboundRotateHeadPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityHeadLookPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
public void translate(GeyserSession session, ClientboundRotateHeadPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
} else {
|
||||
entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
}
|
||||
|
||||
if (entity == null) return;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.EntityMetadata;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityDataPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
|
@ -34,11 +34,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
import org.geysermc.connector.utils.InteractiveTagManager;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
@Translator(packet = ServerEntityMetadataPacket.class)
|
||||
public class JavaEntityMetadataTranslator extends PacketTranslator<ServerEntityMetadataPacket> {
|
||||
@Translator(packet = ClientboundSetEntityDataPacket.class)
|
||||
public class JavaEntityMetadataTranslator extends PacketTranslator<ClientboundSetEntityDataPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityMetadataPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetEntityDataPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosRotPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerEntityPositionRotationPacket.class)
|
||||
public class JavaEntityPositionRotationTranslator extends PacketTranslator<ServerEntityPositionRotationPacket> {
|
||||
@Translator(packet = ClientboundMoveEntityPosRotPacket.class)
|
||||
public class JavaEntityPositionRotationTranslator extends PacketTranslator<ClientboundMoveEntityPosRotPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityPositionRotationPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundMoveEntityPosRotPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,20 +25,22 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityPosPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerEntityPositionPacket.class)
|
||||
public class JavaEntityPositionTranslator extends PacketTranslator<ServerEntityPositionPacket> {
|
||||
@Translator(packet = ClientboundMoveEntityPosPacket.class)
|
||||
public class JavaEntityPositionTranslator extends PacketTranslator<ClientboundMoveEntityPosPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityPositionPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
public void translate(GeyserSession session, ClientboundMoveEntityPosPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
} else {
|
||||
entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
}
|
||||
if (entity == null) return;
|
||||
|
||||
|
|
|
@ -25,26 +25,26 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundUpdateAttributesPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.LivingEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerEntityPropertiesPacket.class)
|
||||
public class JavaEntityPropertiesTranslator extends PacketTranslator<ServerEntityPropertiesPacket> {
|
||||
@Translator(packet = ClientboundUpdateAttributesPacket.class)
|
||||
public class JavaEntityPropertiesTranslator extends PacketTranslator<ClientboundUpdateAttributesPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityPropertiesPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundUpdateAttributesPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
} else {
|
||||
entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
}
|
||||
if (!(entity instanceof LivingEntity)) return;
|
||||
if (!(entity instanceof LivingEntity livingEntity)) return;
|
||||
|
||||
((LivingEntity) entity).updateBedrockAttributes(session, packet.getAttributes());
|
||||
livingEntity.updateBedrockAttributes(session, packet.getAttributes());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityRemoveEffectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveMobEffectPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.MobEffectPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -33,11 +33,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.EntityUtils;
|
||||
|
||||
@Translator(packet = ServerEntityRemoveEffectPacket.class)
|
||||
public class JavaEntityRemoveEffectTranslator extends PacketTranslator<ServerEntityRemoveEffectPacket> {
|
||||
@Translator(packet = ClientboundRemoveMobEffectPacket.class)
|
||||
public class JavaEntityRemoveEffectTranslator extends PacketTranslator<ClientboundRemoveMobEffectPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityRemoveEffectPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundRemoveMobEffectPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveEntityRotPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerEntityRotationPacket.class)
|
||||
public class JavaEntityRotationTranslator extends PacketTranslator<ServerEntityRotationPacket> {
|
||||
@Translator(packet = ClientboundMoveEntityRotPacket.class)
|
||||
public class JavaEntityRotationTranslator extends PacketTranslator<ClientboundMoveEntityRotPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityRotationPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundMoveEntityRotPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntitySetPassengersPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetPassengersPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityLinkData;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityLinkPacket;
|
||||
|
@ -39,11 +39,11 @@ import org.geysermc.connector.utils.EntityUtils;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Translator(packet = ServerEntitySetPassengersPacket.class)
|
||||
public class JavaEntitySetPassengersTranslator extends PacketTranslator<ServerEntitySetPassengersPacket> {
|
||||
@Translator(packet = ClientboundSetPassengersPacket.class)
|
||||
public class JavaEntitySetPassengersTranslator extends PacketTranslator<ClientboundSetPassengersPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntitySetPassengersPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetPassengersPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityStatusPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundEntityEventPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
|
@ -41,11 +41,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Translator(packet = ServerEntityStatusPacket.class)
|
||||
public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntityStatusPacket> {
|
||||
@Translator(packet = ClientboundEntityEventPacket.class)
|
||||
public class JavaEntityStatusTranslator extends PacketTranslator<ClientboundEntityEventPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityStatusPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundEntityEventPacket packet) {
|
||||
Entity entity;
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -25,19 +25,18 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundTeleportEntityPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
||||
@Translator(packet = ServerEntityTeleportPacket.class)
|
||||
public class JavaEntityTeleportTranslator extends PacketTranslator<ServerEntityTeleportPacket> {
|
||||
@Translator(packet = ClientboundTeleportEntityPacket.class)
|
||||
public class JavaEntityTeleportTranslator extends PacketTranslator<ClientboundTeleportEntityPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityTeleportPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundTeleportEntityPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -32,15 +32,15 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundSetEntityMotionPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetEntityMotionPacket;
|
||||
|
||||
@Translator(packet = ServerEntityVelocityPacket.class)
|
||||
public class JavaEntityVelocityTranslator extends PacketTranslator<ServerEntityVelocityPacket> {
|
||||
@Translator(packet = ClientboundSetEntityMotionPacket.class)
|
||||
public class JavaEntityVelocityTranslator extends PacketTranslator<ClientboundSetEntityMotionPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerEntityVelocityPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetEntityMotionPacket packet) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(packet.getEntityId());
|
||||
if (packet.getEntityId() == session.getPlayerEntity().getEntityId()) {
|
||||
entity = session.getPlayerEntity();
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.java.world;
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerVehicleMovePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundMoveVehiclePacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerVehicleMovePacket.class)
|
||||
public class JavaVehicleMoveTranslator extends PacketTranslator<ServerVehicleMovePacket> {
|
||||
@Translator(packet = ClientboundMoveVehiclePacket.class)
|
||||
public class JavaMoveVehicleTranslator extends PacketTranslator<ClientboundMoveVehiclePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerVehicleMovePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundMoveVehiclePacket packet) {
|
||||
Entity entity = session.getRidingVehicleEntity();
|
||||
if (entity == null) return;
|
||||
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerRemoveEntitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.ClientboundRemoveEntitiesPacket;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerRemoveEntitiesPacket.class)
|
||||
public class JavaRemoveEntitiesTranslator extends PacketTranslator<ServerRemoveEntitiesPacket> {
|
||||
@Translator(packet = ClientboundRemoveEntitiesPacket.class)
|
||||
public class JavaRemoveEntitiesTranslator extends PacketTranslator<ClientboundRemoveEntitiesPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerRemoveEntitiesPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundRemoveEntitiesPacket packet) {
|
||||
for (int entityId : packet.getEntityIds()) {
|
||||
Entity entity = session.getEntityCache().getEntityByJavaId(entityId);
|
||||
if (entity != null) {
|
||||
|
|
|
@ -25,16 +25,16 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerPlayerAbilitiesPacket.class)
|
||||
public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayerAbilitiesPacket> {
|
||||
@Translator(packet = ClientboundPlayerAbilitiesPacket.class)
|
||||
public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ClientboundPlayerAbilitiesPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerAbilitiesPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundPlayerAbilitiesPacket packet) {
|
||||
session.setCanFly(packet.isCanFly());
|
||||
session.setFlying(packet.isFlying());
|
||||
session.sendAdventureSettings();
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerActionAckPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundBlockBreakAckPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
|
@ -36,11 +36,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
import org.geysermc.connector.network.translators.world.block.BlockStateValues;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
||||
@Translator(packet = ServerPlayerActionAckPacket.class)
|
||||
public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayerActionAckPacket> {
|
||||
@Translator(packet = ClientboundBlockBreakAckPacket.class)
|
||||
public class JavaPlayerActionAckTranslator extends PacketTranslator<ClientboundBlockBreakAckPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerActionAckPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundBlockBreakAckPacket packet) {
|
||||
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
|
||||
if (packet.getAction() == PlayerAction.START_DIGGING && !packet.isSuccessful()) {
|
||||
LevelEventPacket stopBreak = new LevelEventPacket();
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetCarriedItemPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayerHotbarPacket;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
@Translator(packet = ServerPlayerChangeHeldItemPacket.class)
|
||||
public class JavaPlayerChangeHeldItemTranslator extends PacketTranslator<ServerPlayerChangeHeldItemPacket> {
|
||||
@Translator(packet = ClientboundSetCarriedItemPacket.class)
|
||||
public class JavaPlayerChangeHeldItemTranslator extends PacketTranslator<ClientboundSetCarriedItemPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerChangeHeldItemPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetCarriedItemPacket packet) {
|
||||
PlayerHotbarPacket hotbarPacket = new PlayerHotbarPacket();
|
||||
hotbarPacket.setContainerId(0);
|
||||
hotbarPacket.setSelectedHotbarSlot(packet.getSlot());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import com.nukkitx.protocol.bedrock.packet.SetHealthPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
|
@ -37,11 +37,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@Translator(packet = ServerPlayerHealthPacket.class)
|
||||
public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHealthPacket> {
|
||||
@Translator(packet = ClientboundSetHealthPacket.class)
|
||||
public class JavaPlayerHealthTranslator extends PacketTranslator<ClientboundSetHealthPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerHealthPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetHealthPacket packet) {
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
|
||||
int health = (int) Math.ceil(packet.getHealth());
|
||||
|
|
|
@ -27,7 +27,7 @@ package org.geysermc.connector.network.translators.java.entity.player;
|
|||
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntry;
|
||||
import com.github.steveice10.mc.protocol.data.game.PlayerListEntryAction;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundPlayerInfoPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.packet.PlayerListPacket;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
|
@ -37,10 +37,10 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.skin.SkinManager;
|
||||
|
||||
@Translator(packet = ServerPlayerListEntryPacket.class)
|
||||
public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayerListEntryPacket> {
|
||||
@Translator(packet = ClientboundPlayerInfoPacket.class)
|
||||
public class JavaPlayerListEntryTranslator extends PacketTranslator<ClientboundPlayerInfoPacket> {
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerListEntryPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundPlayerInfoPacket packet) {
|
||||
if (packet.getAction() != PlayerListEntryAction.ADD_PLAYER && packet.getAction() != PlayerListEntryAction.REMOVE_PLAYER)
|
||||
return;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityData;
|
||||
import com.nukkitx.protocol.bedrock.data.entity.EntityLinkData;
|
||||
|
@ -46,11 +46,11 @@ import org.geysermc.connector.utils.ChunkUtils;
|
|||
import org.geysermc.connector.utils.EntityUtils;
|
||||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
|
||||
@Translator(packet = ServerPlayerPositionRotationPacket.class)
|
||||
public class JavaPlayerPositionRotationTranslator extends PacketTranslator<ServerPlayerPositionRotationPacket> {
|
||||
@Translator(packet = ClientboundPlayerPositionPacket.class)
|
||||
public class JavaPlayerPositionRotationTranslator extends PacketTranslator<ClientboundPlayerPositionPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerPositionRotationPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundPlayerPositionPacket packet) {
|
||||
if (!session.isLoggedIn())
|
||||
return;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
|||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
session.setSpawned(true);
|
||||
|
||||
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
|
||||
ServerboundAcceptTeleportationPacket teleportConfirmPacket = new ServerboundAcceptTeleportationPacket(packet.getTeleportId());
|
||||
session.sendDownstreamPacket(teleportConfirmPacket);
|
||||
|
||||
ChunkUtils.updateChunkPosition(session, pos.toInt());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetExperiencePacket;
|
||||
import com.nukkitx.protocol.bedrock.data.AttributeData;
|
||||
import com.nukkitx.protocol.bedrock.packet.UpdateAttributesPacket;
|
||||
import org.geysermc.connector.entity.attribute.GeyserAttributeType;
|
||||
|
@ -36,11 +36,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Translator(packet = ServerPlayerSetExperiencePacket.class)
|
||||
public class JavaPlayerSetExperienceTranslator extends PacketTranslator<ServerPlayerSetExperiencePacket> {
|
||||
@Translator(packet = ClientboundSetExperiencePacket.class)
|
||||
public class JavaPlayerSetExperienceTranslator extends PacketTranslator<ClientboundSetExperiencePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerPlayerSetExperiencePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundSetExperiencePacket packet) {
|
||||
SessionPlayerEntity entity = session.getPlayerEntity();
|
||||
|
||||
AttributeData experience = GeyserAttributeType.EXPERIENCE.getAttribute(packet.getExperience());
|
||||
|
|
|
@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.object.FallingBlockDat
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.object.HangingDirection;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.object.ProjectileData;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.*;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
|
@ -42,11 +42,11 @@ import org.geysermc.connector.utils.LanguageUtils;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@Translator(packet = ServerSpawnEntityPacket.class)
|
||||
public class JavaSpawnEntityTranslator extends PacketTranslator<ServerSpawnEntityPacket> {
|
||||
@Translator(packet = ClientboundAddEntityPacket.class)
|
||||
public class JavaSpawnEntityTranslator extends PacketTranslator<ClientboundAddEntityPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerSpawnEntityPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAddEntityPacket packet) {
|
||||
|
||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.spawn;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddExperienceOrbPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.ExpOrbEntity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
|
@ -32,14 +34,11 @@ import org.geysermc.connector.network.session.GeyserSession;
|
|||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
|
||||
@Translator(packet = ServerSpawnExpOrbPacket.class)
|
||||
public class JavaSpawnExpOrbTranslator extends PacketTranslator<ServerSpawnExpOrbPacket> {
|
||||
@Translator(packet = ClientboundAddExperienceOrbPacket.class)
|
||||
public class JavaSpawnExpOrbTranslator extends PacketTranslator<ClientboundAddExperienceOrbPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerSpawnExpOrbPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAddExperienceOrbPacket packet) {
|
||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
|
||||
Entity entity = new ExpOrbEntity(
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.spawn;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnLivingEntityPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddMobPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.Entity;
|
||||
import org.geysermc.connector.entity.type.EntityType;
|
||||
|
@ -38,11 +38,11 @@ import org.geysermc.connector.utils.LanguageUtils;
|
|||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@Translator(packet = ServerSpawnLivingEntityPacket.class)
|
||||
public class JavaSpawnLivingEntityTranslator extends PacketTranslator<ServerSpawnLivingEntityPacket> {
|
||||
@Translator(packet = ClientboundAddMobPacket.class)
|
||||
public class JavaSpawnLivingEntityTranslator extends PacketTranslator<ClientboundAddMobPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerSpawnLivingEntityPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAddMobPacket packet) {
|
||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
|
||||
Vector3f rotation = Vector3f.from(packet.getYaw(), packet.getPitch(), packet.getHeadYaw());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.spawn;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPaintingPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.entity.PaintingEntity;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
|
@ -33,11 +33,11 @@ import org.geysermc.connector.network.translators.PacketTranslator;
|
|||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.utils.PaintingType;
|
||||
|
||||
@Translator(packet = ServerSpawnPaintingPacket.class)
|
||||
public class JavaSpawnPaintingTranslator extends PacketTranslator<ServerSpawnPaintingPacket> {
|
||||
@Translator(packet = ClientboundAddPaintingPacket.class)
|
||||
public class JavaSpawnPaintingTranslator extends PacketTranslator<ClientboundAddPaintingPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerSpawnPaintingPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAddPaintingPacket packet) {
|
||||
Vector3f position = Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
||||
|
||||
PaintingEntity entity = new PaintingEntity(packet.getEntityId(),
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
package org.geysermc.connector.network.translators.java.entity.spawn;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddPlayerPacket;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import org.geysermc.connector.GeyserConnector;
|
||||
import org.geysermc.connector.entity.player.PlayerEntity;
|
||||
|
@ -35,11 +35,11 @@ import org.geysermc.connector.network.translators.Translator;
|
|||
import org.geysermc.connector.utils.LanguageUtils;
|
||||
import org.geysermc.connector.skin.SkinManager;
|
||||
|
||||
@Translator(packet = ServerSpawnPlayerPacket.class)
|
||||
public class JavaSpawnPlayerTranslator extends PacketTranslator<ServerSpawnPlayerPacket> {
|
||||
@Translator(packet = ClientboundAddPlayerPacket.class)
|
||||
public class JavaSpawnPlayerTranslator extends PacketTranslator<ClientboundAddPlayerPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerSpawnPlayerPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundAddPlayerPacket packet) {
|
||||
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
|
||||
Vector3f rotation = Vector3f.from(packet.getYaw(), packet.getPitch(), packet.getYaw());
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.java.world;
|
||||
package org.geysermc.connector.network.translators.java.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockBreakAnimPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockDestructionPacket;
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.nukkitx.math.vector.Vector3f;
|
||||
import com.nukkitx.protocol.bedrock.data.LevelEventType;
|
||||
|
@ -37,11 +37,11 @@ import org.geysermc.connector.registry.BlockRegistries;
|
|||
import org.geysermc.connector.registry.type.ItemMapping;
|
||||
import org.geysermc.connector.utils.BlockUtils;
|
||||
|
||||
@Translator(packet = ServerBlockBreakAnimPacket.class)
|
||||
public class JavaBlockBreakAnimTranslator extends PacketTranslator<ServerBlockBreakAnimPacket> {
|
||||
@Translator(packet = ClientboundBlockDestructionPacket.class)
|
||||
public class JavaBlockBreakAnimTranslator extends PacketTranslator<ClientboundBlockDestructionPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerBlockBreakAnimPacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundBlockDestructionPacket packet) {
|
||||
int state = session.getConnector().getWorldManager().getBlockAt(session, packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ());
|
||||
int breakTime = (int) (65535 / Math.ceil(BlockUtils.getBreakTime(session, BlockRegistries.JAVA_BLOCKS.get(state), ItemMapping.AIR, new CompoundTag(""), false) * 20));
|
||||
LevelEventPacket levelEventPacket = new LevelEventPacket();
|
|
@ -23,10 +23,10 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.java.world;
|
||||
package org.geysermc.connector.network.translators.java.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockUpdatePacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.protocol.bedrock.data.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
|
||||
|
@ -38,11 +38,11 @@ import org.geysermc.connector.network.translators.sound.BlockSoundInteractionHan
|
|||
import org.geysermc.connector.registry.BlockRegistries;
|
||||
import org.geysermc.connector.utils.ChunkUtils;
|
||||
|
||||
@Translator(packet = ServerBlockChangePacket.class)
|
||||
public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChangePacket> {
|
||||
@Translator(packet = ClientboundBlockUpdatePacket.class)
|
||||
public class JavaBlockChangeTranslator extends PacketTranslator<ClientboundBlockUpdatePacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerBlockChangePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundBlockUpdatePacket packet) {
|
||||
Position pos = packet.getRecord().getPosition();
|
||||
boolean updatePlacement = session.getConnector().getPlatformType() != PlatformType.SPIGOT && // Spigot simply listens for the block place event
|
||||
session.getConnector().getWorldManager().getBlockAt(session, pos) != packet.getRecord().getBlock();
|
||||
|
@ -53,7 +53,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
|||
this.checkInteract(session, packet);
|
||||
}
|
||||
|
||||
private boolean checkPlace(GeyserSession session, ServerBlockChangePacket packet) {
|
||||
private boolean checkPlace(GeyserSession session, ClientboundBlockUpdatePacket packet) {
|
||||
Vector3i lastPlacePos = session.getLastBlockPlacePosition();
|
||||
if (lastPlacePos == null) {
|
||||
return false;
|
||||
|
@ -91,7 +91,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
|||
return true;
|
||||
}
|
||||
|
||||
private void checkInteract(GeyserSession session, ServerBlockChangePacket packet) {
|
||||
private void checkInteract(GeyserSession session, ClientboundBlockUpdatePacket packet) {
|
||||
Vector3i lastInteractPos = session.getLastInteractionBlockPosition();
|
||||
if (lastInteractPos == null || !session.isInteracting()) {
|
||||
return;
|
|
@ -23,11 +23,11 @@
|
|||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.connector.network.translators.java.world;
|
||||
package org.geysermc.connector.network.translators.java.level;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.block.value.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.value.*;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundBlockEventPacket;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import com.nukkitx.nbt.NbtMap;
|
||||
import com.nukkitx.nbt.NbtMapBuilder;
|
||||
|
@ -44,11 +44,11 @@ import org.geysermc.connector.network.translators.world.block.entity.NoteblockBl
|
|||
import org.geysermc.connector.network.translators.world.block.entity.PistonBlockEntity;
|
||||
import org.geysermc.connector.utils.Direction;
|
||||
|
||||
@Translator(packet = ServerBlockValuePacket.class)
|
||||
public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValuePacket> {
|
||||
@Translator(packet = ClientboundBlockEventPacket.class)
|
||||
public class JavaBlockValueTranslator extends PacketTranslator<ClientboundBlockEventPacket> {
|
||||
|
||||
@Override
|
||||
public void translate(GeyserSession session, ServerBlockValuePacket packet) {
|
||||
public void translate(GeyserSession session, ClientboundBlockEventPacket packet) {
|
||||
BlockEventPacket blockEventPacket = new BlockEventPacket();
|
||||
blockEventPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(),
|
||||
packet.getPosition().getY(), packet.getPosition().getZ()));
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue