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