3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-12-27 08:30:12 +01:00

Implement helper methods for sending packets (#487)

* Implement helper methods for sending packets, fixes an NPE when chatting before connecting to the remote server

* Change method names

* Add a space between doc comment lines

* Add debug messages
Dieser Commit ist enthalten in:
Luke 2020-05-05 16:51:43 +01:00 committet von GitHub
Ursprung 96a7770c22
Commit 7195d20fae
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
96 geänderte Dateien mit 270 neuen und 235 gelöschten Zeilen

Datei anzeigen

@ -55,7 +55,7 @@ public class OffhandCommand extends GeyserCommand {
GeyserSession session = (GeyserSession) sender; GeyserSession session = (GeyserSession) sender;
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0), ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
BlockFace.DOWN); BlockFace.DOWN);
session.getDownstream().getSession().send(releaseItemPacket); session.sendDownstreamPacket(releaseItemPacket);
} }
} }
} }

Datei anzeigen

@ -119,7 +119,7 @@ public class Entity {
addEntityPacket.getMetadata().putAll(metadata); addEntityPacket.getMetadata().putAll(metadata);
valid = true; valid = true;
session.getUpstream().sendPacket(addEntityPacket); session.sendUpstreamPacket(addEntityPacket);
session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
} }
@ -135,7 +135,7 @@ public class Entity {
RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket();
removeEntityPacket.setUniqueEntityId(geyserId); removeEntityPacket.setUniqueEntityId(geyserId);
session.getUpstream().sendPacket(removeEntityPacket); session.sendUpstreamPacket(removeEntityPacket);
valid = false; valid = false;
return true; return true;
@ -156,7 +156,7 @@ public class Entity {
moveEntityPacket.setOnGround(isOnGround); moveEntityPacket.setOnGround(isOnGround);
moveEntityPacket.setTeleported(false); moveEntityPacket.setTeleported(false);
session.getUpstream().sendPacket(moveEntityPacket); session.sendUpstreamPacket(moveEntityPacket);
} }
public void moveAbsolute(GeyserSession session, Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) { public void moveAbsolute(GeyserSession session, Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) {
@ -174,7 +174,7 @@ public class Entity {
moveEntityPacket.setOnGround(isOnGround); moveEntityPacket.setOnGround(isOnGround);
moveEntityPacket.setTeleported(teleported); moveEntityPacket.setTeleported(teleported);
session.getUpstream().sendPacket(moveEntityPacket); session.sendUpstreamPacket(moveEntityPacket);
} }
public void updateBedrockAttributes(GeyserSession session) { public void updateBedrockAttributes(GeyserSession session) {
@ -191,7 +191,7 @@ public class Entity {
UpdateAttributesPacket updateAttributesPacket = new UpdateAttributesPacket(); UpdateAttributesPacket updateAttributesPacket = new UpdateAttributesPacket();
updateAttributesPacket.setRuntimeEntityId(geyserId); updateAttributesPacket.setRuntimeEntityId(geyserId);
updateAttributesPacket.setAttributes(attributes); updateAttributesPacket.setAttributes(attributes);
session.getUpstream().sendPacket(updateAttributesPacket); session.sendUpstreamPacket(updateAttributesPacket);
} }
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
@ -218,13 +218,13 @@ public class Entity {
else { else {
useItemPacket = new ClientPlayerUseItemPacket(Hand.OFF_HAND); useItemPacket = new ClientPlayerUseItemPacket(Hand.OFF_HAND);
} }
session.getDownstream().getSession().send(useItemPacket); session.sendDownstreamPacket(useItemPacket);
} }
} else if (session.getPlayerEntity().getEntityId() == entityId && !metadata.getFlags().getFlag(EntityFlag.SNEAKING) && metadata.getFlags().getFlag(EntityFlag.BLOCKING)) { } else if (session.getPlayerEntity().getEntityId() == entityId && !metadata.getFlags().getFlag(EntityFlag.SNEAKING) && metadata.getFlags().getFlag(EntityFlag.BLOCKING)) {
metadata.getFlags().setFlag(EntityFlag.BLOCKING, false); metadata.getFlags().setFlag(EntityFlag.BLOCKING, false);
metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true); metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true);
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0), BlockFace.DOWN); ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0), BlockFace.DOWN);
session.getDownstream().getSession().send(releaseItemPacket); session.sendDownstreamPacket(releaseItemPacket);
} }
// metadata.getFlags().setFlag(EntityFlag.INVISIBLE, (xd & 0x20) == 0x20); // metadata.getFlags().setFlag(EntityFlag.INVISIBLE, (xd & 0x20) == 0x20);
if ((xd & 0x20) == 0x20) if ((xd & 0x20) == 0x20)
@ -265,7 +265,7 @@ public class Entity {
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(geyserId); entityDataPacket.setRuntimeEntityId(geyserId);
entityDataPacket.getMetadata().putAll(metadata); entityDataPacket.getMetadata().putAll(metadata);
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
} }
/** /**

Datei anzeigen

@ -50,7 +50,7 @@ public class ItemEntity extends Entity {
itemPacket.setFromFishing(false); itemPacket.setFromFishing(false);
itemPacket.getMetadata().putAll(metadata); itemPacket.getMetadata().putAll(metadata);
itemPacket.setItemInHand(Translators.getItemTranslator().translateToBedrock(session, (ItemStack) entityMetadata.getValue())); itemPacket.setItemInHand(Translators.getItemTranslator().translateToBedrock(session, (ItemStack) entityMetadata.getValue()));
session.getUpstream().sendPacket(itemPacket); session.sendUpstreamPacket(itemPacket);
} }
super.updateBedrockMetadata(entityMetadata, session); super.updateBedrockMetadata(entityMetadata, session);

Datei anzeigen

@ -149,7 +149,7 @@ public class ItemFrameEntity extends Entity {
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.getUpstream().sendPacket(updateBlockPacket); session.sendUpstreamPacket(updateBlockPacket);
session.getItemFrameCache().remove(position, entityId); session.getItemFrameCache().remove(position, entityId);
valid = false; valid = false;
return true; return true;
@ -179,7 +179,7 @@ public class ItemFrameEntity extends Entity {
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.getUpstream().sendPacket(updateBlockPacket); session.sendUpstreamPacket(updateBlockPacket);
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
blockEntityDataPacket.setBlockPosition(bedrockPosition); blockEntityDataPacket.setBlockPosition(bedrockPosition);
@ -189,7 +189,7 @@ public class ItemFrameEntity extends Entity {
blockEntityDataPacket.setData(getDefaultTag()); blockEntityDataPacket.setData(getDefaultTag());
} }
session.getUpstream().sendPacket(blockEntityDataPacket); session.sendUpstreamPacket(blockEntityDataPacket);
}, 500, TimeUnit.MILLISECONDS); }, 500, TimeUnit.MILLISECONDS);
} }

Datei anzeigen

@ -96,8 +96,8 @@ public class LivingEntity extends Entity {
offHandPacket.setInventorySlot(0); offHandPacket.setInventorySlot(0);
offHandPacket.setContainerId(ContainerId.OFFHAND); offHandPacket.setContainerId(ContainerId.OFFHAND);
session.getUpstream().sendPacket(armorEquipmentPacket); session.sendUpstreamPacket(armorEquipmentPacket);
session.getUpstream().sendPacket(handPacket); session.sendUpstreamPacket(handPacket);
session.getUpstream().sendPacket(offHandPacket); session.sendUpstreamPacket(offHandPacket);
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class PaintingEntity extends Entity {
addPaintingPacket.setName(paintingName.getBedrockName()); addPaintingPacket.setName(paintingName.getBedrockName());
addPaintingPacket.setPosition(fixOffset(true)); addPaintingPacket.setPosition(fixOffset(true));
addPaintingPacket.setDirection(direction); addPaintingPacket.setDirection(direction);
session.getUpstream().sendPacket(addPaintingPacket); session.sendUpstreamPacket(addPaintingPacket);
valid = true; valid = true;

Datei anzeigen

@ -94,7 +94,7 @@ public class PlayerEntity extends LivingEntity {
addPlayerPacket.getMetadata().putAll(metadata); addPlayerPacket.getMetadata().putAll(metadata);
valid = true; valid = true;
session.getUpstream().sendPacket(addPlayerPacket); session.sendUpstreamPacket(addPlayerPacket);
updateEquipment(session); updateEquipment(session);
updateBedrockAttributes(session); updateBedrockAttributes(session);
@ -108,7 +108,7 @@ public class PlayerEntity extends LivingEntity {
PlayerListPacket playerList = new PlayerListPacket(); PlayerListPacket playerList = new PlayerListPacket();
playerList.setAction(PlayerListPacket.Action.ADD); playerList.setAction(PlayerListPacket.Action.ADD);
playerList.getEntries().add(SkinUtils.buildDefaultEntry(profile, geyserId)); playerList.getEntries().add(SkinUtils.buildDefaultEntry(profile, geyserId));
session.getUpstream().sendPacket(playerList); session.sendUpstreamPacket(playerList);
} }
} }
@ -124,7 +124,7 @@ public class PlayerEntity extends LivingEntity {
PlayerListPacket playerList = new PlayerListPacket(); PlayerListPacket playerList = new PlayerListPacket();
playerList.setAction(PlayerListPacket.Action.REMOVE); playerList.setAction(PlayerListPacket.Action.REMOVE);
playerList.getEntries().add(new PlayerListPacket.Entry(uuid)); playerList.getEntries().add(new PlayerListPacket.Entry(uuid));
session.getUpstream().sendPacket(playerList); session.sendUpstreamPacket(playerList);
}); });
} }
} }
@ -145,7 +145,7 @@ public class PlayerEntity extends LivingEntity {
movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN); movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN);
} }
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
} }
@Override @Override
@ -159,7 +159,7 @@ public class PlayerEntity extends LivingEntity {
movePlayerPacket.setRotation(getBedrockRotation()); movePlayerPacket.setRotation(getBedrockRotation());
movePlayerPacket.setOnGround(isOnGround); movePlayerPacket.setOnGround(isOnGround);
movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL); movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
} }
@Override @Override

Datei anzeigen

@ -65,7 +65,7 @@ public class LlamaEntity extends ChestedHorseEntity {
equipmentPacket.setHelmet(ItemData.AIR); equipmentPacket.setHelmet(ItemData.AIR);
equipmentPacket.setLeggings(ItemData.AIR); equipmentPacket.setLeggings(ItemData.AIR);
session.getUpstream().sendPacket(equipmentPacket); session.sendUpstreamPacket(equipmentPacket);
} }
// Color of the llama // Color of the llama
if (entityMetadata.getId() == 21) { if (entityMetadata.getId() == 21) {

Datei anzeigen

@ -53,7 +53,7 @@ public class EnderDragonEntity extends InsentientEntity {
entityEventPacket.setType(EntityEventType.DRAGON_FLAMING); entityEventPacket.setType(EntityEventType.DRAGON_FLAMING);
entityEventPacket.setRuntimeEntityId(geyserId); entityEventPacket.setRuntimeEntityId(geyserId);
entityEventPacket.setData(0); entityEventPacket.setData(0);
session.getUpstream().sendPacket(entityEventPacket); session.sendUpstreamPacket(entityEventPacket);
case 6: case 6:
case 7: case 7:
metadata.getFlags().setFlag(EntityFlag.SITTING, true); metadata.getFlags().setFlag(EntityFlag.SITTING, true);
@ -79,7 +79,7 @@ public class EnderDragonEntity extends InsentientEntity {
addEntityPacket.getAttributes().add(new Attribute("minecraft:health", 0.0f, 200f, 200f, 200f)); addEntityPacket.getAttributes().add(new Attribute("minecraft:health", 0.0f, 200f, 200f, 200f));
valid = true; valid = true;
session.getUpstream().sendPacket(addEntityPacket); session.sendUpstreamPacket(addEntityPacket);
session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
} }

Datei anzeigen

@ -58,10 +58,10 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
PlayStatusPacket playStatus = new PlayStatusPacket(); PlayStatusPacket playStatus = new PlayStatusPacket();
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS); playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
session.getUpstream().sendPacket(playStatus); session.sendUpstreamPacket(playStatus);
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket(); ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
session.getUpstream().sendPacket(resourcePacksInfo); session.sendUpstreamPacket(resourcePacksInfo);
return true; return true;
} }
@ -77,7 +77,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
stack.setExperimental(false); stack.setExperimental(false);
stack.setForcedToAccept(false); stack.setForcedToAccept(false);
stack.setGameVersion("*"); stack.setGameVersion("*");
session.getUpstream().sendPacket(stack); session.sendUpstreamPacket(stack);
break; break;
default: default:
session.disconnect("disconnectionScreen.resourcePack"); session.disconnect("disconnectionScreen.resourcePack");

Datei anzeigen

@ -29,6 +29,7 @@ import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsException; import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsException;
import com.github.steveice10.mc.auth.exception.request.RequestException; import com.github.steveice10.mc.auth.exception.request.RequestException;
import com.github.steveice10.mc.protocol.MinecraftProtocol; import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.data.SubProtocol;
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.world.ClientTeleportConfirmPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
@ -41,6 +42,7 @@ import com.github.steveice10.packetlib.tcp.TcpSessionFactory;
import com.nukkitx.math.GenericMath; import com.nukkitx.math.GenericMath;
import com.nukkitx.math.TrigMath; import com.nukkitx.math.TrigMath;
import com.nukkitx.math.vector.*; import com.nukkitx.math.vector.*;
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.BedrockServerSession;
import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.ContainerId;
import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
@ -156,6 +158,8 @@ public class GeyserSession implements CommandSender {
@Setter @Setter
private int craftSlot = 0; private int craftSlot = 0;
private MinecraftProtocol protocol;
public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) { public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) {
this.connector = connector; this.connector = connector;
this.upstream = new UpstreamSession(bedrockServerSession); this.upstream = new UpstreamSession(bedrockServerSession);
@ -227,7 +231,6 @@ public class GeyserSession implements CommandSender {
// new thread so clients don't timeout // new thread so clients don't timeout
new Thread(() -> { new Thread(() -> {
try { try {
MinecraftProtocol protocol;
if (password != null && !password.isEmpty()) { if (password != null && !password.isEmpty()) {
protocol = new MinecraftProtocol(username, password); protocol = new MinecraftProtocol(username, password);
} else { } else {
@ -481,8 +484,47 @@ public class GeyserSession implements CommandSender {
int teleportId = teleportCache.getTeleportConfirmId(); int teleportId = teleportCache.getTeleportConfirmId();
teleportCache = null; teleportCache = null;
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(teleportId); ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(teleportId);
getDownstream().getSession().send(teleportConfirmPacket); sendDownstreamPacket(teleportConfirmPacket);
} }
return true; return true;
} }
/**
* Queue a packet to be sent to player.
*
* @param packet the bedrock packet from the NukkitX protocol lib
*/
public void sendUpstreamPacket(BedrockPacket packet) {
if (upstream != null && !upstream.isClosed()) {
upstream.sendPacket(packet);
} else {
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " but the session was null");
}
}
/**
* Send a packet immediately to the player.
*
* @param packet the bedrock packet from the NukkitX protocol lib
*/
public void sendUpstreamPacketImmediately(BedrockPacket packet) {
if (upstream != null && !upstream.isClosed()) {
upstream.sendPacketImmediately(packet);
} else {
connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " immediately but the session was null");
}
}
/**
* Send a packet to the remote server.
*
* @param packet the java edition packet from MCProtocolLib
*/
public void sendDownstreamPacket(Packet packet) {
if (downstream != null && downstream.getSession() != null && protocol.getSubProtocol().equals(SubProtocol.GAME)) {
downstream.getSession().send(packet);
} else {
connector.getLogger().debug("Tried to send downstream packet " + packet.getClass().getSimpleName() + " before connected to the server");
}
}
} }

Datei anzeigen

@ -62,7 +62,7 @@ public class BossBar {
bossEventPacket.setOverlay(overlay); bossEventPacket.setOverlay(overlay);
bossEventPacket.setDarkenSky(darkenSky); bossEventPacket.setDarkenSky(darkenSky);
session.getUpstream().sendPacket(bossEventPacket); session.sendUpstreamPacket(bossEventPacket);
} }
public void updateTitle(Message title) { public void updateTitle(Message title) {
@ -72,7 +72,7 @@ public class BossBar {
bossEventPacket.setAction(BossEventPacket.Action.TITLE); bossEventPacket.setAction(BossEventPacket.Action.TITLE);
bossEventPacket.setTitle(MessageUtils.getTranslatedBedrockMessage(title, session.getClientData().getLanguageCode())); bossEventPacket.setTitle(MessageUtils.getTranslatedBedrockMessage(title, session.getClientData().getLanguageCode()));
session.getUpstream().sendPacket(bossEventPacket); session.sendUpstreamPacket(bossEventPacket);
} }
public void updateHealth(float health) { public void updateHealth(float health) {
@ -82,7 +82,7 @@ public class BossBar {
bossEventPacket.setAction(BossEventPacket.Action.HEALTH_PERCENTAGE); bossEventPacket.setAction(BossEventPacket.Action.HEALTH_PERCENTAGE);
bossEventPacket.setHealthPercentage(health); bossEventPacket.setHealthPercentage(health);
session.getUpstream().sendPacket(bossEventPacket); session.sendUpstreamPacket(bossEventPacket);
} }
public void removeBossBar() { public void removeBossBar() {
@ -90,7 +90,7 @@ public class BossBar {
bossEventPacket.setBossUniqueEntityId(entityId); bossEventPacket.setBossUniqueEntityId(entityId);
bossEventPacket.setAction(BossEventPacket.Action.HIDE); bossEventPacket.setAction(BossEventPacket.Action.HIDE);
session.getUpstream().sendPacket(bossEventPacket); session.sendUpstreamPacket(bossEventPacket);
removeBossEntity(); removeBossEntity();
} }
@ -109,13 +109,13 @@ public class BossBar {
addEntityPacket.setMotion(Vector3f.ZERO); addEntityPacket.setMotion(Vector3f.ZERO);
addEntityPacket.getMetadata().put(EntityData.SCALE, 0.01F); // scale = 0 doesn't work? addEntityPacket.getMetadata().put(EntityData.SCALE, 0.01F); // scale = 0 doesn't work?
session.getUpstream().sendPacket(addEntityPacket); session.sendUpstreamPacket(addEntityPacket);
} }
private void removeBossEntity() { private void removeBossEntity() {
RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket();
removeEntityPacket.setUniqueEntityId(entityId); removeEntityPacket.setUniqueEntityId(entityId);
session.getUpstream().sendPacket(removeEntityPacket); session.sendUpstreamPacket(removeEntityPacket);
} }
} }

Datei anzeigen

@ -66,7 +66,7 @@ public class WindowCache {
formRequestPacket.setFormId(id); formRequestPacket.setFormId(id);
formRequestPacket.setFormData(windows.get(id).getJSONData()); formRequestPacket.setFormData(windows.get(id).getJSONData());
session.getUpstream().sendPacket(formRequestPacket); session.sendUpstreamPacket(formRequestPacket);
} }
public void showWindow(FormWindow window, int id) { public void showWindow(FormWindow window, int id) {
@ -74,7 +74,7 @@ public class WindowCache {
formRequestPacket.setFormId(id); formRequestPacket.setFormId(id);
formRequestPacket.setFormData(window.getJSONData()); formRequestPacket.setFormData(window.getJSONData());
session.getUpstream().sendPacket(formRequestPacket); session.sendUpstreamPacket(formRequestPacket);
addWindow(window, id); addWindow(window, id);
} }

Datei anzeigen

@ -64,44 +64,44 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
break; break;
case START_SWIMMING: case START_SWIMMING:
ClientPlayerStatePacket startSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING); ClientPlayerStatePacket startSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
session.getDownstream().getSession().send(startSwimPacket); session.sendDownstreamPacket(startSwimPacket);
break; break;
case STOP_SWIMMING: case STOP_SWIMMING:
ClientPlayerStatePacket stopSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING); ClientPlayerStatePacket stopSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
session.getDownstream().getSession().send(stopSwimPacket); session.sendDownstreamPacket(stopSwimPacket);
break; break;
case START_GLIDE: case START_GLIDE:
case STOP_GLIDE: case STOP_GLIDE:
ClientPlayerStatePacket glidePacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING); ClientPlayerStatePacket glidePacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
session.getDownstream().getSession().send(glidePacket); session.sendDownstreamPacket(glidePacket);
break; break;
case START_SNEAK: case START_SNEAK:
ClientPlayerStatePacket startSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING); ClientPlayerStatePacket startSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
session.getDownstream().getSession().send(startSneakPacket); session.sendDownstreamPacket(startSneakPacket);
session.setSneaking(true); session.setSneaking(true);
break; break;
case STOP_SNEAK: case STOP_SNEAK:
ClientPlayerStatePacket stopSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING); ClientPlayerStatePacket stopSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING);
session.getDownstream().getSession().send(stopSneakPacket); session.sendDownstreamPacket(stopSneakPacket);
session.setSneaking(false); session.setSneaking(false);
break; break;
case START_SPRINT: case START_SPRINT:
ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING); ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
session.getDownstream().getSession().send(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); ClientPlayerStatePacket stopSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
session.getDownstream().getSession().send(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()]); ClientPlayerActionPacket dropItemPacket = new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]);
session.getDownstream().getSession().send(dropItemPacket); session.sendDownstreamPacket(dropItemPacket);
break; break;
case STOP_SLEEP: case STOP_SLEEP:
ClientPlayerStatePacket stopSleepingPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.LEAVE_BED); ClientPlayerStatePacket stopSleepingPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.LEAVE_BED);
session.getDownstream().getSession().send(stopSleepingPacket); session.sendDownstreamPacket(stopSleepingPacket);
break; break;
case BLOCK_INTERACT: case BLOCK_INTERACT:
// Handled in BedrockInventoryTransactionTranslator // Handled in BedrockInventoryTransactionTranslator
@ -109,19 +109,19 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
case START_BREAK: case START_BREAK:
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(), ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(),
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]); packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]);
session.getDownstream().getSession().send(startBreakingPacket); session.sendDownstreamPacket(startBreakingPacket);
break; break;
case CONTINUE_BREAK: case CONTINUE_BREAK:
LevelEventPacket continueBreakPacket = new LevelEventPacket(); LevelEventPacket continueBreakPacket = new LevelEventPacket();
continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK); continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK);
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock() == null ? BlockTranslator.AIR : session.getBreakingBlock())); continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock() == null ? BlockTranslator.AIR : session.getBreakingBlock()));
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat()); continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
session.getUpstream().sendPacket(continueBreakPacket); session.sendUpstreamPacket(continueBreakPacket);
break; break;
case ABORT_BREAK: case ABORT_BREAK:
ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(), ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(),
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.DOWN); packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.DOWN);
session.getDownstream().getSession().send(abortBreakingPacket); session.sendDownstreamPacket(abortBreakingPacket);
break; break;
case STOP_BREAK: case STOP_BREAK:
// Handled in BedrockInventoryTransactionTranslator // Handled in BedrockInventoryTransactionTranslator
@ -131,7 +131,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
//sometimes the client doesn't feel like loading //sometimes the client doesn't feel like loading
PlayStatusPacket spawnPacket = new PlayStatusPacket(); PlayStatusPacket spawnPacket = new PlayStatusPacket();
spawnPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); spawnPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
session.getUpstream().sendPacket(spawnPacket); session.sendUpstreamPacket(spawnPacket);
entity.updateBedrockAttributes(session); entity.updateBedrockAttributes(session);
session.getEntityCache().updateBossBars(); session.getEntityCache().updateBossBars();
} }

Datei anzeigen

@ -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.getConnector().getGeneralThreadPool().schedule(() -> session.getConnector().getGeneralThreadPool().schedule(() ->
session.getDownstream().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)), session.sendDownstreamPacket(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
25, 25,
TimeUnit.MILLISECONDS TimeUnit.MILLISECONDS
); );

Datei anzeigen

@ -79,7 +79,7 @@ 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();
ClientUpdateSignPacket clientUpdateSignPacket = new ClientUpdateSignPacket(pos, lines); ClientUpdateSignPacket clientUpdateSignPacket = new ClientUpdateSignPacket(pos, lines);
session.getDownstream().getSession().send(clientUpdateSignPacket); session.sendDownstreamPacket(clientUpdateSignPacket);
//TODO (potentially): originally I was going to update the sign blocks so Bedrock and Java users would match visually //TODO (potentially): originally I was going to update the sign blocks so Bedrock and Java users would match visually
// However Java can still store a lot per-line and visuals are still messed up so that doesn't work // However Java can still store a lot per-line and visuals are still messed up so that doesn't work

Datei anzeigen

@ -53,7 +53,7 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
} }
ClientChatPacket chatPacket = new ClientChatPacket(message); ClientChatPacket chatPacket = new ClientChatPacket(message);
session.getDownstream().getSession().send(chatPacket); session.sendDownstreamPacket(chatPacket);
} }
} }
} }

Datei anzeigen

@ -48,7 +48,7 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
} }
} }
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId); ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);
session.getDownstream().getSession().send(closeWindowPacket); session.sendDownstreamPacket(closeWindowPacket);
InventoryUtils.closeInventory(session, windowId); InventoryUtils.closeInventory(session, windowId);
} }
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class BedrockEntityEventTranslator extends PacketTranslator<EntityEventPa
switch (packet.getType()) { switch (packet.getType()) {
// Resend the packet so we get the eating sounds // Resend the packet so we get the eating sounds
case EATING_ITEM: case EATING_ITEM:
session.getUpstream().sendPacket(packet); session.sendUpstreamPacket(packet);
return; return;
} }
session.getConnector().getLogger().debug("Did not translate incoming EntityEventPacket: " + packet.toString()); session.getConnector().getLogger().debug("Did not translate incoming EntityEventPacket: " + packet.toString());

Datei anzeigen

@ -52,12 +52,12 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
} }
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.INTERACT, Hand.MAIN_HAND); InteractAction.INTERACT, Hand.MAIN_HAND);
session.getDownstream().getSession().send(interactPacket); session.sendDownstreamPacket(interactPacket);
break; break;
case DAMAGE: case DAMAGE:
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.ATTACK, Hand.MAIN_HAND); InteractAction.ATTACK, Hand.MAIN_HAND);
session.getDownstream().getSession().send(attackPacket); session.sendDownstreamPacket(attackPacket);
break; break;
} }
} }

Datei anzeigen

@ -84,8 +84,8 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
InteractAction.INTERACT, Hand.MAIN_HAND); InteractAction.INTERACT, Hand.MAIN_HAND);
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()), ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND); InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND);
session.getDownstream().getSession().send(interactPacket); session.sendDownstreamPacket(interactPacket);
session.getDownstream().getSession().send(interactAtPacket); session.sendDownstreamPacket(interactAtPacket);
break; break;
} }
@ -95,7 +95,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
Hand.MAIN_HAND, Hand.MAIN_HAND,
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(), packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
false); false);
session.getDownstream().getSession().send(blockPacket); session.sendDownstreamPacket(blockPacket);
Vector3i blockPos = packet.getBlockPosition(); Vector3i blockPos = packet.getBlockPosition();
// TODO: Find a better way to do this? // TODO: Find a better way to do this?
switch (packet.getFace()) { switch (packet.getFace()) {
@ -131,7 +131,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
break; break;
} // Handled in Entity.java } // Handled in Entity.java
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND); ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
session.getDownstream().getSession().send(useItemPacket); session.sendDownstreamPacket(useItemPacket);
break; break;
case 2: case 2:
BlockState blockState = session.getConnector().getWorldManager().getBlockAt(session, packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()); BlockState blockState = session.getConnector().getWorldManager().getBlockAt(session, packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
@ -144,21 +144,21 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
blockBreakPacket.setType(LevelEventType.DESTROY); blockBreakPacket.setType(LevelEventType.DESTROY);
blockBreakPacket.setPosition(packet.getBlockPosition().toFloat()); blockBreakPacket.setPosition(packet.getBlockPosition().toFloat());
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState)); blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
session.getUpstream().sendPacket(blockBreakPacket); session.sendUpstreamPacket(blockBreakPacket);
} }
if (ItemFrameEntity.positionContainsItemFrame(session, packet.getBlockPosition()) && if (ItemFrameEntity.positionContainsItemFrame(session, packet.getBlockPosition()) &&
session.getEntityCache().getEntityByJavaId(ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition())) != null) { session.getEntityCache().getEntityByJavaId(ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition())) != null) {
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()), ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
InteractAction.ATTACK); InteractAction.ATTACK);
session.getDownstream().getSession().send(attackPacket); session.sendDownstreamPacket(attackPacket);
break; break;
} }
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.getFace()]); ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getFace()]);
session.getDownstream().getSession().send(breakPacket); session.sendDownstreamPacket(breakPacket);
break; break;
} }
break; break;
@ -167,7 +167,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
// 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, new Position(0,0,0), ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0),
BlockFace.DOWN); BlockFace.DOWN);
session.getDownstream().getSession().send(releaseItemPacket); session.sendDownstreamPacket(releaseItemPacket);
} }
break; break;
case ITEM_USE_ON_ENTITY: case ITEM_USE_ON_ENTITY:
@ -183,15 +183,15 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
InteractAction.INTERACT, Hand.MAIN_HAND); InteractAction.INTERACT, Hand.MAIN_HAND);
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND); InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND);
session.getDownstream().getSession().send(interactPacket); session.sendDownstreamPacket(interactPacket);
session.getDownstream().getSession().send(interactAtPacket); session.sendDownstreamPacket(interactAtPacket);
EntitySoundInteractionHandler.handleEntityInteraction(session, vector, entity); EntitySoundInteractionHandler.handleEntityInteraction(session, vector, entity);
break; break;
case 1: //Attack case 1: //Attack
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
InteractAction.ATTACK); InteractAction.ATTACK);
session.getDownstream().getSession().send(attackPacket); session.sendDownstreamPacket(attackPacket);
break; break;
} }
break; break;

Datei anzeigen

@ -51,7 +51,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
Vector3i position = Vector3i.from(packet.getBlockPosition().getX(), y, packet.getBlockPosition().getZ()); Vector3i position = Vector3i.from(packet.getBlockPosition().getX(), y, packet.getBlockPosition().getZ());
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, position), ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, position),
InteractAction.ATTACK, Hand.MAIN_HAND); InteractAction.ATTACK, Hand.MAIN_HAND);
session.getDownstream().getSession().send(interactPacket); session.sendDownstreamPacket(interactPacket);
} }
} }

Datei anzeigen

@ -36,6 +36,6 @@ public class BedrockLevelSoundEventTranslator extends PacketTranslator<LevelSoun
@Override @Override
public void translate(LevelSoundEventPacket packet, GeyserSession session) { public void translate(LevelSoundEventPacket packet, GeyserSession session) {
// lol what even :thinking: // lol what even :thinking:
session.getUpstream().sendPacket(packet); session.sendUpstreamPacket(packet);
} }
} }

Datei anzeigen

@ -46,6 +46,6 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
session.getInventory().setHeldItemSlot(packet.getHotbarSlot()); session.getInventory().setHeldItemSlot(packet.getHotbarSlot());
ClientPlayerChangeHeldItemPacket changeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(packet.getHotbarSlot()); ClientPlayerChangeHeldItemPacket changeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(packet.getHotbarSlot());
session.getDownstream().getSession().send(changeHeldItemPacket); session.sendDownstreamPacket(changeHeldItemPacket);
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
moveEntityBack.setRotation(entity.getBedrockRotation()); moveEntityBack.setRotation(entity.getBedrockRotation());
moveEntityBack.setTeleported(true); moveEntityBack.setTeleported(true);
moveEntityBack.setOnGround(true); moveEntityBack.setOnGround(true);
session.getUpstream().sendPacketImmediately(moveEntityBack); session.sendUpstreamPacketImmediately(moveEntityBack);
return; return;
} }
@ -97,7 +97,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
if (!colliding) if (!colliding)
*/ */
session.getDownstream().getSession().send(playerPositionRotationPacket); session.sendDownstreamPacket(playerPositionRotationPacket);
} }
public boolean isValidMove(GeyserSession session, MovePlayerPacket.Mode mode, Vector3f currentPosition, Vector3f newPosition) { public boolean isValidMove(GeyserSession session, MovePlayerPacket.Mode mode, Vector3f currentPosition, Vector3f newPosition) {
@ -130,13 +130,13 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(entity.getMetadata()); entityDataPacket.getMetadata().putAll(entity.getMetadata());
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
movePlayerPacket.setPosition(entity.getPosition()); movePlayerPacket.setPosition(entity.getPosition());
movePlayerPacket.setRotation(entity.getBedrockRotation()); movePlayerPacket.setRotation(entity.getBedrockRotation());
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET); movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET);
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
} }
} }

Datei anzeigen

@ -44,10 +44,10 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
respawnPacket.setRuntimeEntityId(0); respawnPacket.setRuntimeEntityId(0);
respawnPacket.setPosition(Vector3f.ZERO); respawnPacket.setPosition(Vector3f.ZERO);
respawnPacket.setState(RespawnPacket.State.SERVER_SEARCHING); respawnPacket.setState(RespawnPacket.State.SERVER_SEARCHING);
session.getUpstream().sendPacket(respawnPacket); session.sendUpstreamPacket(respawnPacket);
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN); ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getDownstream().getSession().send(javaRespawnPacket); session.sendDownstreamPacket(javaRespawnPacket);
} }
} }
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPa
public void translate(ShowCreditsPacket packet, GeyserSession session) { public void translate(ShowCreditsPacket packet, GeyserSession session) {
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) { if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN); ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getDownstream().getSession().send(javaRespawnPacket); session.sendDownstreamPacket(javaRespawnPacket);
} }
} }
} }

Datei anzeigen

@ -45,6 +45,6 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
} }
ClientChatPacket chatPacket = new ClientChatPacket(message); ClientChatPacket chatPacket = new ClientChatPacket(message);
session.getDownstream().getSession().send(chatPacket); session.sendDownstreamPacket(chatPacket);
} }
} }

Datei anzeigen

@ -108,7 +108,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
rename = ""; rename = "";
} }
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename); ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename);
session.getDownstream().getSession().send(renameItemPacket); session.sendDownstreamPacket(renameItemPacket);
} }
if (anvilResult != null) { if (anvilResult != null) {
//client will send another packet to grab anvil output //client will send another packet to grab anvil output
@ -138,7 +138,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
rename = ""; rename = "";
} }
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename); ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename);
session.getDownstream().getSession().send(renameItemPacket); session.sendDownstreamPacket(renameItemPacket);
} }
} }
super.updateSlot(session, inventory, slot); super.updateSlot(session, inventory, slot);

Datei anzeigen

@ -44,7 +44,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator {
dataPacket.setWindowId((byte) inventory.getId()); dataPacket.setWindowId((byte) inventory.getId());
dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL); dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL);
dataPacket.setValue(20); dataPacket.setValue(20);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
} }
@Override @Override
@ -62,7 +62,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator {
return; return;
} }
dataPacket.setValue(value); dataPacket.setValue(value);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
} }
@Override @Override

Datei anzeigen

@ -59,7 +59,7 @@ public class CraftingInventoryTranslator extends BaseInventoryTranslator {
containerOpenPacket.setType((byte) ContainerType.WORKBENCH.id()); containerOpenPacket.setType((byte) ContainerType.WORKBENCH.id());
containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
session.getUpstream().sendPacket(containerOpenPacket); session.sendUpstreamPacket(containerOpenPacket);
} }
@Override @Override

Datei anzeigen

@ -60,7 +60,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
blockPacket.setBlockPosition(position); blockPacket.setBlockPosition(position);
blockPacket.setRuntimeId(blockId); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
CompoundTag tag = CompoundTag.builder() CompoundTag tag = CompoundTag.builder()
.stringTag("id", "Chest") .stringTag("id", "Chest")
@ -73,14 +73,14 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
BlockEntityDataPacket dataPacket = new BlockEntityDataPacket(); BlockEntityDataPacket dataPacket = new BlockEntityDataPacket();
dataPacket.setData(tag); dataPacket.setData(tag);
dataPacket.setBlockPosition(position); dataPacket.setBlockPosition(position);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
blockPacket = new UpdateBlockPacket(); blockPacket = new UpdateBlockPacket();
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(pairPosition); blockPacket.setBlockPosition(pairPosition);
blockPacket.setRuntimeId(blockId); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
tag = CompoundTag.builder() tag = CompoundTag.builder()
.stringTag("id", "Chest") .stringTag("id", "Chest")
@ -93,7 +93,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
dataPacket = new BlockEntityDataPacket(); dataPacket = new BlockEntityDataPacket();
dataPacket.setData(tag); dataPacket.setData(tag);
dataPacket.setBlockPosition(pairPosition); dataPacket.setBlockPosition(pairPosition);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
inventory.setHolderPosition(position); inventory.setHolderPosition(position);
} }
@ -105,7 +105,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
containerOpenPacket.setType((byte) ContainerType.CONTAINER.id()); containerOpenPacket.setType((byte) ContainerType.CONTAINER.id());
containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
session.getUpstream().sendPacket(containerOpenPacket); session.sendUpstreamPacket(containerOpenPacket);
} }
@Override @Override
@ -117,7 +117,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
holderPos = holderPos.add(Vector3i.UNIT_X); holderPos = holderPos.add(Vector3i.UNIT_X);
pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ()); pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ());
@ -126,7 +126,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
} }
@Override @Override

Datei anzeigen

@ -58,7 +58,7 @@ public class FurnaceInventoryTranslator extends BlockInventoryTranslator {
return; return;
} }
dataPacket.setValue(value); dataPacket.setValue(value);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
} }
@Override @Override

Datei anzeigen

@ -34,7 +34,6 @@ import com.nukkitx.protocol.bedrock.data.InventorySource;
import com.nukkitx.protocol.bedrock.data.ItemData; import com.nukkitx.protocol.bedrock.data.ItemData;
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket; import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket; import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
import it.unimi.dsi.fastutil.longs.LongArraySet;
import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.inventory.Inventory;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.Translators; import org.geysermc.connector.network.translators.Translators;
@ -66,7 +65,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
contents[i - 36] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)); contents[i - 36] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i));
} }
inventoryContentPacket.setContents(contents); inventoryContentPacket.setContents(contents);
session.getUpstream().sendPacket(inventoryContentPacket); session.sendUpstreamPacket(inventoryContentPacket);
// Armor // Armor
InventoryContentPacket armorContentPacket = new InventoryContentPacket(); InventoryContentPacket armorContentPacket = new InventoryContentPacket();
@ -76,13 +75,13 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
contents[i - 5] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)); contents[i - 5] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i));
} }
armorContentPacket.setContents(contents); armorContentPacket.setContents(contents);
session.getUpstream().sendPacket(armorContentPacket); session.sendUpstreamPacket(armorContentPacket);
// Offhand // Offhand
InventoryContentPacket offhandPacket = new InventoryContentPacket(); InventoryContentPacket offhandPacket = new InventoryContentPacket();
offhandPacket.setContainerId(ContainerId.OFFHAND); offhandPacket.setContainerId(ContainerId.OFFHAND);
offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(45))}); offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(45))});
session.getUpstream().sendPacket(offhandPacket); session.sendUpstreamPacket(offhandPacket);
} }
/** /**
@ -103,7 +102,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)));
} }
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
} }
} }
@ -126,12 +125,12 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
slotPacket.setSlot(slot + 27); slotPacket.setSlot(slot + 27);
} }
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
} else if (slot == 45) { } else if (slot == 45) {
InventoryContentPacket offhandPacket = new InventoryContentPacket(); InventoryContentPacket offhandPacket = new InventoryContentPacket();
offhandPacket.setContainerId(ContainerId.OFFHAND); offhandPacket.setContainerId(ContainerId.OFFHAND);
offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot))}); offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot))});
session.getUpstream().sendPacket(offhandPacket); session.sendUpstreamPacket(offhandPacket);
} }
} }
@ -204,7 +203,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem()); javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem());
} }
ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, javaItem); ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, javaItem);
session.getDownstream().getSession().send(creativePacket); session.sendDownstreamPacket(creativePacket);
inventory.setItem(javaSlot, javaItem); inventory.setItem(javaSlot, javaItem);
break; break;
case ContainerId.CURSOR: case ContainerId.CURSOR:
@ -217,7 +216,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
&& action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) { && action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) {
javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem()); javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem());
ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, javaItem); ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, javaItem);
session.getDownstream().getSession().send(creativeDropPacket); session.sendDownstreamPacket(creativeDropPacket);
} }
break; break;
} }

Datei anzeigen

@ -104,8 +104,8 @@ class ClickPlan {
break; break;
} }
} }
session.getDownstream().getSession().send(clickPacket); session.sendDownstreamPacket(clickPacket);
session.getDownstream().getSession().send(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true)); session.sendDownstreamPacket(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true));
} }
/*if (refresh) { /*if (refresh) {

Datei anzeigen

@ -94,7 +94,7 @@ public class InventoryActionDataTranslator {
ClientPlayerActionPacket actionPacket = new ClientPlayerActionPacket( ClientPlayerActionPacket actionPacket = new ClientPlayerActionPacket(
sourceAction.getToItem().getCount() == 0 ? PlayerAction.DROP_ITEM_STACK : PlayerAction.DROP_ITEM, sourceAction.getToItem().getCount() == 0 ? PlayerAction.DROP_ITEM_STACK : PlayerAction.DROP_ITEM,
new Position(0, 0, 0), BlockFace.DOWN); new Position(0, 0, 0), BlockFace.DOWN);
session.getDownstream().getSession().send(actionPacket); session.sendDownstreamPacket(actionPacket);
ItemStack item = session.getInventory().getItem(heldSlot); ItemStack item = session.getInventory().getItem(heldSlot);
if (item != null) { if (item != null) {
session.getInventory().setItem(heldSlot, new ItemStack(item.getId(), item.getAmount() - 1, item.getNbt())); session.getInventory().setItem(heldSlot, new ItemStack(item.getId(), item.getAmount() - 1, item.getNbt()));
@ -110,14 +110,14 @@ public class InventoryActionDataTranslator {
inventory.getTransactionId().getAndIncrement(), inventory.getTransactionId().getAndIncrement(),
javaSlot, null, WindowAction.DROP_ITEM, javaSlot, null, WindowAction.DROP_ITEM,
DropItemParam.DROP_SELECTED_STACK); DropItemParam.DROP_SELECTED_STACK);
session.getDownstream().getSession().send(dropPacket); session.sendDownstreamPacket(dropPacket);
} else { } else {
for (int i = 0; i < dropAmount; i++) { for (int i = 0; i < dropAmount; i++) {
ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(),
inventory.getTransactionId().getAndIncrement(), inventory.getTransactionId().getAndIncrement(),
javaSlot, null, WindowAction.DROP_ITEM, javaSlot, null, WindowAction.DROP_ITEM,
DropItemParam.DROP_FROM_SELECTED); DropItemParam.DROP_FROM_SELECTED);
session.getDownstream().getSession().send(dropPacket); session.sendDownstreamPacket(dropPacket);
} }
} }
ItemStack item = session.getInventory().getItem(javaSlot); ItemStack item = session.getInventory().getItem(javaSlot);
@ -129,7 +129,7 @@ public class InventoryActionDataTranslator {
ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), inventory.getTransactionId().getAndIncrement(), ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), inventory.getTransactionId().getAndIncrement(),
-999, null, WindowAction.CLICK_ITEM, -999, null, WindowAction.CLICK_ITEM,
dropAmount > 1 ? ClickItemParam.LEFT_CLICK : ClickItemParam.RIGHT_CLICK); dropAmount > 1 ? ClickItemParam.LEFT_CLICK : ClickItemParam.RIGHT_CLICK);
session.getDownstream().getSession().send(dropPacket); session.sendDownstreamPacket(dropPacket);
ItemStack cursor = session.getInventory().getCursor(); ItemStack cursor = session.getInventory().getCursor();
if (cursor != null) { if (cursor != null) {
session.getInventory().setCursor(new ItemStack(cursor.getId(), dropAmount > 1 ? 0 : cursor.getAmount() - 1, cursor.getNbt())); session.getInventory().setCursor(new ItemStack(cursor.getId(), dropAmount > 1 ? 0 : cursor.getAmount() - 1, cursor.getNbt()));
@ -180,7 +180,7 @@ public class InventoryActionDataTranslator {
inventory.getTransactionId().getAndIncrement(), inventory.getTransactionId().getAndIncrement(),
javaSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM, javaSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM,
ShiftClickItemParam.LEFT_CLICK); ShiftClickItemParam.LEFT_CLICK);
session.getDownstream().getSession().send(shiftClickPacket); session.sendDownstreamPacket(shiftClickPacket);
translator.updateInventory(session, inventory); translator.updateInventory(session, inventory);
return; return;
} }
@ -266,7 +266,7 @@ public class InventoryActionDataTranslator {
inventory.getTransactionId().getAndIncrement(), inventory.getTransactionId().getAndIncrement(),
fromSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM, fromSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM,
ShiftClickItemParam.LEFT_CLICK); ShiftClickItemParam.LEFT_CLICK);
session.getDownstream().getSession().send(shiftClickPacket); session.sendDownstreamPacket(shiftClickPacket);
translator.updateInventory(session, inventory); translator.updateInventory(session, inventory);
return; return;
} else if (translator.getSlotType(fromSlot) == SlotType.OUTPUT) { } else if (translator.getSlotType(fromSlot) == SlotType.OUTPUT) {

Datei anzeigen

@ -54,7 +54,7 @@ public class BlockInventoryHolder extends InventoryHolder {
blockPacket.setBlockPosition(position); blockPacket.setBlockPosition(position);
blockPacket.setRuntimeId(blockId); blockPacket.setRuntimeId(blockId);
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
inventory.setHolderPosition(position); inventory.setHolderPosition(position);
CompoundTag tag = CompoundTag.builder() CompoundTag tag = CompoundTag.builder()
@ -65,7 +65,7 @@ public class BlockInventoryHolder extends InventoryHolder {
BlockEntityDataPacket dataPacket = new BlockEntityDataPacket(); BlockEntityDataPacket dataPacket = new BlockEntityDataPacket();
dataPacket.setData(tag); dataPacket.setData(tag);
dataPacket.setBlockPosition(position); dataPacket.setBlockPosition(position);
session.getUpstream().sendPacket(dataPacket); session.sendUpstreamPacket(dataPacket);
} }
@Override @Override
@ -75,7 +75,7 @@ public class BlockInventoryHolder extends InventoryHolder {
containerOpenPacket.setType((byte) containerType.id()); containerOpenPacket.setType((byte) containerType.id());
containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
session.getUpstream().sendPacket(containerOpenPacket); session.sendUpstreamPacket(containerOpenPacket);
} }
@Override @Override
@ -87,6 +87,6 @@ public class BlockInventoryHolder extends InventoryHolder {
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setBlockPosition(holderPos); blockPacket.setBlockPosition(holderPos);
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
} }
} }

Datei anzeigen

@ -54,7 +54,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
InventoryContentPacket contentPacket = new InventoryContentPacket(); InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId()); contentPacket.setContainerId(inventory.getId());
contentPacket.setContents(bedrockItems); contentPacket.setContents(bedrockItems);
session.getUpstream().sendPacket(contentPacket); session.sendUpstreamPacket(contentPacket);
} }
@Override @Override
@ -66,7 +66,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
slotPacket.setContainerId(inventory.getId()); slotPacket.setContainerId(inventory.getId());
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
return true; return true;
} }
} }

Datei anzeigen

@ -46,7 +46,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
InventoryContentPacket contentPacket = new InventoryContentPacket(); InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(inventory.getId()); contentPacket.setContainerId(inventory.getId());
contentPacket.setContents(bedrockItems); contentPacket.setContents(bedrockItems);
session.getUpstream().sendPacket(contentPacket); session.sendUpstreamPacket(contentPacket);
} }
@Override @Override
@ -58,7 +58,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
slotPacket.setContainerId(inventory.getId()); slotPacket.setContainerId(inventory.getId());
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
return true; return true;
} }
} }

Datei anzeigen

@ -45,7 +45,7 @@ public class CursorInventoryUpdater extends InventoryUpdater {
slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setContainerId(ContainerId.CURSOR);
slotPacket.setSlot(bedrockSlot); slotPacket.setSlot(bedrockSlot);
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
} }
} }
@ -58,7 +58,7 @@ public class CursorInventoryUpdater extends InventoryUpdater {
slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setContainerId(ContainerId.CURSOR);
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
return true; return true;
} }
} }

Datei anzeigen

@ -44,7 +44,7 @@ public abstract class InventoryUpdater {
InventoryContentPacket contentPacket = new InventoryContentPacket(); InventoryContentPacket contentPacket = new InventoryContentPacket();
contentPacket.setContainerId(ContainerId.INVENTORY); contentPacket.setContainerId(ContainerId.INVENTORY);
contentPacket.setContents(bedrockItems); contentPacket.setContents(bedrockItems);
session.getUpstream().sendPacket(contentPacket); session.sendUpstreamPacket(contentPacket);
} }
public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) {
@ -53,7 +53,7 @@ public abstract class InventoryUpdater {
slotPacket.setContainerId(ContainerId.INVENTORY); slotPacket.setContainerId(ContainerId.INVENTORY);
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
session.getUpstream().sendPacket(slotPacket); session.sendUpstreamPacket(slotPacket);
return true; return true;
} }
return false; return false;

Datei anzeigen

@ -76,6 +76,6 @@ public class JavaChatTranslator extends PacketTranslator<ServerChatPacket> {
textPacket.setMessage(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), locale, false)); textPacket.setMessage(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), locale, false));
} }
session.getUpstream().sendPacket(textPacket); session.sendUpstreamPacket(textPacket);
} }
} }

Datei anzeigen

@ -90,7 +90,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
} }
} }
craftingDataPacket.getPotionMixData().addAll(POTION_MIXES); craftingDataPacket.getPotionMixData().addAll(POTION_MIXES);
session.getUpstream().sendPacket(craftingDataPacket); session.sendUpstreamPacket(craftingDataPacket);
} }
//TODO: rewrite //TODO: rewrite

Datei anzeigen

@ -39,6 +39,6 @@ public class JavaDifficultyTranslator extends PacketTranslator<ServerDifficultyP
public void translate(ServerDifficultyPacket packet, GeyserSession session) { public void translate(ServerDifficultyPacket packet, GeyserSession session) {
SetDifficultyPacket setDifficultyPacket = new SetDifficultyPacket(); SetDifficultyPacket setDifficultyPacket = new SetDifficultyPacket();
setDifficultyPacket.setDifficulty(packet.getDifficulty().ordinal()); setDifficultyPacket.setDifficulty(packet.getDifficulty().ordinal());
session.getUpstream().sendPacket(setDifficultyPacket); session.sendUpstreamPacket(setDifficultyPacket);
} }
} }

Datei anzeigen

@ -56,21 +56,21 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket(); AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId()); bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
bedrockPacket.setPlayerPermission(PlayerPermission.MEMBER); bedrockPacket.setPlayerPermission(PlayerPermission.MEMBER);
session.getUpstream().sendPacket(bedrockPacket); session.sendUpstreamPacket(bedrockPacket);
PlayStatusPacket playStatus = new PlayStatusPacket(); PlayStatusPacket playStatus = new PlayStatusPacket();
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS); playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
// session.getUpstream().sendPacket(playStatus); // session.sendPacket(playStatus);
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal()); playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
session.getUpstream().sendPacket(playerGameTypePacket); session.sendUpstreamPacket(playerGameTypePacket);
session.setGameMode(packet.getGameMode()); session.setGameMode(packet.getGameMode());
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(entity.getMetadata()); entityDataPacket.getMetadata().putAll(entity.getMetadata());
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
session.setRenderDistance(packet.getViewDistance()); session.setRenderDistance(packet.getViewDistance());
@ -78,7 +78,7 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
String locale = session.getClientData().getLanguageCode(); String locale = session.getClientData().getLanguageCode();
List<SkinPart> skinParts = Arrays.asList(SkinPart.values()); List<SkinPart> skinParts = Arrays.asList(SkinPart.values());
ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, Hand.MAIN_HAND); ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, Hand.MAIN_HAND);
session.getDownstream().getSession().send(clientSettingsPacket); session.sendDownstreamPacket(clientSettingsPacket);
if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) { if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) {
DimensionUtils.switchDimension(session, packet.getDimension()); DimensionUtils.switchDimension(session, packet.getDimension());

Datei anzeigen

@ -12,7 +12,7 @@ public class JavaLoginPluginMessageTranslator extends PacketTranslator<LoginPlug
@Override @Override
public void translate(LoginPluginRequestPacket packet, GeyserSession session) { public void translate(LoginPluginRequestPacket packet, GeyserSession session) {
// 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.
session.getDownstream().getSession().send( session.sendDownstreamPacket(
new LoginPluginResponsePacket(packet.getMessageId(), null) new LoginPluginResponsePacket(packet.getMessageId(), null)
); );
} }

Datei anzeigen

@ -52,7 +52,7 @@ public class JavaPluginMessageTranslator extends PacketTranslator<ServerPluginMe
@Override @Override
public void translate(ServerPluginMessagePacket packet, GeyserSession session) { public void translate(ServerPluginMessagePacket packet, GeyserSession session) {
if (packet.getChannel().equals("minecraft:brand")) { if (packet.getChannel().equals("minecraft:brand")) {
session.getDownstream().getSession().send( session.sendDownstreamPacket(
new ClientPluginMessagePacket(packet.getChannel(), brandData) new ClientPluginMessagePacket(packet.getChannel(), brandData)
); );
} }

Datei anzeigen

@ -57,14 +57,14 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal()); playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
session.getUpstream().sendPacket(playerGameTypePacket); session.sendUpstreamPacket(playerGameTypePacket);
session.setGameMode(packet.getGamemode()); session.setGameMode(packet.getGamemode());
LevelEventPacket stopRainPacket = new LevelEventPacket(); LevelEventPacket stopRainPacket = new LevelEventPacket();
stopRainPacket.setType(LevelEventType.STOP_RAIN); stopRainPacket.setType(LevelEventType.STOP_RAIN);
stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
stopRainPacket.setPosition(Vector3f.ZERO); stopRainPacket.setPosition(Vector3f.ZERO);
session.getUpstream().sendPacket(stopRainPacket); session.sendUpstreamPacket(stopRainPacket);
if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) { if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
DimensionUtils.switchDimension(session, packet.getDimension()); DimensionUtils.switchDimension(session, packet.getDimension());

Datei anzeigen

@ -100,7 +100,7 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
GeyserConnector.getInstance().getLogger().debug("Sending command packet of " + commandData.size() + " commands"); GeyserConnector.getInstance().getLogger().debug("Sending command packet of " + commandData.size() + " commands");
// Finally, send the commands to the client // Finally, send the commands to the client
session.getUpstream().sendPacket(availableCommandsPacket); session.sendUpstreamPacket(availableCommandsPacket);
} }
/** /**

Datei anzeigen

@ -65,6 +65,6 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
break; break;
} }
session.getUpstream().sendPacket(titlePacket); session.sendUpstreamPacket(titlePacket);
} }
} }

Datei anzeigen

@ -62,6 +62,6 @@ public class JavaEntityAnimationTranslator extends PacketTranslator<ServerEntity
break; break;
} }
session.getUpstream().sendPacket(animatePacket); session.sendUpstreamPacket(animatePacket);
} }
} }

Datei anzeigen

@ -55,6 +55,6 @@ public class JavaEntityEffectTranslator extends PacketTranslator<ServerEntityEff
mobEffectPacket.setRuntimeEntityId(entity.getGeyserId()); mobEffectPacket.setRuntimeEntityId(entity.getGeyserId());
mobEffectPacket.setParticles(packet.isShowParticles()); mobEffectPacket.setParticles(packet.isShowParticles());
mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect())); mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect()));
session.getUpstream().sendPacket(mobEffectPacket); session.sendUpstreamPacket(mobEffectPacket);
} }
} }

Datei anzeigen

@ -55,14 +55,14 @@ public class JavaEntityHeadLookTranslator extends PacketTranslator<ServerEntityH
moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId()); moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId());
moveEntityAbsolutePacket.setPosition(entity.getPosition()); moveEntityAbsolutePacket.setPosition(entity.getPosition());
moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation()); moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation());
session.getUpstream().sendPacket(moveEntityAbsolutePacket); session.sendUpstreamPacket(moveEntityAbsolutePacket);
} else { } else {
MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
movePlayerPacket.setPosition(entity.getPosition()); movePlayerPacket.setPosition(entity.getPosition());
movePlayerPacket.setRotation(entity.getBedrockRotation()); movePlayerPacket.setRotation(entity.getBedrockRotation());
movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION); movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION);
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
} }
} }
} }

Datei anzeigen

@ -52,6 +52,6 @@ public class JavaEntityRemoveEffectTranslator extends PacketTranslator<ServerEnt
mobEffectPacket.setEvent(MobEffectPacket.Event.REMOVE); mobEffectPacket.setEvent(MobEffectPacket.Event.REMOVE);
mobEffectPacket.setRuntimeEntityId(entity.getGeyserId()); mobEffectPacket.setRuntimeEntityId(entity.getGeyserId());
mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect())); mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect()));
session.getUpstream().sendPacket(mobEffectPacket); session.sendUpstreamPacket(mobEffectPacket);
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class JavaEntityRotationTranslator extends PacketTranslator<ServerEntityR
moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId()); moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId());
moveEntityAbsolutePacket.setPosition(entity.getPosition()); moveEntityAbsolutePacket.setPosition(entity.getPosition());
moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation()); moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation());
session.getUpstream().sendPacket(moveEntityAbsolutePacket); session.sendUpstreamPacket(moveEntityAbsolutePacket);
} else { } else {
MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
@ -63,7 +63,7 @@ public class JavaEntityRotationTranslator extends PacketTranslator<ServerEntityR
movePlayerPacket.setRotation(entity.getBedrockRotation()); movePlayerPacket.setRotation(entity.getBedrockRotation());
movePlayerPacket.setOnGround(packet.isOnGround()); movePlayerPacket.setOnGround(packet.isOnGround());
movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION); movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION);
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
} }
} }
} }

Datei anzeigen

@ -96,6 +96,6 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
break; break;
} }
session.getUpstream().sendPacket(entityEventPacket); session.sendUpstreamPacket(entityEventPacket);
} }
} }

Datei anzeigen

@ -51,6 +51,6 @@ public class JavaEntityVelocityTranslator extends PacketTranslator<ServerEntityV
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId()); entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
entityMotionPacket.setMotion(entity.getMotion()); entityMotionPacket.setMotion(entity.getMotion());
session.getUpstream().sendPacket(entityMotionPacket); session.sendUpstreamPacket(entityMotionPacket);
} }
} }

Datei anzeigen

@ -57,7 +57,7 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(metadata); entityDataPacket.getMetadata().putAll(metadata);
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>(); Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP); playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP);
@ -73,6 +73,6 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
adventureSettingsPacket.setCommandPermission(CommandPermission.NORMAL); adventureSettingsPacket.setCommandPermission(CommandPermission.NORMAL);
adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId()); adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId());
adventureSettingsPacket.getFlags().addAll(playerFlags); adventureSettingsPacket.getFlags().addAll(playerFlags);
session.getUpstream().sendPacket(adventureSettingsPacket); session.sendUpstreamPacket(adventureSettingsPacket);
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
levelEvent.setType(LevelEventType.DESTROY); levelEvent.setType(LevelEventType.DESTROY);
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock())); levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
session.getUpstream().sendPacket(levelEvent); session.sendUpstreamPacket(levelEvent);
session.setBreakingBlock(null); session.setBreakingBlock(null);
} }
ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition()); ChunkUtils.updateBlock(session, packet.getNewState(), packet.getPosition());
@ -82,7 +82,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
double breakTime = Math.ceil(BlockUtils.getBreakTime(blockHardness, packet.getNewState().getId(), itemEntry, nbtData, session.getPlayerEntity()) * 20); double breakTime = Math.ceil(BlockUtils.getBreakTime(blockHardness, packet.getNewState().getId(), itemEntry, nbtData, session.getPlayerEntity()) * 20);
levelEvent.setData((int) (65535 / breakTime)); levelEvent.setData((int) (65535 / breakTime));
session.setBreakingBlock(packet.getNewState()); session.setBreakingBlock(packet.getNewState());
session.getUpstream().sendPacket(levelEvent); session.sendUpstreamPacket(levelEvent);
break; break;
case CANCEL_DIGGING: case CANCEL_DIGGING:
levelEvent.setType(LevelEventType.BLOCK_STOP_BREAK); levelEvent.setType(LevelEventType.BLOCK_STOP_BREAK);
@ -93,7 +93,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
)); ));
levelEvent.setData(0); levelEvent.setData(0);
session.setBreakingBlock(null); session.setBreakingBlock(null);
session.getUpstream().sendPacket(levelEvent); session.sendUpstreamPacket(levelEvent);
break; break;
} }
} }

Datei anzeigen

@ -40,7 +40,7 @@ public class JavaPlayerChangeHeldItemTranslator extends PacketTranslator<ServerP
hotbarPacket.setContainerId(0); hotbarPacket.setContainerId(0);
hotbarPacket.setSelectedHotbarSlot(packet.getSlot()); hotbarPacket.setSelectedHotbarSlot(packet.getSlot());
hotbarPacket.setSelectHotbarSlot(true); hotbarPacket.setSelectHotbarSlot(true);
session.getUpstream().sendPacket(hotbarPacket); session.sendUpstreamPacket(hotbarPacket);
session.getInventory().setHeldItemSlot(packet.getSlot()); session.getInventory().setHeldItemSlot(packet.getSlot());
} }

Datei anzeigen

@ -46,7 +46,7 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
int health = (int) Math.ceil(packet.getHealth()); int health = (int) Math.ceil(packet.getHealth());
SetHealthPacket setHealthPacket = new SetHealthPacket(); SetHealthPacket setHealthPacket = new SetHealthPacket();
setHealthPacket.setHealth(health); setHealthPacket.setHealth(health);
session.getUpstream().sendPacket(setHealthPacket); session.sendUpstreamPacket(setHealthPacket);
float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f; float maxHealth = entity.getAttributes().containsKey(AttributeType.MAX_HEALTH) ? entity.getAttributes().get(AttributeType.MAX_HEALTH).getValue() : 20f;
// Max health must be divisible by two in bedrock // Max health must be divisible by two in bedrock

Datei anzeigen

@ -81,7 +81,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayer
} }
if (packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER || session.getUpstream().isInitialized()) { if (packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER || session.getUpstream().isInitialized()) {
session.getUpstream().sendPacket(translate); session.sendUpstreamPacket(translate);
} }
} }
} }

Datei anzeigen

@ -62,18 +62,18 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
respawnPacket.setRuntimeEntityId(entity.getGeyserId()); respawnPacket.setRuntimeEntityId(entity.getGeyserId());
respawnPacket.setPosition(pos); respawnPacket.setPosition(pos);
respawnPacket.setState(RespawnPacket.State.SERVER_READY); respawnPacket.setState(RespawnPacket.State.SERVER_READY);
session.getUpstream().sendPacket(respawnPacket); session.sendUpstreamPacket(respawnPacket);
EntityEventPacket eventPacket = new EntityEventPacket(); EntityEventPacket eventPacket = new EntityEventPacket();
eventPacket.setRuntimeEntityId(entity.getGeyserId()); eventPacket.setRuntimeEntityId(entity.getGeyserId());
eventPacket.setType(EntityEventType.RESPAWN); eventPacket.setType(EntityEventType.RESPAWN);
eventPacket.setData(0); eventPacket.setData(0);
session.getUpstream().sendPacket(eventPacket); session.sendUpstreamPacket(eventPacket);
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(entity.getMetadata()); entityDataPacket.getMetadata().putAll(entity.getMetadata());
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
@ -81,11 +81,11 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0)); movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0));
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET); movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET);
session.getUpstream().sendPacket(movePlayerPacket); session.sendUpstreamPacket(movePlayerPacket);
session.setSpawned(true); session.setSpawned(true);
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId()); ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
session.getDownstream().getSession().send(teleportConfirmPacket); session.sendDownstreamPacket(teleportConfirmPacket);
ChunkUtils.updateChunkPosition(session, pos.toInt()); ChunkUtils.updateChunkPosition(session, pos.toInt());
@ -107,7 +107,7 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), true, true); entity.moveAbsolute(session, Vector3f.from(packet.getX(), packet.getY(), packet.getZ()), packet.getYaw(), packet.getPitch(), true, true);
} else { } else {
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId()); ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
session.getDownstream().getSession().send(teleportConfirmPacket); session.sendDownstreamPacket(teleportConfirmPacket);
} }
} }
} }

Datei anzeigen

@ -68,7 +68,7 @@ public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSo
// packet not mapped in the library // packet not mapped in the library
stopSoundPacket.setStoppingAllSound(false); stopSoundPacket.setStoppingAllSound(false);
session.getUpstream().sendPacket(stopSoundPacket); session.sendUpstreamPacket(stopSoundPacket);
session.getConnector().getLogger().debug("[StopSound] Packet sent - " + packet.toString() + " --> " + stopSoundPacket); session.getConnector().getLogger().debug("[StopSound] Packet sent - " + packet.toString() + " --> " + stopSoundPacket);
} }
} }

Datei anzeigen

@ -39,7 +39,7 @@ public class JavaCloseWindowTranslator extends PacketTranslator<ServerCloseWindo
public void translate(ServerCloseWindowPacket packet, GeyserSession session) { public void translate(ServerCloseWindowPacket packet, GeyserSession session) {
ContainerClosePacket closePacket = new ContainerClosePacket(); ContainerClosePacket closePacket = new ContainerClosePacket();
closePacket.setWindowId((byte)packet.getWindowId()); closePacket.setWindowId((byte)packet.getWindowId());
session.getUpstream().sendPacket(closePacket); session.sendUpstreamPacket(closePacket);
InventoryUtils.closeInventory(session, packet.getWindowId()); InventoryUtils.closeInventory(session, packet.getWindowId());
} }
} }

Datei anzeigen

@ -27,12 +27,9 @@ package org.geysermc.connector.network.translators.java.window;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket;
import org.geysermc.connector.inventory.Inventory;
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.inventory.InventoryTranslator;
import org.geysermc.connector.utils.InventoryUtils;
@Translator(packet = ServerConfirmTransactionPacket.class) @Translator(packet = ServerConfirmTransactionPacket.class)
public class JavaConfirmTransactionTranslator extends PacketTranslator<ServerConfirmTransactionPacket> { public class JavaConfirmTransactionTranslator extends PacketTranslator<ServerConfirmTransactionPacket> {
@ -41,7 +38,7 @@ public class JavaConfirmTransactionTranslator extends PacketTranslator<ServerCon
public void translate(ServerConfirmTransactionPacket packet, GeyserSession session) { public void translate(ServerConfirmTransactionPacket packet, GeyserSession session) {
if (!packet.isAccepted()) { if (!packet.isAccepted()) {
ClientConfirmTransactionPacket confirmPacket = new ClientConfirmTransactionPacket(packet.getWindowId(), packet.getActionId(), true); ClientConfirmTransactionPacket confirmPacket = new ClientConfirmTransactionPacket(packet.getWindowId(), packet.getActionId(), true);
session.getDownstream().getSession().send(confirmPacket); session.sendDownstreamPacket(confirmPacket);
} }
} }
} }

Datei anzeigen

@ -55,11 +55,11 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
if (openInventory != null) { if (openInventory != null) {
ContainerClosePacket closePacket = new ContainerClosePacket(); ContainerClosePacket closePacket = new ContainerClosePacket();
closePacket.setWindowId((byte)openInventory.getId()); closePacket.setWindowId((byte)openInventory.getId());
session.getUpstream().sendPacket(closePacket); session.sendUpstreamPacket(closePacket);
Translators.getInventoryTranslators().get(openInventory.getWindowType()).closeInventory(session, openInventory); Translators.getInventoryTranslators().get(openInventory.getWindowType()).closeInventory(session, openInventory);
} }
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId()); ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId());
session.getDownstream().getSession().send(closeWindowPacket); session.sendDownstreamPacket(closeWindowPacket);
return; return;
} }

Datei anzeigen

@ -84,7 +84,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
placeBlockSoundPacket.setBabySound(false); placeBlockSoundPacket.setBabySound(false);
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(packet.getRecord().getBlock())); placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(packet.getRecord().getBlock()));
placeBlockSoundPacket.setIdentifier(":"); placeBlockSoundPacket.setIdentifier(":");
session.getUpstream().sendPacket(placeBlockSoundPacket); session.sendUpstreamPacket(placeBlockSoundPacket);
session.setLastBlockPlacePosition(null); session.setLastBlockPlacePosition(null);
session.setLastBlockPlacedId(null); session.setLastBlockPlacedId(null);
return true; return true;

Datei anzeigen

@ -53,11 +53,11 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
ChestValue value = (ChestValue) packet.getValue() ; ChestValue value = (ChestValue) packet.getValue() ;
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
blockEventPacket.setEventData(value.getViewers() > 0 ? 1 : 0); blockEventPacket.setEventData(value.getViewers() > 0 ? 1 : 0);
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} }
if (packet.getValue() instanceof EndGatewayValue) { if (packet.getValue() instanceof EndGatewayValue) {
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} }
if (packet.getValue() instanceof NoteBlockValue) { if (packet.getValue() instanceof NoteBlockValue) {
NoteblockBlockEntityTranslator.translate(session, packet.getPosition()); NoteblockBlockEntityTranslator.translate(session, packet.getPosition());
@ -77,15 +77,15 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
} }
if (packet.getValue() instanceof BeaconValue) { if (packet.getValue() instanceof BeaconValue) {
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} }
if (packet.getValue() instanceof MobSpawnerValue) { if (packet.getValue() instanceof MobSpawnerValue) {
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} }
if (packet.getValue() instanceof EndGatewayValue) { if (packet.getValue() instanceof EndGatewayValue) {
blockEventPacket.setEventType(1); blockEventPacket.setEventType(1);
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
} }
} }
@ -101,7 +101,7 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
blockEntityDataPacket.setBlockPosition(position); blockEntityDataPacket.setBlockPosition(position);
byte state = (byte) ((progress == 1.0f && lastProgress == 1.0f) ? 2 : 1); byte state = (byte) ((progress == 1.0f && lastProgress == 1.0f) ? 2 : 1);
blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state)); blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state));
session.getUpstream().sendPacket(blockEntityDataPacket); session.sendUpstreamPacket(blockEntityDataPacket);
if (lastProgress != 1.0f) { if (lastProgress != 1.0f) {
session.getConnector().getGeneralThreadPool().schedule(() -> session.getConnector().getGeneralThreadPool().schedule(() ->
extendPiston(session, position, (progress >= 1.0f) ? 1.0f : progress + 0.5f, progress), extendPiston(session, position, (progress >= 1.0f) ? 1.0f : progress + 0.5f, progress),
@ -121,7 +121,7 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
blockEntityDataPacket.setBlockPosition(position); blockEntityDataPacket.setBlockPosition(position);
byte state = (byte) ((progress == 0.0f && lastProgress == 0.0f) ? 0 : 3); byte state = (byte) ((progress == 0.0f && lastProgress == 0.0f) ? 0 : 3);
blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state)); blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state));
session.getUpstream().sendPacket(blockEntityDataPacket); session.sendUpstreamPacket(blockEntityDataPacket);
if (lastProgress != 0.0f) { if (lastProgress != 0.0f) {
session.getConnector().getGeneralThreadPool().schedule(() -> session.getConnector().getGeneralThreadPool().schedule(() ->
retractPiston(session, position, (progress <= 0.0f) ? 0.0f : progress - 0.5f, progress), retractPiston(session, position, (progress <= 0.0f) ? 0.0f : progress - 0.5f, progress),

Datei anzeigen

@ -98,7 +98,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
levelChunkPacket.setChunkX(packet.getColumn().getX()); levelChunkPacket.setChunkX(packet.getColumn().getX());
levelChunkPacket.setChunkZ(packet.getColumn().getZ()); levelChunkPacket.setChunkZ(packet.getColumn().getZ());
levelChunkPacket.setData(payload); levelChunkPacket.setData(payload);
session.getUpstream().sendPacket(levelChunkPacket); session.sendUpstreamPacket(levelChunkPacket);
// Some block entities need to be loaded in later or else text doesn't show (signs) or they crash the game (end gateway blocks) // Some block entities need to be loaded in later or else text doesn't show (signs) or they crash the game (end gateway blocks)
for (Object2IntMap.Entry<CompoundTag> blockEntityEntry : chunkData.getLoadBlockEntitiesLater().object2IntEntrySet()) { for (Object2IntMap.Entry<CompoundTag> blockEntityEntry : chunkData.getLoadBlockEntitiesLater().object2IntEntrySet()) {

Datei anzeigen

@ -50,6 +50,6 @@ public class JavaCollectItemTranslator extends PacketTranslator<ServerEntityColl
} }
takeItemEntityPacket.setRuntimeEntityId(collectorEntity.getGeyserId()); takeItemEntityPacket.setRuntimeEntityId(collectorEntity.getGeyserId());
takeItemEntityPacket.setItemRuntimeEntityId(collectedEntity.getGeyserId()); takeItemEntityPacket.setItemRuntimeEntityId(collectedEntity.getGeyserId());
session.getUpstream().sendPacket(takeItemEntityPacket); session.sendUpstreamPacket(takeItemEntityPacket);
} }
} }

Datei anzeigen

@ -29,7 +29,6 @@ package org.geysermc.connector.network.translators.java.world;
import com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord; import com.github.steveice10.mc.protocol.data.game.world.block.ExplodedBlockRecord;
import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerExplosionPacket; import com.github.steveice10.mc.protocol.packet.ingame.server.world.ServerExplosionPacket;
import com.nukkitx.math.vector.Vector3f; import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.math.vector.Vector3i;
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.packet.LevelEventPacket; import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
@ -52,7 +51,7 @@ public class JavaExplosionTranslator extends PacketTranslator<ServerExplosionPac
levelEventPacket.setType(LevelEventType.PARTICLE_LARGE_EXPLOSION); levelEventPacket.setType(LevelEventType.PARTICLE_LARGE_EXPLOSION);
levelEventPacket.setData(0); levelEventPacket.setData(0);
levelEventPacket.setPosition(pos.toFloat()); levelEventPacket.setPosition(pos.toFloat());
session.getUpstream().sendPacket(levelEventPacket); session.sendUpstreamPacket(levelEventPacket);
ChunkUtils.updateBlock(session, BlockTranslator.AIR, pos.toInt()); ChunkUtils.updateBlock(session, BlockTranslator.AIR, pos.toInt());
} }
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket(); LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
@ -62,6 +61,6 @@ public class JavaExplosionTranslator extends PacketTranslator<ServerExplosionPac
levelSoundEventPacket.setSound(SoundEvent.EXPLODE); levelSoundEventPacket.setSound(SoundEvent.EXPLODE);
levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setIdentifier(":");
levelSoundEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); levelSoundEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(levelSoundEventPacket); session.sendUpstreamPacket(levelSoundEventPacket);
} }
} }

Datei anzeigen

@ -61,14 +61,14 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
startRainPacket.setType(LevelEventType.START_RAIN); startRainPacket.setType(LevelEventType.START_RAIN);
startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
startRainPacket.setPosition(Vector3f.ZERO); startRainPacket.setPosition(Vector3f.ZERO);
session.getUpstream().sendPacket(startRainPacket); session.sendUpstreamPacket(startRainPacket);
break; break;
case STOP_RAIN: case STOP_RAIN:
LevelEventPacket stopRainPacket = new LevelEventPacket(); LevelEventPacket stopRainPacket = new LevelEventPacket();
stopRainPacket.setType(LevelEventType.STOP_RAIN); stopRainPacket.setType(LevelEventType.STOP_RAIN);
stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
stopRainPacket.setPosition(Vector3f.ZERO); stopRainPacket.setPosition(Vector3f.ZERO);
session.getUpstream().sendPacket(stopRainPacket); session.sendUpstreamPacket(stopRainPacket);
break; break;
case CHANGE_GAMEMODE: case CHANGE_GAMEMODE:
Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>(); Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
@ -89,14 +89,14 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
playerGameTypePacket.setGamemode(gameMode.ordinal()); playerGameTypePacket.setGamemode(gameMode.ordinal());
session.getUpstream().sendPacket(playerGameTypePacket); session.sendUpstreamPacket(playerGameTypePacket);
session.setGameMode(gameMode); session.setGameMode(gameMode);
AdventureSettingsPacket adventureSettingsPacket = new AdventureSettingsPacket(); AdventureSettingsPacket adventureSettingsPacket = new AdventureSettingsPacket();
adventureSettingsPacket.setPlayerPermission(PlayerPermission.MEMBER); adventureSettingsPacket.setPlayerPermission(PlayerPermission.MEMBER);
adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId()); adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId());
adventureSettingsPacket.getFlags().addAll(playerFlags); adventureSettingsPacket.getFlags().addAll(playerFlags);
session.getUpstream().sendPacket(adventureSettingsPacket); session.sendUpstreamPacket(adventureSettingsPacket);
EntityDataMap metadata = entity.getMetadata(); EntityDataMap metadata = entity.getMetadata();
metadata.getFlags().setFlag(EntityFlag.CAN_FLY, gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR); metadata.getFlags().setFlag(EntityFlag.CAN_FLY, gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR);
@ -104,7 +104,7 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
entityDataPacket.getMetadata().putAll(metadata); entityDataPacket.getMetadata().putAll(metadata);
session.getUpstream().sendPacket(entityDataPacket); session.sendUpstreamPacket(entityDataPacket);
// Update the crafting grid to add/remove barriers for creative inventory // Update the crafting grid to add/remove barriers for creative inventory
PlayerInventoryTranslator.updateCraftingGrid(session, session.getInventory()); PlayerInventoryTranslator.updateCraftingGrid(session, session.getInventory());
@ -114,13 +114,13 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
switch ((EnterCreditsValue) packet.getValue()) { switch ((EnterCreditsValue) packet.getValue()) {
case SEEN_BEFORE: case SEEN_BEFORE:
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN); ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
session.getDownstream().getSession().send(javaRespawnPacket); session.sendDownstreamPacket(javaRespawnPacket);
break; break;
case FIRST_TIME: case FIRST_TIME:
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket(); ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS); showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId()); showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
session.getUpstream().sendPacket(showCreditsPacket); session.sendUpstreamPacket(showCreditsPacket);
break; break;
} }
break; break;

Datei anzeigen

@ -57,7 +57,7 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
levelEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); levelEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
levelEventPacket.setData(0); levelEventPacket.setData(0);
levelEventPacket.setType(LevelEventType.valueOf(soundMapping.getBedrock())); levelEventPacket.setType(LevelEventType.valueOf(soundMapping.getBedrock()));
session.getUpstream().sendPacket(levelEventPacket); session.sendUpstreamPacket(levelEventPacket);
return; return;
} }
LevelSoundEventPacket soundPacket = new LevelSoundEventPacket(); LevelSoundEventPacket soundPacket = new LevelSoundEventPacket();
@ -92,7 +92,7 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
soundPacket.setBabySound(false); // might need to adjust this in the future soundPacket.setBabySound(false); // might need to adjust this in the future
soundPacket.setRelativeVolumeDisabled(false); soundPacket.setRelativeVolumeDisabled(false);
session.getUpstream().sendPacket(soundPacket); session.sendUpstreamPacket(soundPacket);
session.getConnector().getLogger().debug("Packet sent - " + packet.toString() + " --> " + soundPacket.toString()); session.getConnector().getLogger().debug("Packet sent - " + packet.toString() + " --> " + soundPacket.toString());
} }
} }

Datei anzeigen

@ -90,12 +90,12 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
soundEvent.setExtraData(-1); soundEvent.setExtraData(-1);
soundEvent.setBabySound(false); soundEvent.setBabySound(false);
soundEvent.setRelativeVolumeDisabled(false); soundEvent.setRelativeVolumeDisabled(false);
session.getUpstream().sendPacket(soundEvent); session.sendUpstreamPacket(soundEvent);
break; break;
case BLOCK_LAVA_EXTINGUISH: case BLOCK_LAVA_EXTINGUISH:
effect.setType(LevelEventType.SHOOT); effect.setType(LevelEventType.SHOOT);
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY() + 1, packet.getPosition().getZ())); effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY() + 1, packet.getPosition().getZ()));
session.getUpstream().sendPacket(effect); session.sendUpstreamPacket(effect);
LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket(); LevelSoundEventPacket soundEventPacket = new LevelSoundEventPacket();
soundEventPacket.setSound(SoundEvent.EXTINGUISH_FIRE); soundEventPacket.setSound(SoundEvent.EXTINGUISH_FIRE);
@ -104,14 +104,14 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
soundEventPacket.setExtraData(-1); soundEventPacket.setExtraData(-1);
soundEventPacket.setBabySound(false); soundEventPacket.setBabySound(false);
soundEventPacket.setRelativeVolumeDisabled(false); soundEventPacket.setRelativeVolumeDisabled(false);
session.getUpstream().sendPacket(soundEventPacket); session.sendUpstreamPacket(soundEventPacket);
return; return;
default: default:
GeyserConnector.getInstance().getLogger().debug("No effect handling for particle effect: " + packet.getEffect()); GeyserConnector.getInstance().getLogger().debug("No effect handling for particle effect: " + packet.getEffect());
} }
} }
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.getUpstream().sendPacket(effect); session.sendUpstreamPacket(effect);
} else if (packet.getEffect() instanceof SoundEffect) { } else if (packet.getEffect() instanceof SoundEffect) {
SoundEffect soundEffect = (SoundEffect) packet.getEffect(); SoundEffect soundEffect = (SoundEffect) packet.getEffect();
Effect geyserEffect = EffectUtils.EFFECTS.get(soundEffect.name()); Effect geyserEffect = EffectUtils.EFFECTS.get(soundEffect.name());
@ -131,7 +131,7 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
soundEvent.setExtraData(geyserEffect.getData()); soundEvent.setExtraData(geyserEffect.getData());
soundEvent.setIdentifier(geyserEffect.getIdentifier()); soundEvent.setIdentifier(geyserEffect.getIdentifier());
soundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); soundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.getUpstream().sendPacket(soundEvent); session.sendUpstreamPacket(soundEvent);
} }
} else { } else {
GeyserConnector.getInstance().getLogger().debug("No effect handling for sound effect: " + packet.getEffect()); GeyserConnector.getInstance().getLogger().debug("No effect handling for sound effect: " + packet.getEffect());
@ -139,7 +139,7 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
} }
if (effect.getType() != null) { if (effect.getType() != null) {
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
session.getUpstream().sendPacket(effect); session.sendUpstreamPacket(effect);
} }
} }

Datei anzeigen

@ -72,7 +72,7 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
playSoundPacket.setVolume(packet.getVolume()); playSoundPacket.setVolume(packet.getVolume());
playSoundPacket.setPitch(packet.getPitch()); playSoundPacket.setPitch(packet.getPitch());
session.getUpstream().sendPacket(playSoundPacket); session.sendUpstreamPacket(playSoundPacket);
session.getConnector().getLogger().debug("[PlaySound] Packet sent - " + packet.toString() + " --> " + playSoundPacket); session.getConnector().getLogger().debug("[PlaySound] Packet sent - " + packet.toString() + " --> " + playSoundPacket);
} }
} }

Datei anzeigen

@ -52,7 +52,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
particle.setType(LevelEventType.DESTROY); particle.setType(LevelEventType.DESTROY);
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
particle.setData(BlockTranslator.getBedrockBlockId(((BlockParticleData) packet.getParticle().getData()).getBlockState())); particle.setData(BlockTranslator.getBedrockBlockId(((BlockParticleData) packet.getParticle().getData()).getBlockState()));
session.getUpstream().sendPacket(particle); session.sendUpstreamPacket(particle);
break; break;
case FALLING_DUST: case FALLING_DUST:
//In fact, FallingDustParticle should have data like DustParticle, //In fact, FallingDustParticle should have data like DustParticle,
@ -60,7 +60,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
particle.setType(LevelEventType.PARTICLE_FALLING_DUST); particle.setType(LevelEventType.PARTICLE_FALLING_DUST);
particle.setData(BlockTranslator.getBedrockBlockId(((FallingDustParticleData)packet.getParticle().getData()).getBlockState())); particle.setData(BlockTranslator.getBedrockBlockId(((FallingDustParticleData)packet.getParticle().getData()).getBlockState()));
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(particle); session.sendUpstreamPacket(particle);
break; break;
case ITEM: case ITEM:
ItemStack javaItem = ((ItemParticleData)packet.getParticle().getData()).getItemStack(); ItemStack javaItem = ((ItemParticleData)packet.getParticle().getData()).getItemStack();
@ -70,7 +70,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
particle.setType(LevelEventType.PARTICLE_ITEM_BREAK); particle.setType(LevelEventType.PARTICLE_ITEM_BREAK);
particle.setData(id << 16 | damage); particle.setData(id << 16 | damage);
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(particle); session.sendUpstreamPacket(particle);
break; break;
case DUST: case DUST:
DustParticleData data = (DustParticleData)packet.getParticle().getData(); DustParticleData data = (DustParticleData)packet.getParticle().getData();
@ -80,14 +80,14 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
particle.setType(LevelEventType.PARTICLE_FALLING_DUST); particle.setType(LevelEventType.PARTICLE_FALLING_DUST);
particle.setData(((0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)); particle.setData(((0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff));
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(particle); session.sendUpstreamPacket(particle);
break; break;
default: default:
LevelEventType typeParticle = EffectUtils.getParticleLevelEventType(packet.getParticle().getType()); LevelEventType typeParticle = EffectUtils.getParticleLevelEventType(packet.getParticle().getType());
if (typeParticle != null) { if (typeParticle != null) {
particle.setType(typeParticle); particle.setType(typeParticle);
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(particle); session.sendUpstreamPacket(particle);
} else { } else {
String stringParticle = EffectUtils.getParticleString(packet.getParticle().getType()); String stringParticle = EffectUtils.getParticleString(packet.getParticle().getType());
if (stringParticle != null) { if (stringParticle != null) {
@ -95,7 +95,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
stringPacket.setIdentifier(stringParticle); stringPacket.setIdentifier(stringParticle);
stringPacket.setDimensionId(session.getPlayerEntity().getDimension()); stringPacket.setDimensionId(session.getPlayerEntity().getDimension());
stringPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ())); stringPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
session.getUpstream().sendPacket(stringPacket); session.sendUpstreamPacket(stringPacket);
} }
} }
break; break;

Datei anzeigen

@ -42,6 +42,6 @@ public class JavaSpawnPositionTranslator extends PacketTranslator<ServerSpawnPos
spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ())); spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
spawnPositionPacket.setSpawnForced(true); spawnPositionPacket.setSpawnForced(true);
spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.WORLD_SPAWN); spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.WORLD_SPAWN);
session.getUpstream().sendPacket(spawnPositionPacket); session.sendUpstreamPacket(spawnPositionPacket);
} }
} }

Datei anzeigen

@ -55,7 +55,7 @@ public class JavaUpdateTimeTranslator extends PacketTranslator<ServerUpdateTimeP
// https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day // https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day
SetTimePacket setTimePacket = new SetTimePacket(); SetTimePacket setTimePacket = new SetTimePacket();
setTimePacket.setTime((int) Math.abs(time) % 24000); setTimePacket.setTime((int) Math.abs(time) % 24000);
session.getUpstream().sendPacket(setTimePacket); session.sendUpstreamPacket(setTimePacket);
// TODO: Performance efficient to always do this? // TODO: Performance efficient to always do this?
LAST_RECORDED_TIMES.put(session.getPlayerEntity().getEntityId(), time); LAST_RECORDED_TIMES.put(session.getPlayerEntity().getEntityId(), time);
} }
@ -69,7 +69,7 @@ public class JavaUpdateTimeTranslator extends PacketTranslator<ServerUpdateTimeP
private void setDoDaylightCycleGamerule(GeyserSession session, boolean doCycle) { private void setDoDaylightCycleGamerule(GeyserSession session, boolean doCycle) {
GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket();
gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle)); gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle));
session.getUpstream().sendPacket(gameRulesChangedPacket); session.sendUpstreamPacket(gameRulesChangedPacket);
} }
} }

Datei anzeigen

@ -67,7 +67,7 @@ public class BucketSoundInteractionHandler implements BlockSoundInteractionHandl
} }
if (soundEvent != null) { if (soundEvent != null) {
soundEventPacket.setSound(soundEvent); soundEventPacket.setSound(soundEvent);
session.getUpstream().sendPacket(soundEventPacket); session.sendUpstreamPacket(soundEventPacket);
} }
} }
} }

Datei anzeigen

@ -43,6 +43,6 @@ public class ComparatorSoundInteractHandler implements BlockSoundInteractionHand
levelEventPacket.setPosition(position); levelEventPacket.setPosition(position);
levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER); levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
levelEventPacket.setData(powered ? 500 : 550); levelEventPacket.setData(powered ? 500 : 550);
session.getUpstream().sendPacket(levelEventPacket); session.sendUpstreamPacket(levelEventPacket);
} }
} }

Datei anzeigen

@ -42,6 +42,6 @@ public class DoorSoundInteractionHandler implements BlockSoundInteractionHandler
levelEventPacket.setType(LevelEventType.SOUND_DOOR); levelEventPacket.setType(LevelEventType.SOUND_DOOR);
levelEventPacket.setPosition(position); levelEventPacket.setPosition(position);
levelEventPacket.setData(0); levelEventPacket.setData(0);
session.getUpstream().sendPacket(levelEventPacket); session.sendUpstreamPacket(levelEventPacket);
} }
} }

Datei anzeigen

@ -45,6 +45,6 @@ public class FlintAndSteelInteractionHandler implements BlockSoundInteractionHan
levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setIdentifier(":");
levelSoundEventPacket.setSound(SoundEvent.IGNITE); levelSoundEventPacket.setSound(SoundEvent.IGNITE);
levelSoundEventPacket.setExtraData(-1); levelSoundEventPacket.setExtraData(-1);
session.getUpstream().sendPacket(levelSoundEventPacket); session.sendUpstreamPacket(levelSoundEventPacket);
} }
} }

Datei anzeigen

@ -46,6 +46,6 @@ public class GrassPathInteractionHandler implements BlockSoundInteractionHandler
levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setIdentifier(":");
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON); levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier))); levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier)));
session.getUpstream().sendPacket(levelSoundEventPacket); session.sendUpstreamPacket(levelSoundEventPacket);
} }
} }

Datei anzeigen

@ -46,6 +46,6 @@ public class HoeInteractionHandler implements BlockSoundInteractionHandler {
levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setIdentifier(":");
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON); levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier))); levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier)));
session.getUpstream().sendPacket(levelSoundEventPacket); session.sendUpstreamPacket(levelSoundEventPacket);
} }
} }

Datei anzeigen

@ -43,6 +43,6 @@ public class LeverSoundInteractionHandler implements BlockSoundInteractionHandle
levelEventPacket.setPosition(position); levelEventPacket.setPosition(position);
levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER); levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
levelEventPacket.setData(powered ? 600 : 500); levelEventPacket.setData(powered ? 600 : 500);
session.getUpstream().sendPacket(levelEventPacket); session.sendUpstreamPacket(levelEventPacket);
} }
} }

Datei anzeigen

@ -50,6 +50,6 @@ public class MilkCowSoundInteractionHandler implements EntitySoundInteractionHan
levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setIdentifier(":");
levelSoundEventPacket.setSound(SoundEvent.MILK); levelSoundEventPacket.setSound(SoundEvent.MILK);
levelSoundEventPacket.setExtraData(-1); levelSoundEventPacket.setExtraData(-1);
session.getUpstream().sendPacket(levelSoundEventPacket); session.sendUpstreamPacket(levelSoundEventPacket);
} }
} }

Datei anzeigen

@ -53,7 +53,7 @@ public class FlowerPotBlockEntityTranslator implements BedrockOnlyBlockEntity, R
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.getUpstream().sendPacket(updateBlockPacket); session.sendUpstreamPacket(updateBlockPacket);
} }
/** /**

Datei anzeigen

@ -50,7 +50,7 @@ public class NoteblockBlockEntityTranslator implements RequiresBlockState {
blockEventPacket.setBlockPosition(Vector3i.from(position.getX(), position.getY(), position.getZ())); blockEventPacket.setBlockPosition(Vector3i.from(position.getX(), position.getY(), position.getZ()));
blockEventPacket.setEventType(0); blockEventPacket.setEventType(0);
blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState)); blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState));
session.getUpstream().sendPacket(blockEventPacket); session.sendUpstreamPacket(blockEventPacket);
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(position); ChunkUtils.CACHED_BLOCK_ENTITIES.remove(position);
} }

Datei anzeigen

@ -187,7 +187,7 @@ public class Scoreboard {
if (objective.getUpdateType() == REMOVE || update) { if (objective.getUpdateType() == REMOVE || update) {
RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket();
removeObjectivePacket.setObjectiveId(objective.getObjectiveName()); removeObjectivePacket.setObjectiveId(objective.getObjectiveName());
session.getUpstream().sendPacket(removeObjectivePacket); session.sendUpstreamPacket(removeObjectivePacket);
if (objective.getUpdateType() == REMOVE) { if (objective.getUpdateType() == REMOVE) {
objectives.remove(objective.getObjectiveName()); // now we can deregister objectives.remove(objective.getObjectiveName()); // now we can deregister
} }
@ -199,7 +199,7 @@ public class Scoreboard {
displayObjectivePacket.setCriteria("dummy"); displayObjectivePacket.setCriteria("dummy");
displayObjectivePacket.setDisplaySlot(objective.getDisplaySlot()); displayObjectivePacket.setDisplaySlot(objective.getDisplaySlot());
displayObjectivePacket.setSortOrder(1); // ?? displayObjectivePacket.setSortOrder(1); // ??
session.getUpstream().sendPacket(displayObjectivePacket); session.sendUpstreamPacket(displayObjectivePacket);
} }
objective.setUpdateType(NOTHING); objective.setUpdateType(NOTHING);
} }
@ -208,21 +208,21 @@ public class Scoreboard {
SetScorePacket setScorePacket = new SetScorePacket(); SetScorePacket setScorePacket = new SetScorePacket();
setScorePacket.setAction(SetScorePacket.Action.REMOVE); setScorePacket.setAction(SetScorePacket.Action.REMOVE);
setScorePacket.setInfos(removeScores); setScorePacket.setInfos(removeScores);
session.getUpstream().sendPacket(setScorePacket); session.sendUpstreamPacket(setScorePacket);
} }
if (!addScores.isEmpty()) { if (!addScores.isEmpty()) {
SetScorePacket setScorePacket = new SetScorePacket(); SetScorePacket setScorePacket = new SetScorePacket();
setScorePacket.setAction(SetScorePacket.Action.SET); setScorePacket.setAction(SetScorePacket.Action.SET);
setScorePacket.setInfos(addScores); setScorePacket.setInfos(addScores);
session.getUpstream().sendPacket(setScorePacket); session.sendUpstreamPacket(setScorePacket);
} }
} }
public void despawnObjective(Objective objective) { public void despawnObjective(Objective objective) {
RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket();
removeObjectivePacket.setObjectiveId(objective.getObjectiveName()); removeObjectivePacket.setObjectiveId(objective.getObjectiveName());
session.getUpstream().sendPacket(removeObjectivePacket); session.sendUpstreamPacket(removeObjectivePacket);
objectives.remove(objective.getDisplayName()); objectives.remove(objective.getDisplayName());
List<ScoreInfo> toRemove = new ArrayList<>(); List<ScoreInfo> toRemove = new ArrayList<>();
@ -238,7 +238,7 @@ public class Scoreboard {
SetScorePacket setScorePacket = new SetScorePacket(); SetScorePacket setScorePacket = new SetScorePacket();
setScorePacket.setAction(SetScorePacket.Action.REMOVE); setScorePacket.setAction(SetScorePacket.Action.REMOVE);
setScorePacket.setInfos(toRemove); setScorePacket.setInfos(toRemove);
session.getUpstream().sendPacket(setScorePacket); session.sendUpstreamPacket(setScorePacket);
} }
} }

Datei anzeigen

@ -49,6 +49,6 @@ public class BlockEntityUtils {
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket(); BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
blockEntityPacket.setBlockPosition(position); blockEntityPacket.setBlockPosition(position);
blockEntityPacket.setData(blockEntity); blockEntityPacket.setData(blockEntity);
session.getUpstream().sendPacket(blockEntityPacket); session.sendUpstreamPacket(blockEntityPacket);
} }
} }

Datei anzeigen

@ -156,7 +156,7 @@ public class ChunkUtils {
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket(); NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
chunkPublisherUpdatePacket.setPosition(position); chunkPublisherUpdatePacket.setPosition(position);
chunkPublisherUpdatePacket.setRadius(session.getRenderDistance() << 4); chunkPublisherUpdatePacket.setRadius(session.getRenderDistance() << 4);
session.getUpstream().sendPacket(chunkPublisherUpdatePacket); session.sendUpstreamPacket(chunkPublisherUpdatePacket);
session.setLastChunkPosition(newChunkPos); session.setLastChunkPosition(newChunkPos);
} }
@ -188,7 +188,7 @@ public class ChunkUtils {
updateBlockPacket.setBlockPosition(position); updateBlockPacket.setBlockPosition(position);
updateBlockPacket.setRuntimeId(blockId); updateBlockPacket.setRuntimeId(blockId);
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
session.getUpstream().sendPacket(updateBlockPacket); session.sendUpstreamPacket(updateBlockPacket);
UpdateBlockPacket waterPacket = new UpdateBlockPacket(); UpdateBlockPacket waterPacket = new UpdateBlockPacket();
waterPacket.setDataLayer(1); waterPacket.setDataLayer(1);
@ -198,7 +198,7 @@ public class ChunkUtils {
} else { } else {
waterPacket.setRuntimeId(0); waterPacket.setRuntimeId(0);
} }
session.getUpstream().sendPacket(waterPacket); session.sendUpstreamPacket(waterPacket);
// Since Java stores bed colors/skull information as part of the namespaced ID and Bedrock stores it as a tag // Since Java stores bed colors/skull information as part of the namespaced ID and Bedrock stores it as a tag
// This is the only place I could find that interacts with the Java block state and block updates // This is the only place I could find that interacts with the Java block state and block updates
@ -228,7 +228,7 @@ public class ChunkUtils {
data.setSubChunksLength(0); data.setSubChunksLength(0);
data.setData(Translators.EMPTY_LEVEL_CHUNK_DATA); data.setData(Translators.EMPTY_LEVEL_CHUNK_DATA);
data.setCachingEnabled(false); data.setCachingEnabled(false);
session.getUpstream().sendPacket(data); session.sendUpstreamPacket(data);
if (forceUpdate) { if (forceUpdate) {
Vector3i pos = Vector3i.from(chunkX + x << 4, 80, chunkZ + z << 4); Vector3i pos = Vector3i.from(chunkX + x << 4, 80, chunkZ + z << 4);
@ -236,7 +236,7 @@ public class ChunkUtils {
blockPacket.setBlockPosition(pos); blockPacket.setBlockPosition(pos);
blockPacket.setDataLayer(0); blockPacket.setDataLayer(0);
blockPacket.setRuntimeId(1); blockPacket.setRuntimeId(1);
session.getUpstream().sendPacket(blockPacket); session.sendUpstreamPacket(blockPacket);
} }
} }
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class DimensionUtils {
changeDimensionPacket.setDimension(bedrockDimension); changeDimensionPacket.setDimension(bedrockDimension);
changeDimensionPacket.setRespawn(true); changeDimensionPacket.setRespawn(true);
changeDimensionPacket.setPosition(pos.toFloat()); changeDimensionPacket.setPosition(pos.toFloat());
session.getUpstream().sendPacket(changeDimensionPacket); session.sendUpstreamPacket(changeDimensionPacket);
player.setDimension(bedrockDimension); player.setDimension(bedrockDimension);
player.setPosition(pos.toFloat()); player.setPosition(pos.toFloat());
session.setSpawned(false); session.setSpawned(false);
@ -59,7 +59,7 @@ public class DimensionUtils {
StopSoundPacket stopSoundPacket = new StopSoundPacket(); StopSoundPacket stopSoundPacket = new StopSoundPacket();
stopSoundPacket.setStoppingAllSound(true); stopSoundPacket.setStoppingAllSound(true);
stopSoundPacket.setSoundName(""); stopSoundPacket.setSoundName("");
session.getUpstream().sendPacket(stopSoundPacket); session.sendUpstreamPacket(stopSoundPacket);
} }
/** /**

Datei anzeigen

@ -84,7 +84,7 @@ public class InventoryUtils {
cursorPacket.setContainerId(ContainerId.CURSOR); cursorPacket.setContainerId(ContainerId.CURSOR);
cursorPacket.setSlot(0); cursorPacket.setSlot(0);
cursorPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, session.getInventory().getCursor())); cursorPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, session.getInventory().getCursor()));
session.getUpstream().sendPacket(cursorPacket); session.sendUpstreamPacket(cursorPacket);
} }
public static boolean canStack(ItemStack item1, ItemStack item2) { public static boolean canStack(ItemStack item1, ItemStack item2) {

Datei anzeigen

@ -35,8 +35,6 @@ import com.nukkitx.protocol.bedrock.packet.LoginPacket;
import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket; import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
import com.nukkitx.protocol.bedrock.util.EncryptionUtils; import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
import net.minidev.json.JSONObject;
import org.geysermc.common.window.CustomFormBuilder; import org.geysermc.common.window.CustomFormBuilder;
import org.geysermc.common.window.CustomFormWindow; import org.geysermc.common.window.CustomFormWindow;
import org.geysermc.common.window.FormWindow; import org.geysermc.common.window.FormWindow;
@ -152,7 +150,7 @@ public class LoginEncryptionUtils {
ServerToClientHandshakePacket packet = new ServerToClientHandshakePacket(); ServerToClientHandshakePacket packet = new ServerToClientHandshakePacket();
packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize()); packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize());
session.getUpstream().sendPacketImmediately(packet); session.sendUpstreamPacketImmediately(packet);
} }
private static int AUTH_FORM_ID = 1336; private static int AUTH_FORM_ID = 1336;

Datei anzeigen

@ -177,12 +177,12 @@ public class SkinUtils {
PlayerListPacket playerRemovePacket = new PlayerListPacket(); PlayerListPacket playerRemovePacket = new PlayerListPacket();
playerRemovePacket.setAction(PlayerListPacket.Action.REMOVE); playerRemovePacket.setAction(PlayerListPacket.Action.REMOVE);
playerRemovePacket.getEntries().add(updatedEntry); playerRemovePacket.getEntries().add(updatedEntry);
session.getUpstream().sendPacket(playerRemovePacket); session.sendUpstreamPacket(playerRemovePacket);
PlayerListPacket playerAddPacket = new PlayerListPacket(); PlayerListPacket playerAddPacket = new PlayerListPacket();
playerAddPacket.setAction(PlayerListPacket.Action.ADD); playerAddPacket.setAction(PlayerListPacket.Action.ADD);
playerAddPacket.getEntries().add(updatedEntry); playerAddPacket.getEntries().add(updatedEntry);
session.getUpstream().sendPacket(playerAddPacket); session.sendUpstreamPacket(playerAddPacket);
} }
} }
} catch (Exception e) { } catch (Exception e) {