Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +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:
Ursprung
96a7770c22
Commit
7195d20fae
@ -55,7 +55,7 @@ public class OffhandCommand extends GeyserCommand {
|
||||
GeyserSession session = (GeyserSession) sender;
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
|
||||
BlockFace.DOWN);
|
||||
session.getDownstream().getSession().send(releaseItemPacket);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class Entity {
|
||||
addEntityPacket.getMetadata().putAll(metadata);
|
||||
|
||||
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 + ")");
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class Entity {
|
||||
|
||||
RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket();
|
||||
removeEntityPacket.setUniqueEntityId(geyserId);
|
||||
session.getUpstream().sendPacket(removeEntityPacket);
|
||||
session.sendUpstreamPacket(removeEntityPacket);
|
||||
|
||||
valid = false;
|
||||
return true;
|
||||
@ -156,7 +156,7 @@ public class Entity {
|
||||
moveEntityPacket.setOnGround(isOnGround);
|
||||
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) {
|
||||
@ -174,7 +174,7 @@ public class Entity {
|
||||
moveEntityPacket.setOnGround(isOnGround);
|
||||
moveEntityPacket.setTeleported(teleported);
|
||||
|
||||
session.getUpstream().sendPacket(moveEntityPacket);
|
||||
session.sendUpstreamPacket(moveEntityPacket);
|
||||
}
|
||||
|
||||
public void updateBedrockAttributes(GeyserSession session) {
|
||||
@ -191,7 +191,7 @@ public class Entity {
|
||||
UpdateAttributesPacket updateAttributesPacket = new UpdateAttributesPacket();
|
||||
updateAttributesPacket.setRuntimeEntityId(geyserId);
|
||||
updateAttributesPacket.setAttributes(attributes);
|
||||
session.getUpstream().sendPacket(updateAttributesPacket);
|
||||
session.sendUpstreamPacket(updateAttributesPacket);
|
||||
}
|
||||
|
||||
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
||||
@ -218,13 +218,13 @@ public class Entity {
|
||||
else {
|
||||
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)) {
|
||||
metadata.getFlags().setFlag(EntityFlag.BLOCKING, false);
|
||||
metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true);
|
||||
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);
|
||||
if ((xd & 0x20) == 0x20)
|
||||
@ -265,7 +265,7 @@ public class Entity {
|
||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||
entityDataPacket.setRuntimeEntityId(geyserId);
|
||||
entityDataPacket.getMetadata().putAll(metadata);
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class ItemEntity extends Entity {
|
||||
itemPacket.setFromFishing(false);
|
||||
itemPacket.getMetadata().putAll(metadata);
|
||||
itemPacket.setItemInHand(Translators.getItemTranslator().translateToBedrock(session, (ItemStack) entityMetadata.getValue()));
|
||||
session.getUpstream().sendPacket(itemPacket);
|
||||
session.sendUpstreamPacket(itemPacket);
|
||||
}
|
||||
|
||||
super.updateBedrockMetadata(entityMetadata, session);
|
||||
|
@ -149,7 +149,7 @@ public class ItemFrameEntity extends Entity {
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
session.getUpstream().sendPacket(updateBlockPacket);
|
||||
session.sendUpstreamPacket(updateBlockPacket);
|
||||
session.getItemFrameCache().remove(position, entityId);
|
||||
valid = false;
|
||||
return true;
|
||||
@ -179,7 +179,7 @@ public class ItemFrameEntity extends Entity {
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
session.getUpstream().sendPacket(updateBlockPacket);
|
||||
session.sendUpstreamPacket(updateBlockPacket);
|
||||
|
||||
BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket();
|
||||
blockEntityDataPacket.setBlockPosition(bedrockPosition);
|
||||
@ -189,7 +189,7 @@ public class ItemFrameEntity extends Entity {
|
||||
blockEntityDataPacket.setData(getDefaultTag());
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(blockEntityDataPacket);
|
||||
session.sendUpstreamPacket(blockEntityDataPacket);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ public class LivingEntity extends Entity {
|
||||
offHandPacket.setInventorySlot(0);
|
||||
offHandPacket.setContainerId(ContainerId.OFFHAND);
|
||||
|
||||
session.getUpstream().sendPacket(armorEquipmentPacket);
|
||||
session.getUpstream().sendPacket(handPacket);
|
||||
session.getUpstream().sendPacket(offHandPacket);
|
||||
session.sendUpstreamPacket(armorEquipmentPacket);
|
||||
session.sendUpstreamPacket(handPacket);
|
||||
session.sendUpstreamPacket(offHandPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class PaintingEntity extends Entity {
|
||||
addPaintingPacket.setName(paintingName.getBedrockName());
|
||||
addPaintingPacket.setPosition(fixOffset(true));
|
||||
addPaintingPacket.setDirection(direction);
|
||||
session.getUpstream().sendPacket(addPaintingPacket);
|
||||
session.sendUpstreamPacket(addPaintingPacket);
|
||||
|
||||
valid = true;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class PlayerEntity extends LivingEntity {
|
||||
addPlayerPacket.getMetadata().putAll(metadata);
|
||||
|
||||
valid = true;
|
||||
session.getUpstream().sendPacket(addPlayerPacket);
|
||||
session.sendUpstreamPacket(addPlayerPacket);
|
||||
|
||||
updateEquipment(session);
|
||||
updateBedrockAttributes(session);
|
||||
@ -108,7 +108,7 @@ public class PlayerEntity extends LivingEntity {
|
||||
PlayerListPacket playerList = new PlayerListPacket();
|
||||
playerList.setAction(PlayerListPacket.Action.ADD);
|
||||
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();
|
||||
playerList.setAction(PlayerListPacket.Action.REMOVE);
|
||||
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);
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,7 +159,7 @@ public class PlayerEntity extends LivingEntity {
|
||||
movePlayerPacket.setRotation(getBedrockRotation());
|
||||
movePlayerPacket.setOnGround(isOnGround);
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL);
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,7 +65,7 @@ public class LlamaEntity extends ChestedHorseEntity {
|
||||
equipmentPacket.setHelmet(ItemData.AIR);
|
||||
equipmentPacket.setLeggings(ItemData.AIR);
|
||||
|
||||
session.getUpstream().sendPacket(equipmentPacket);
|
||||
session.sendUpstreamPacket(equipmentPacket);
|
||||
}
|
||||
// Color of the llama
|
||||
if (entityMetadata.getId() == 21) {
|
||||
|
@ -53,7 +53,7 @@ public class EnderDragonEntity extends InsentientEntity {
|
||||
entityEventPacket.setType(EntityEventType.DRAGON_FLAMING);
|
||||
entityEventPacket.setRuntimeEntityId(geyserId);
|
||||
entityEventPacket.setData(0);
|
||||
session.getUpstream().sendPacket(entityEventPacket);
|
||||
session.sendUpstreamPacket(entityEventPacket);
|
||||
case 6:
|
||||
case 7:
|
||||
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));
|
||||
|
||||
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 + ")");
|
||||
}
|
||||
|
@ -58,10 +58,10 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
|
||||
PlayStatusPacket playStatus = new PlayStatusPacket();
|
||||
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||
session.getUpstream().sendPacket(playStatus);
|
||||
session.sendUpstreamPacket(playStatus);
|
||||
|
||||
ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket();
|
||||
session.getUpstream().sendPacket(resourcePacksInfo);
|
||||
session.sendUpstreamPacket(resourcePacksInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler {
|
||||
stack.setExperimental(false);
|
||||
stack.setForcedToAccept(false);
|
||||
stack.setGameVersion("*");
|
||||
session.getUpstream().sendPacket(stack);
|
||||
session.sendUpstreamPacket(stack);
|
||||
break;
|
||||
default:
|
||||
session.disconnect("disconnectionScreen.resourcePack");
|
||||
|
@ -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.RequestException;
|
||||
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.packet.ingame.client.world.ClientTeleportConfirmPacket;
|
||||
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.TrigMath;
|
||||
import com.nukkitx.math.vector.*;
|
||||
import com.nukkitx.protocol.bedrock.BedrockPacket;
|
||||
import com.nukkitx.protocol.bedrock.BedrockServerSession;
|
||||
import com.nukkitx.protocol.bedrock.data.ContainerId;
|
||||
import com.nukkitx.protocol.bedrock.data.GamePublishSetting;
|
||||
@ -156,6 +158,8 @@ public class GeyserSession implements CommandSender {
|
||||
@Setter
|
||||
private int craftSlot = 0;
|
||||
|
||||
private MinecraftProtocol protocol;
|
||||
|
||||
public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) {
|
||||
this.connector = connector;
|
||||
this.upstream = new UpstreamSession(bedrockServerSession);
|
||||
@ -227,7 +231,6 @@ public class GeyserSession implements CommandSender {
|
||||
// new thread so clients don't timeout
|
||||
new Thread(() -> {
|
||||
try {
|
||||
MinecraftProtocol protocol;
|
||||
if (password != null && !password.isEmpty()) {
|
||||
protocol = new MinecraftProtocol(username, password);
|
||||
} else {
|
||||
@ -481,8 +484,47 @@ public class GeyserSession implements CommandSender {
|
||||
int teleportId = teleportCache.getTeleportConfirmId();
|
||||
teleportCache = null;
|
||||
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(teleportId);
|
||||
getDownstream().getSession().send(teleportConfirmPacket);
|
||||
sendDownstreamPacket(teleportConfirmPacket);
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class BossBar {
|
||||
bossEventPacket.setOverlay(overlay);
|
||||
bossEventPacket.setDarkenSky(darkenSky);
|
||||
|
||||
session.getUpstream().sendPacket(bossEventPacket);
|
||||
session.sendUpstreamPacket(bossEventPacket);
|
||||
}
|
||||
|
||||
public void updateTitle(Message title) {
|
||||
@ -72,7 +72,7 @@ public class BossBar {
|
||||
bossEventPacket.setAction(BossEventPacket.Action.TITLE);
|
||||
bossEventPacket.setTitle(MessageUtils.getTranslatedBedrockMessage(title, session.getClientData().getLanguageCode()));
|
||||
|
||||
session.getUpstream().sendPacket(bossEventPacket);
|
||||
session.sendUpstreamPacket(bossEventPacket);
|
||||
}
|
||||
|
||||
public void updateHealth(float health) {
|
||||
@ -82,7 +82,7 @@ public class BossBar {
|
||||
bossEventPacket.setAction(BossEventPacket.Action.HEALTH_PERCENTAGE);
|
||||
bossEventPacket.setHealthPercentage(health);
|
||||
|
||||
session.getUpstream().sendPacket(bossEventPacket);
|
||||
session.sendUpstreamPacket(bossEventPacket);
|
||||
}
|
||||
|
||||
public void removeBossBar() {
|
||||
@ -90,7 +90,7 @@ public class BossBar {
|
||||
bossEventPacket.setBossUniqueEntityId(entityId);
|
||||
bossEventPacket.setAction(BossEventPacket.Action.HIDE);
|
||||
|
||||
session.getUpstream().sendPacket(bossEventPacket);
|
||||
session.sendUpstreamPacket(bossEventPacket);
|
||||
removeBossEntity();
|
||||
}
|
||||
|
||||
@ -109,13 +109,13 @@ public class BossBar {
|
||||
addEntityPacket.setMotion(Vector3f.ZERO);
|
||||
addEntityPacket.getMetadata().put(EntityData.SCALE, 0.01F); // scale = 0 doesn't work?
|
||||
|
||||
session.getUpstream().sendPacket(addEntityPacket);
|
||||
session.sendUpstreamPacket(addEntityPacket);
|
||||
}
|
||||
|
||||
private void removeBossEntity() {
|
||||
RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket();
|
||||
removeEntityPacket.setUniqueEntityId(entityId);
|
||||
|
||||
session.getUpstream().sendPacket(removeEntityPacket);
|
||||
session.sendUpstreamPacket(removeEntityPacket);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class WindowCache {
|
||||
formRequestPacket.setFormId(id);
|
||||
formRequestPacket.setFormData(windows.get(id).getJSONData());
|
||||
|
||||
session.getUpstream().sendPacket(formRequestPacket);
|
||||
session.sendUpstreamPacket(formRequestPacket);
|
||||
}
|
||||
|
||||
public void showWindow(FormWindow window, int id) {
|
||||
@ -74,7 +74,7 @@ public class WindowCache {
|
||||
formRequestPacket.setFormId(id);
|
||||
formRequestPacket.setFormData(window.getJSONData());
|
||||
|
||||
session.getUpstream().sendPacket(formRequestPacket);
|
||||
session.sendUpstreamPacket(formRequestPacket);
|
||||
|
||||
addWindow(window, id);
|
||||
}
|
||||
|
@ -64,44 +64,44 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
break;
|
||||
case START_SWIMMING:
|
||||
ClientPlayerStatePacket startSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.getDownstream().getSession().send(startSwimPacket);
|
||||
session.sendDownstreamPacket(startSwimPacket);
|
||||
break;
|
||||
case STOP_SWIMMING:
|
||||
ClientPlayerStatePacket stopSwimPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.getDownstream().getSession().send(stopSwimPacket);
|
||||
session.sendDownstreamPacket(stopSwimPacket);
|
||||
break;
|
||||
case START_GLIDE:
|
||||
case STOP_GLIDE:
|
||||
ClientPlayerStatePacket glidePacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_ELYTRA_FLYING);
|
||||
session.getDownstream().getSession().send(glidePacket);
|
||||
session.sendDownstreamPacket(glidePacket);
|
||||
break;
|
||||
case START_SNEAK:
|
||||
ClientPlayerStatePacket startSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SNEAKING);
|
||||
session.getDownstream().getSession().send(startSneakPacket);
|
||||
session.sendDownstreamPacket(startSneakPacket);
|
||||
session.setSneaking(true);
|
||||
break;
|
||||
case STOP_SNEAK:
|
||||
ClientPlayerStatePacket stopSneakPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SNEAKING);
|
||||
session.getDownstream().getSession().send(stopSneakPacket);
|
||||
session.sendDownstreamPacket(stopSneakPacket);
|
||||
session.setSneaking(false);
|
||||
break;
|
||||
case START_SPRINT:
|
||||
ClientPlayerStatePacket startSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.START_SPRINTING);
|
||||
session.getDownstream().getSession().send(startSprintPacket);
|
||||
session.sendDownstreamPacket(startSprintPacket);
|
||||
session.setSprinting(true);
|
||||
break;
|
||||
case STOP_SPRINT:
|
||||
ClientPlayerStatePacket stopSprintPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.STOP_SPRINTING);
|
||||
session.getDownstream().getSession().send(stopSprintPacket);
|
||||
session.sendDownstreamPacket(stopSprintPacket);
|
||||
session.setSprinting(false);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
ClientPlayerActionPacket dropItemPacket = new ClientPlayerActionPacket(PlayerAction.DROP_ITEM, position, BlockFace.values()[packet.getFace()]);
|
||||
session.getDownstream().getSession().send(dropItemPacket);
|
||||
session.sendDownstreamPacket(dropItemPacket);
|
||||
break;
|
||||
case STOP_SLEEP:
|
||||
ClientPlayerStatePacket stopSleepingPacket = new ClientPlayerStatePacket((int) entity.getEntityId(), PlayerState.LEAVE_BED);
|
||||
session.getDownstream().getSession().send(stopSleepingPacket);
|
||||
session.sendDownstreamPacket(stopSleepingPacket);
|
||||
break;
|
||||
case BLOCK_INTERACT:
|
||||
// Handled in BedrockInventoryTransactionTranslator
|
||||
@ -109,19 +109,19 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
case START_BREAK:
|
||||
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(),
|
||||
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]);
|
||||
session.getDownstream().getSession().send(startBreakingPacket);
|
||||
session.sendDownstreamPacket(startBreakingPacket);
|
||||
break;
|
||||
case CONTINUE_BREAK:
|
||||
LevelEventPacket continueBreakPacket = new LevelEventPacket();
|
||||
continueBreakPacket.setType(LevelEventType.PUNCH_BLOCK);
|
||||
continueBreakPacket.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock() == null ? BlockTranslator.AIR : session.getBreakingBlock()));
|
||||
continueBreakPacket.setPosition(packet.getBlockPosition().toFloat());
|
||||
session.getUpstream().sendPacket(continueBreakPacket);
|
||||
session.sendUpstreamPacket(continueBreakPacket);
|
||||
break;
|
||||
case ABORT_BREAK:
|
||||
ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(),
|
||||
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.DOWN);
|
||||
session.getDownstream().getSession().send(abortBreakingPacket);
|
||||
session.sendDownstreamPacket(abortBreakingPacket);
|
||||
break;
|
||||
case STOP_BREAK:
|
||||
// Handled in BedrockInventoryTransactionTranslator
|
||||
@ -131,7 +131,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||
//sometimes the client doesn't feel like loading
|
||||
PlayStatusPacket spawnPacket = new PlayStatusPacket();
|
||||
spawnPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||
session.getUpstream().sendPacket(spawnPacket);
|
||||
session.sendUpstreamPacket(spawnPacket);
|
||||
entity.updateBedrockAttributes(session);
|
||||
session.getEntityCache().updateBossBars();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class BedrockAnimateTranslator extends PacketTranslator<AnimatePacket> {
|
||||
case SWING_ARM:
|
||||
// Delay so entity damage can be processed first
|
||||
session.getConnector().getGeneralThreadPool().schedule(() ->
|
||||
session.getDownstream().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
|
||||
session.sendDownstreamPacket(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)),
|
||||
25,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
|
@ -79,7 +79,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator<BlockEnti
|
||||
// Put the final line on since it isn't done in the for loop
|
||||
if (iterator < lines.length) lines[iterator] = newMessage.toString();
|
||||
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
|
||||
// However Java can still store a lot per-line and visuals are still messed up so that doesn't work
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
|
||||
}
|
||||
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(message);
|
||||
session.getDownstream().getSession().send(chatPacket);
|
||||
session.sendDownstreamPacket(chatPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class BedrockContainerCloseTranslator extends PacketTranslator<ContainerC
|
||||
}
|
||||
}
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(windowId);
|
||||
session.getDownstream().getSession().send(closeWindowPacket);
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
InventoryUtils.closeInventory(session, windowId);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class BedrockEntityEventTranslator extends PacketTranslator<EntityEventPa
|
||||
switch (packet.getType()) {
|
||||
// Resend the packet so we get the eating sounds
|
||||
case EATING_ITEM:
|
||||
session.getUpstream().sendPacket(packet);
|
||||
session.sendUpstreamPacket(packet);
|
||||
return;
|
||||
}
|
||||
session.getConnector().getLogger().debug("Did not translate incoming EntityEventPacket: " + packet.toString());
|
||||
|
@ -52,12 +52,12 @@ public class BedrockInteractTranslator extends PacketTranslator<InteractPacket>
|
||||
}
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(interactPacket);
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
break;
|
||||
case DAMAGE:
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(attackPacket);
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -84,8 +84,8 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND);
|
||||
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
|
||||
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(interactPacket);
|
||||
session.getDownstream().getSession().send(interactAtPacket);
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamPacket(interactAtPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
Hand.MAIN_HAND,
|
||||
packet.getClickPosition().getX(), packet.getClickPosition().getY(), packet.getClickPosition().getZ(),
|
||||
false);
|
||||
session.getDownstream().getSession().send(blockPacket);
|
||||
session.sendDownstreamPacket(blockPacket);
|
||||
Vector3i blockPos = packet.getBlockPosition();
|
||||
// TODO: Find a better way to do this?
|
||||
switch (packet.getFace()) {
|
||||
@ -131,7 +131,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
break;
|
||||
} // Handled in Entity.java
|
||||
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(useItemPacket);
|
||||
session.sendDownstreamPacket(useItemPacket);
|
||||
break;
|
||||
case 2:
|
||||
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.setPosition(packet.getBlockPosition().toFloat());
|
||||
blockBreakPacket.setData(BlockTranslator.getBedrockBlockId(blockState));
|
||||
session.getUpstream().sendPacket(blockBreakPacket);
|
||||
session.sendUpstreamPacket(blockBreakPacket);
|
||||
}
|
||||
|
||||
if (ItemFrameEntity.positionContainsItemFrame(session, packet.getBlockPosition()) &&
|
||||
session.getEntityCache().getEntityByJavaId(ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition())) != null) {
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, packet.getBlockPosition()),
|
||||
InteractAction.ATTACK);
|
||||
session.getDownstream().getSession().send(attackPacket);
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerAction action = session.getGameMode() == GameMode.CREATIVE ? PlayerAction.START_DIGGING : PlayerAction.FINISH_DIGGING;
|
||||
Position pos = new Position(packet.getBlockPosition().getX(), packet.getBlockPosition().getY(), packet.getBlockPosition().getZ());
|
||||
ClientPlayerActionPacket breakPacket = new ClientPlayerActionPacket(action, pos, BlockFace.values()[packet.getFace()]);
|
||||
session.getDownstream().getSession().send(breakPacket);
|
||||
session.sendDownstreamPacket(breakPacket);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -167,7 +167,7 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
// Followed to the Minecraft Protocol specification outlined at wiki.vg
|
||||
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0),
|
||||
BlockFace.DOWN);
|
||||
session.getDownstream().getSession().send(releaseItemPacket);
|
||||
session.sendDownstreamPacket(releaseItemPacket);
|
||||
}
|
||||
break;
|
||||
case ITEM_USE_ON_ENTITY:
|
||||
@ -183,15 +183,15 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||
InteractAction.INTERACT, Hand.MAIN_HAND);
|
||||
ClientPlayerInteractEntityPacket interactAtPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
InteractAction.INTERACT_AT, vector.getX(), vector.getY(), vector.getZ(), Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(interactPacket);
|
||||
session.getDownstream().getSession().send(interactAtPacket);
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
session.sendDownstreamPacket(interactAtPacket);
|
||||
|
||||
EntitySoundInteractionHandler.handleEntityInteraction(session, vector, entity);
|
||||
break;
|
||||
case 1: //Attack
|
||||
ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(),
|
||||
InteractAction.ATTACK);
|
||||
session.getDownstream().getSession().send(attackPacket);
|
||||
session.sendDownstreamPacket(attackPacket);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -51,7 +51,7 @@ public class BedrockItemFrameDropItemTranslator extends PacketTranslator<ItemFra
|
||||
Vector3i position = Vector3i.from(packet.getBlockPosition().getX(), y, packet.getBlockPosition().getZ());
|
||||
ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) ItemFrameEntity.getItemFrameEntityId(session, position),
|
||||
InteractAction.ATTACK, Hand.MAIN_HAND);
|
||||
session.getDownstream().getSession().send(interactPacket);
|
||||
session.sendDownstreamPacket(interactPacket);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,6 +36,6 @@ public class BedrockLevelSoundEventTranslator extends PacketTranslator<LevelSoun
|
||||
@Override
|
||||
public void translate(LevelSoundEventPacket packet, GeyserSession session) {
|
||||
// lol what even :thinking:
|
||||
session.getUpstream().sendPacket(packet);
|
||||
session.sendUpstreamPacket(packet);
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,6 @@ public class BedrockMobEquipmentTranslator extends PacketTranslator<MobEquipment
|
||||
session.getInventory().setHeldItemSlot(packet.getHotbarSlot());
|
||||
|
||||
ClientPlayerChangeHeldItemPacket changeHeldItemPacket = new ClientPlayerChangeHeldItemPacket(packet.getHotbarSlot());
|
||||
session.getDownstream().getSession().send(changeHeldItemPacket);
|
||||
session.sendDownstreamPacket(changeHeldItemPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||
moveEntityBack.setRotation(entity.getBedrockRotation());
|
||||
moveEntityBack.setTeleported(true);
|
||||
moveEntityBack.setOnGround(true);
|
||||
session.getUpstream().sendPacketImmediately(moveEntityBack);
|
||||
session.sendUpstreamPacketImmediately(moveEntityBack);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ public class BedrockMovePlayerTranslator extends PacketTranslator<MovePlayerPack
|
||||
|
||||
if (!colliding)
|
||||
*/
|
||||
session.getDownstream().getSession().send(playerPositionRotationPacket);
|
||||
session.sendDownstreamPacket(playerPositionRotationPacket);
|
||||
}
|
||||
|
||||
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();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(entity.getMetadata());
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
movePlayerPacket.setPosition(entity.getPosition());
|
||||
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET);
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
}
|
||||
|
@ -44,10 +44,10 @@ public class BedrockRespawnTranslator extends PacketTranslator<RespawnPacket> {
|
||||
respawnPacket.setRuntimeEntityId(0);
|
||||
respawnPacket.setPosition(Vector3f.ZERO);
|
||||
respawnPacket.setState(RespawnPacket.State.SERVER_SEARCHING);
|
||||
session.getUpstream().sendPacket(respawnPacket);
|
||||
session.sendUpstreamPacket(respawnPacket);
|
||||
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.getDownstream().getSession().send(javaRespawnPacket);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator<ShowCreditsPa
|
||||
public void translate(ShowCreditsPacket packet, GeyserSession session) {
|
||||
if (packet.getStatus() == ShowCreditsPacket.Status.END_CREDITS) {
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.getDownstream().getSession().send(javaRespawnPacket);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ public class BedrockTextTranslator extends PacketTranslator<TextPacket> {
|
||||
}
|
||||
|
||||
ClientChatPacket chatPacket = new ClientChatPacket(message);
|
||||
session.getDownstream().getSession().send(chatPacket);
|
||||
session.sendDownstreamPacket(chatPacket);
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||
rename = "";
|
||||
}
|
||||
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename);
|
||||
session.getDownstream().getSession().send(renameItemPacket);
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
}
|
||||
if (anvilResult != null) {
|
||||
//client will send another packet to grab anvil output
|
||||
@ -138,7 +138,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator {
|
||||
rename = "";
|
||||
}
|
||||
ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename);
|
||||
session.getDownstream().getSession().send(renameItemPacket);
|
||||
session.sendDownstreamPacket(renameItemPacket);
|
||||
}
|
||||
}
|
||||
super.updateSlot(session, inventory, slot);
|
||||
|
@ -44,7 +44,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator {
|
||||
dataPacket.setWindowId((byte) inventory.getId());
|
||||
dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL);
|
||||
dataPacket.setValue(20);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +62,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator {
|
||||
return;
|
||||
}
|
||||
dataPacket.setValue(value);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,7 @@ public class CraftingInventoryTranslator extends BaseInventoryTranslator {
|
||||
containerOpenPacket.setType((byte) ContainerType.WORKBENCH.id());
|
||||
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
|
||||
containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
|
||||
session.getUpstream().sendPacket(containerOpenPacket);
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
blockPacket.setBlockPosition(position);
|
||||
blockPacket.setRuntimeId(blockId);
|
||||
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
|
||||
CompoundTag tag = CompoundTag.builder()
|
||||
.stringTag("id", "Chest")
|
||||
@ -73,14 +73,14 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
BlockEntityDataPacket dataPacket = new BlockEntityDataPacket();
|
||||
dataPacket.setData(tag);
|
||||
dataPacket.setBlockPosition(position);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
|
||||
blockPacket = new UpdateBlockPacket();
|
||||
blockPacket.setDataLayer(0);
|
||||
blockPacket.setBlockPosition(pairPosition);
|
||||
blockPacket.setRuntimeId(blockId);
|
||||
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
|
||||
tag = CompoundTag.builder()
|
||||
.stringTag("id", "Chest")
|
||||
@ -93,7 +93,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
dataPacket = new BlockEntityDataPacket();
|
||||
dataPacket.setData(tag);
|
||||
dataPacket.setBlockPosition(pairPosition);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
|
||||
inventory.setHolderPosition(position);
|
||||
}
|
||||
@ -105,7 +105,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
containerOpenPacket.setType((byte) ContainerType.CONTAINER.id());
|
||||
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
|
||||
containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
|
||||
session.getUpstream().sendPacket(containerOpenPacket);
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,7 +117,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
blockPacket.setDataLayer(0);
|
||||
blockPacket.setBlockPosition(holderPos);
|
||||
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
|
||||
holderPos = holderPos.add(Vector3i.UNIT_X);
|
||||
pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ());
|
||||
@ -126,7 +126,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator {
|
||||
blockPacket.setDataLayer(0);
|
||||
blockPacket.setBlockPosition(holderPos);
|
||||
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +58,7 @@ public class FurnaceInventoryTranslator extends BlockInventoryTranslator {
|
||||
return;
|
||||
}
|
||||
dataPacket.setValue(value);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,7 +34,6 @@ import com.nukkitx.protocol.bedrock.data.InventorySource;
|
||||
import com.nukkitx.protocol.bedrock.data.ItemData;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket;
|
||||
import it.unimi.dsi.fastutil.longs.LongArraySet;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
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));
|
||||
}
|
||||
inventoryContentPacket.setContents(contents);
|
||||
session.getUpstream().sendPacket(inventoryContentPacket);
|
||||
session.sendUpstreamPacket(inventoryContentPacket);
|
||||
|
||||
// Armor
|
||||
InventoryContentPacket armorContentPacket = new InventoryContentPacket();
|
||||
@ -76,13 +75,13 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
contents[i - 5] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i));
|
||||
}
|
||||
armorContentPacket.setContents(contents);
|
||||
session.getUpstream().sendPacket(armorContentPacket);
|
||||
session.sendUpstreamPacket(armorContentPacket);
|
||||
|
||||
// Offhand
|
||||
InventoryContentPacket offhandPacket = new InventoryContentPacket();
|
||||
offhandPacket.setContainerId(ContainerId.OFFHAND);
|
||||
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)));
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,12 +125,12 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
slotPacket.setSlot(slot + 27);
|
||||
}
|
||||
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
} else if (slot == 45) {
|
||||
InventoryContentPacket offhandPacket = new InventoryContentPacket();
|
||||
offhandPacket.setContainerId(ContainerId.OFFHAND);
|
||||
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());
|
||||
}
|
||||
ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, javaItem);
|
||||
session.getDownstream().getSession().send(creativePacket);
|
||||
session.sendDownstreamPacket(creativePacket);
|
||||
inventory.setItem(javaSlot, javaItem);
|
||||
break;
|
||||
case ContainerId.CURSOR:
|
||||
@ -217,7 +216,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator {
|
||||
&& action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) {
|
||||
javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem());
|
||||
ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, javaItem);
|
||||
session.getDownstream().getSession().send(creativeDropPacket);
|
||||
session.sendDownstreamPacket(creativeDropPacket);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ class ClickPlan {
|
||||
break;
|
||||
}
|
||||
}
|
||||
session.getDownstream().getSession().send(clickPacket);
|
||||
session.getDownstream().getSession().send(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true));
|
||||
session.sendDownstreamPacket(clickPacket);
|
||||
session.sendDownstreamPacket(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true));
|
||||
}
|
||||
|
||||
/*if (refresh) {
|
||||
|
@ -94,7 +94,7 @@ public class InventoryActionDataTranslator {
|
||||
ClientPlayerActionPacket actionPacket = new ClientPlayerActionPacket(
|
||||
sourceAction.getToItem().getCount() == 0 ? PlayerAction.DROP_ITEM_STACK : PlayerAction.DROP_ITEM,
|
||||
new Position(0, 0, 0), BlockFace.DOWN);
|
||||
session.getDownstream().getSession().send(actionPacket);
|
||||
session.sendDownstreamPacket(actionPacket);
|
||||
ItemStack item = session.getInventory().getItem(heldSlot);
|
||||
if (item != null) {
|
||||
session.getInventory().setItem(heldSlot, new ItemStack(item.getId(), item.getAmount() - 1, item.getNbt()));
|
||||
@ -110,14 +110,14 @@ public class InventoryActionDataTranslator {
|
||||
inventory.getTransactionId().getAndIncrement(),
|
||||
javaSlot, null, WindowAction.DROP_ITEM,
|
||||
DropItemParam.DROP_SELECTED_STACK);
|
||||
session.getDownstream().getSession().send(dropPacket);
|
||||
session.sendDownstreamPacket(dropPacket);
|
||||
} else {
|
||||
for (int i = 0; i < dropAmount; i++) {
|
||||
ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(),
|
||||
inventory.getTransactionId().getAndIncrement(),
|
||||
javaSlot, null, WindowAction.DROP_ITEM,
|
||||
DropItemParam.DROP_FROM_SELECTED);
|
||||
session.getDownstream().getSession().send(dropPacket);
|
||||
session.sendDownstreamPacket(dropPacket);
|
||||
}
|
||||
}
|
||||
ItemStack item = session.getInventory().getItem(javaSlot);
|
||||
@ -129,7 +129,7 @@ public class InventoryActionDataTranslator {
|
||||
ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), inventory.getTransactionId().getAndIncrement(),
|
||||
-999, null, WindowAction.CLICK_ITEM,
|
||||
dropAmount > 1 ? ClickItemParam.LEFT_CLICK : ClickItemParam.RIGHT_CLICK);
|
||||
session.getDownstream().getSession().send(dropPacket);
|
||||
session.sendDownstreamPacket(dropPacket);
|
||||
ItemStack cursor = session.getInventory().getCursor();
|
||||
if (cursor != null) {
|
||||
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(),
|
||||
javaSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM,
|
||||
ShiftClickItemParam.LEFT_CLICK);
|
||||
session.getDownstream().getSession().send(shiftClickPacket);
|
||||
session.sendDownstreamPacket(shiftClickPacket);
|
||||
translator.updateInventory(session, inventory);
|
||||
return;
|
||||
}
|
||||
@ -266,7 +266,7 @@ public class InventoryActionDataTranslator {
|
||||
inventory.getTransactionId().getAndIncrement(),
|
||||
fromSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM,
|
||||
ShiftClickItemParam.LEFT_CLICK);
|
||||
session.getDownstream().getSession().send(shiftClickPacket);
|
||||
session.sendDownstreamPacket(shiftClickPacket);
|
||||
translator.updateInventory(session, inventory);
|
||||
return;
|
||||
} else if (translator.getSlotType(fromSlot) == SlotType.OUTPUT) {
|
||||
|
@ -54,7 +54,7 @@ public class BlockInventoryHolder extends InventoryHolder {
|
||||
blockPacket.setBlockPosition(position);
|
||||
blockPacket.setRuntimeId(blockId);
|
||||
blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY);
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
inventory.setHolderPosition(position);
|
||||
|
||||
CompoundTag tag = CompoundTag.builder()
|
||||
@ -65,7 +65,7 @@ public class BlockInventoryHolder extends InventoryHolder {
|
||||
BlockEntityDataPacket dataPacket = new BlockEntityDataPacket();
|
||||
dataPacket.setData(tag);
|
||||
dataPacket.setBlockPosition(position);
|
||||
session.getUpstream().sendPacket(dataPacket);
|
||||
session.sendUpstreamPacket(dataPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,7 +75,7 @@ public class BlockInventoryHolder extends InventoryHolder {
|
||||
containerOpenPacket.setType((byte) containerType.id());
|
||||
containerOpenPacket.setBlockPosition(inventory.getHolderPosition());
|
||||
containerOpenPacket.setUniqueEntityId(inventory.getHolderId());
|
||||
session.getUpstream().sendPacket(containerOpenPacket);
|
||||
session.sendUpstreamPacket(containerOpenPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,6 +87,6 @@ public class BlockInventoryHolder extends InventoryHolder {
|
||||
blockPacket.setDataLayer(0);
|
||||
blockPacket.setBlockPosition(holderPos);
|
||||
blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock));
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
|
||||
InventoryContentPacket contentPacket = new InventoryContentPacket();
|
||||
contentPacket.setContainerId(inventory.getId());
|
||||
contentPacket.setContents(bedrockItems);
|
||||
session.getUpstream().sendPacket(contentPacket);
|
||||
session.sendUpstreamPacket(contentPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -66,7 +66,7 @@ public class ChestInventoryUpdater extends InventoryUpdater {
|
||||
slotPacket.setContainerId(inventory.getId());
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
|
||||
InventoryContentPacket contentPacket = new InventoryContentPacket();
|
||||
contentPacket.setContainerId(inventory.getId());
|
||||
contentPacket.setContents(bedrockItems);
|
||||
session.getUpstream().sendPacket(contentPacket);
|
||||
session.sendUpstreamPacket(contentPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,7 +58,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater {
|
||||
slotPacket.setContainerId(inventory.getId());
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class CursorInventoryUpdater extends InventoryUpdater {
|
||||
slotPacket.setContainerId(ContainerId.CURSOR);
|
||||
slotPacket.setSlot(bedrockSlot);
|
||||
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.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public abstract class InventoryUpdater {
|
||||
InventoryContentPacket contentPacket = new InventoryContentPacket();
|
||||
contentPacket.setContainerId(ContainerId.INVENTORY);
|
||||
contentPacket.setContents(bedrockItems);
|
||||
session.getUpstream().sendPacket(contentPacket);
|
||||
session.sendUpstreamPacket(contentPacket);
|
||||
}
|
||||
|
||||
public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) {
|
||||
@ -53,7 +53,7 @@ public abstract class InventoryUpdater {
|
||||
slotPacket.setContainerId(ContainerId.INVENTORY);
|
||||
slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot));
|
||||
slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot)));
|
||||
session.getUpstream().sendPacket(slotPacket);
|
||||
session.sendUpstreamPacket(slotPacket);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -76,6 +76,6 @@ public class JavaChatTranslator extends PacketTranslator<ServerChatPacket> {
|
||||
textPacket.setMessage(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), locale, false));
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(textPacket);
|
||||
session.sendUpstreamPacket(textPacket);
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator<ServerDeclare
|
||||
}
|
||||
}
|
||||
craftingDataPacket.getPotionMixData().addAll(POTION_MIXES);
|
||||
session.getUpstream().sendPacket(craftingDataPacket);
|
||||
session.sendUpstreamPacket(craftingDataPacket);
|
||||
}
|
||||
|
||||
//TODO: rewrite
|
||||
|
@ -39,6 +39,6 @@ public class JavaDifficultyTranslator extends PacketTranslator<ServerDifficultyP
|
||||
public void translate(ServerDifficultyPacket packet, GeyserSession session) {
|
||||
SetDifficultyPacket setDifficultyPacket = new SetDifficultyPacket();
|
||||
setDifficultyPacket.setDifficulty(packet.getDifficulty().ordinal());
|
||||
session.getUpstream().sendPacket(setDifficultyPacket);
|
||||
session.sendUpstreamPacket(setDifficultyPacket);
|
||||
}
|
||||
}
|
||||
|
@ -56,21 +56,21 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
||||
AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket();
|
||||
bedrockPacket.setUniqueEntityId(session.getPlayerEntity().getGeyserId());
|
||||
bedrockPacket.setPlayerPermission(PlayerPermission.MEMBER);
|
||||
session.getUpstream().sendPacket(bedrockPacket);
|
||||
session.sendUpstreamPacket(bedrockPacket);
|
||||
|
||||
PlayStatusPacket playStatus = new PlayStatusPacket();
|
||||
playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS);
|
||||
// session.getUpstream().sendPacket(playStatus);
|
||||
// session.sendPacket(playStatus);
|
||||
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
|
||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||
session.sendUpstreamPacket(playerGameTypePacket);
|
||||
session.setGameMode(packet.getGameMode());
|
||||
|
||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(entity.getMetadata());
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
|
||||
session.setRenderDistance(packet.getViewDistance());
|
||||
|
||||
@ -78,7 +78,7 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
||||
String locale = session.getClientData().getLanguageCode();
|
||||
List<SkinPart> skinParts = Arrays.asList(SkinPart.values());
|
||||
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()) {
|
||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
||||
|
@ -12,7 +12,7 @@ public class JavaLoginPluginMessageTranslator extends PacketTranslator<LoginPlug
|
||||
@Override
|
||||
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.
|
||||
session.getDownstream().getSession().send(
|
||||
session.sendDownstreamPacket(
|
||||
new LoginPluginResponsePacket(packet.getMessageId(), null)
|
||||
);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class JavaPluginMessageTranslator extends PacketTranslator<ServerPluginMe
|
||||
@Override
|
||||
public void translate(ServerPluginMessagePacket packet, GeyserSession session) {
|
||||
if (packet.getChannel().equals("minecraft:brand")) {
|
||||
session.getDownstream().getSession().send(
|
||||
session.sendDownstreamPacket(
|
||||
new ClientPluginMessagePacket(packet.getChannel(), brandData)
|
||||
);
|
||||
}
|
||||
|
@ -57,14 +57,14 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||
session.sendUpstreamPacket(playerGameTypePacket);
|
||||
session.setGameMode(packet.getGamemode());
|
||||
|
||||
LevelEventPacket stopRainPacket = new LevelEventPacket();
|
||||
stopRainPacket.setType(LevelEventType.STOP_RAIN);
|
||||
stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
|
||||
stopRainPacket.setPosition(Vector3f.ZERO);
|
||||
session.getUpstream().sendPacket(stopRainPacket);
|
||||
session.sendUpstreamPacket(stopRainPacket);
|
||||
|
||||
if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) {
|
||||
DimensionUtils.switchDimension(session, packet.getDimension());
|
||||
|
@ -100,7 +100,7 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator<Server
|
||||
GeyserConnector.getInstance().getLogger().debug("Sending command packet of " + commandData.size() + " commands");
|
||||
|
||||
// Finally, send the commands to the client
|
||||
session.getUpstream().sendPacket(availableCommandsPacket);
|
||||
session.sendUpstreamPacket(availableCommandsPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,6 @@ public class JavaTitleTranslator extends PacketTranslator<ServerTitlePacket> {
|
||||
break;
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(titlePacket);
|
||||
session.sendUpstreamPacket(titlePacket);
|
||||
}
|
||||
}
|
||||
|
@ -62,6 +62,6 @@ public class JavaEntityAnimationTranslator extends PacketTranslator<ServerEntity
|
||||
break;
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(animatePacket);
|
||||
session.sendUpstreamPacket(animatePacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,6 +55,6 @@ public class JavaEntityEffectTranslator extends PacketTranslator<ServerEntityEff
|
||||
mobEffectPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
mobEffectPacket.setParticles(packet.isShowParticles());
|
||||
mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect()));
|
||||
session.getUpstream().sendPacket(mobEffectPacket);
|
||||
session.sendUpstreamPacket(mobEffectPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ public class JavaEntityHeadLookTranslator extends PacketTranslator<ServerEntityH
|
||||
moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
moveEntityAbsolutePacket.setPosition(entity.getPosition());
|
||||
moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation());
|
||||
session.getUpstream().sendPacket(moveEntityAbsolutePacket);
|
||||
session.sendUpstreamPacket(moveEntityAbsolutePacket);
|
||||
} else {
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
movePlayerPacket.setPosition(entity.getPosition());
|
||||
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION);
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,6 @@ public class JavaEntityRemoveEffectTranslator extends PacketTranslator<ServerEnt
|
||||
mobEffectPacket.setEvent(MobEffectPacket.Event.REMOVE);
|
||||
mobEffectPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
mobEffectPacket.setEffectId(EntityUtils.toBedrockEffectId(packet.getEffect()));
|
||||
session.getUpstream().sendPacket(mobEffectPacket);
|
||||
session.sendUpstreamPacket(mobEffectPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class JavaEntityRotationTranslator extends PacketTranslator<ServerEntityR
|
||||
moveEntityAbsolutePacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
moveEntityAbsolutePacket.setPosition(entity.getPosition());
|
||||
moveEntityAbsolutePacket.setRotation(entity.getBedrockRotation());
|
||||
session.getUpstream().sendPacket(moveEntityAbsolutePacket);
|
||||
session.sendUpstreamPacket(moveEntityAbsolutePacket);
|
||||
} else {
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
@ -63,7 +63,7 @@ public class JavaEntityRotationTranslator extends PacketTranslator<ServerEntityR
|
||||
movePlayerPacket.setRotation(entity.getBedrockRotation());
|
||||
movePlayerPacket.setOnGround(packet.isOnGround());
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.ROTATION);
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,6 +96,6 @@ public class JavaEntityStatusTranslator extends PacketTranslator<ServerEntitySta
|
||||
break;
|
||||
}
|
||||
|
||||
session.getUpstream().sendPacket(entityEventPacket);
|
||||
session.sendUpstreamPacket(entityEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,6 @@ public class JavaEntityVelocityTranslator extends PacketTranslator<ServerEntityV
|
||||
entityMotionPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityMotionPacket.setMotion(entity.getMotion());
|
||||
|
||||
session.getUpstream().sendPacket(entityMotionPacket);
|
||||
session.sendUpstreamPacket(entityMotionPacket);
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
|
||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(metadata);
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
|
||||
Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
|
||||
playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP);
|
||||
@ -73,6 +73,6 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator<ServerPlayer
|
||||
adventureSettingsPacket.setCommandPermission(CommandPermission.NORMAL);
|
||||
adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId());
|
||||
adventureSettingsPacket.getFlags().addAll(playerFlags);
|
||||
session.getUpstream().sendPacket(adventureSettingsPacket);
|
||||
session.sendUpstreamPacket(adventureSettingsPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
||||
levelEvent.setType(LevelEventType.DESTROY);
|
||||
levelEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
levelEvent.setData(BlockTranslator.getBedrockBlockId(session.getBreakingBlock()));
|
||||
session.getUpstream().sendPacket(levelEvent);
|
||||
session.sendUpstreamPacket(levelEvent);
|
||||
session.setBreakingBlock(null);
|
||||
}
|
||||
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);
|
||||
levelEvent.setData((int) (65535 / breakTime));
|
||||
session.setBreakingBlock(packet.getNewState());
|
||||
session.getUpstream().sendPacket(levelEvent);
|
||||
session.sendUpstreamPacket(levelEvent);
|
||||
break;
|
||||
case CANCEL_DIGGING:
|
||||
levelEvent.setType(LevelEventType.BLOCK_STOP_BREAK);
|
||||
@ -93,7 +93,7 @@ public class JavaPlayerActionAckTranslator extends PacketTranslator<ServerPlayer
|
||||
));
|
||||
levelEvent.setData(0);
|
||||
session.setBreakingBlock(null);
|
||||
session.getUpstream().sendPacket(levelEvent);
|
||||
session.sendUpstreamPacket(levelEvent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class JavaPlayerChangeHeldItemTranslator extends PacketTranslator<ServerP
|
||||
hotbarPacket.setContainerId(0);
|
||||
hotbarPacket.setSelectedHotbarSlot(packet.getSlot());
|
||||
hotbarPacket.setSelectHotbarSlot(true);
|
||||
session.getUpstream().sendPacket(hotbarPacket);
|
||||
session.sendUpstreamPacket(hotbarPacket);
|
||||
|
||||
session.getInventory().setHeldItemSlot(packet.getSlot());
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class JavaPlayerHealthTranslator extends PacketTranslator<ServerPlayerHea
|
||||
int health = (int) Math.ceil(packet.getHealth());
|
||||
SetHealthPacket setHealthPacket = new SetHealthPacket();
|
||||
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;
|
||||
// Max health must be divisible by two in bedrock
|
||||
|
@ -81,7 +81,7 @@ public class JavaPlayerListEntryTranslator extends PacketTranslator<ServerPlayer
|
||||
}
|
||||
|
||||
if (packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER || session.getUpstream().isInitialized()) {
|
||||
session.getUpstream().sendPacket(translate);
|
||||
session.sendUpstreamPacket(translate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,18 +62,18 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
||||
respawnPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
respawnPacket.setPosition(pos);
|
||||
respawnPacket.setState(RespawnPacket.State.SERVER_READY);
|
||||
session.getUpstream().sendPacket(respawnPacket);
|
||||
session.sendUpstreamPacket(respawnPacket);
|
||||
|
||||
EntityEventPacket eventPacket = new EntityEventPacket();
|
||||
eventPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
eventPacket.setType(EntityEventType.RESPAWN);
|
||||
eventPacket.setData(0);
|
||||
session.getUpstream().sendPacket(eventPacket);
|
||||
session.sendUpstreamPacket(eventPacket);
|
||||
|
||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(entity.getMetadata());
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
|
||||
MovePlayerPacket movePlayerPacket = new MovePlayerPacket();
|
||||
movePlayerPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
@ -81,11 +81,11 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator<Serve
|
||||
movePlayerPacket.setRotation(Vector3f.from(packet.getPitch(), packet.getYaw(), 0));
|
||||
movePlayerPacket.setMode(MovePlayerPacket.Mode.RESET);
|
||||
|
||||
session.getUpstream().sendPacket(movePlayerPacket);
|
||||
session.sendUpstreamPacket(movePlayerPacket);
|
||||
session.setSpawned(true);
|
||||
|
||||
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
|
||||
session.getDownstream().getSession().send(teleportConfirmPacket);
|
||||
session.sendDownstreamPacket(teleportConfirmPacket);
|
||||
|
||||
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);
|
||||
} else {
|
||||
ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(packet.getTeleportId());
|
||||
session.getDownstream().getSession().send(teleportConfirmPacket);
|
||||
session.sendDownstreamPacket(teleportConfirmPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class JavaPlayerStopSoundTranslator extends PacketTranslator<ServerStopSo
|
||||
// packet not mapped in the library
|
||||
stopSoundPacket.setStoppingAllSound(false);
|
||||
|
||||
session.getUpstream().sendPacket(stopSoundPacket);
|
||||
session.sendUpstreamPacket(stopSoundPacket);
|
||||
session.getConnector().getLogger().debug("[StopSound] Packet sent - " + packet.toString() + " --> " + stopSoundPacket);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class JavaCloseWindowTranslator extends PacketTranslator<ServerCloseWindo
|
||||
public void translate(ServerCloseWindowPacket packet, GeyserSession session) {
|
||||
ContainerClosePacket closePacket = new ContainerClosePacket();
|
||||
closePacket.setWindowId((byte)packet.getWindowId());
|
||||
session.getUpstream().sendPacket(closePacket);
|
||||
session.sendUpstreamPacket(closePacket);
|
||||
InventoryUtils.closeInventory(session, packet.getWindowId());
|
||||
}
|
||||
}
|
||||
|
@ -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.server.window.ServerConfirmTransactionPacket;
|
||||
import org.geysermc.connector.inventory.Inventory;
|
||||
import org.geysermc.connector.network.session.GeyserSession;
|
||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||
import org.geysermc.connector.network.translators.Translator;
|
||||
import org.geysermc.connector.network.translators.inventory.InventoryTranslator;
|
||||
import org.geysermc.connector.utils.InventoryUtils;
|
||||
|
||||
@Translator(packet = ServerConfirmTransactionPacket.class)
|
||||
public class JavaConfirmTransactionTranslator extends PacketTranslator<ServerConfirmTransactionPacket> {
|
||||
@ -41,7 +38,7 @@ public class JavaConfirmTransactionTranslator extends PacketTranslator<ServerCon
|
||||
public void translate(ServerConfirmTransactionPacket packet, GeyserSession session) {
|
||||
if (!packet.isAccepted()) {
|
||||
ClientConfirmTransactionPacket confirmPacket = new ClientConfirmTransactionPacket(packet.getWindowId(), packet.getActionId(), true);
|
||||
session.getDownstream().getSession().send(confirmPacket);
|
||||
session.sendDownstreamPacket(confirmPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,11 +55,11 @@ public class JavaOpenWindowTranslator extends PacketTranslator<ServerOpenWindowP
|
||||
if (openInventory != null) {
|
||||
ContainerClosePacket closePacket = new ContainerClosePacket();
|
||||
closePacket.setWindowId((byte)openInventory.getId());
|
||||
session.getUpstream().sendPacket(closePacket);
|
||||
session.sendUpstreamPacket(closePacket);
|
||||
Translators.getInventoryTranslators().get(openInventory.getWindowType()).closeInventory(session, openInventory);
|
||||
}
|
||||
ClientCloseWindowPacket closeWindowPacket = new ClientCloseWindowPacket(packet.getWindowId());
|
||||
session.getDownstream().getSession().send(closeWindowPacket);
|
||||
session.sendDownstreamPacket(closeWindowPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class JavaBlockChangeTranslator extends PacketTranslator<ServerBlockChang
|
||||
placeBlockSoundPacket.setBabySound(false);
|
||||
placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(packet.getRecord().getBlock()));
|
||||
placeBlockSoundPacket.setIdentifier(":");
|
||||
session.getUpstream().sendPacket(placeBlockSoundPacket);
|
||||
session.sendUpstreamPacket(placeBlockSoundPacket);
|
||||
session.setLastBlockPlacePosition(null);
|
||||
session.setLastBlockPlacedId(null);
|
||||
return true;
|
||||
|
@ -53,11 +53,11 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
|
||||
ChestValue value = (ChestValue) packet.getValue() ;
|
||||
blockEventPacket.setEventType(1);
|
||||
blockEventPacket.setEventData(value.getViewers() > 0 ? 1 : 0);
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
}
|
||||
if (packet.getValue() instanceof EndGatewayValue) {
|
||||
blockEventPacket.setEventType(1);
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
}
|
||||
if (packet.getValue() instanceof NoteBlockValue) {
|
||||
NoteblockBlockEntityTranslator.translate(session, packet.getPosition());
|
||||
@ -77,15 +77,15 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
|
||||
}
|
||||
if (packet.getValue() instanceof BeaconValue) {
|
||||
blockEventPacket.setEventType(1);
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
}
|
||||
if (packet.getValue() instanceof MobSpawnerValue) {
|
||||
blockEventPacket.setEventType(1);
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
}
|
||||
if (packet.getValue() instanceof EndGatewayValue) {
|
||||
blockEventPacket.setEventType(1);
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class JavaBlockValueTranslator extends PacketTranslator<ServerBlockValueP
|
||||
blockEntityDataPacket.setBlockPosition(position);
|
||||
byte state = (byte) ((progress == 1.0f && lastProgress == 1.0f) ? 2 : 1);
|
||||
blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state));
|
||||
session.getUpstream().sendPacket(blockEntityDataPacket);
|
||||
session.sendUpstreamPacket(blockEntityDataPacket);
|
||||
if (lastProgress != 1.0f) {
|
||||
session.getConnector().getGeneralThreadPool().schedule(() ->
|
||||
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);
|
||||
byte state = (byte) ((progress == 0.0f && lastProgress == 0.0f) ? 0 : 3);
|
||||
blockEntityDataPacket.setData(buildPistonTag(position, progress, lastProgress, state));
|
||||
session.getUpstream().sendPacket(blockEntityDataPacket);
|
||||
session.sendUpstreamPacket(blockEntityDataPacket);
|
||||
if (lastProgress != 0.0f) {
|
||||
session.getConnector().getGeneralThreadPool().schedule(() ->
|
||||
retractPiston(session, position, (progress <= 0.0f) ? 0.0f : progress - 0.5f, progress),
|
||||
|
@ -98,7 +98,7 @@ public class JavaChunkDataTranslator extends PacketTranslator<ServerChunkDataPac
|
||||
levelChunkPacket.setChunkX(packet.getColumn().getX());
|
||||
levelChunkPacket.setChunkZ(packet.getColumn().getZ());
|
||||
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)
|
||||
for (Object2IntMap.Entry<CompoundTag> blockEntityEntry : chunkData.getLoadBlockEntitiesLater().object2IntEntrySet()) {
|
||||
|
@ -50,6 +50,6 @@ public class JavaCollectItemTranslator extends PacketTranslator<ServerEntityColl
|
||||
}
|
||||
takeItemEntityPacket.setRuntimeEntityId(collectorEntity.getGeyserId());
|
||||
takeItemEntityPacket.setItemRuntimeEntityId(collectedEntity.getGeyserId());
|
||||
session.getUpstream().sendPacket(takeItemEntityPacket);
|
||||
session.sendUpstreamPacket(takeItemEntityPacket);
|
||||
}
|
||||
}
|
||||
|
@ -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.packet.ingame.server.world.ServerExplosionPacket;
|
||||
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.SoundEvent;
|
||||
import com.nukkitx.protocol.bedrock.packet.LevelEventPacket;
|
||||
@ -52,7 +51,7 @@ public class JavaExplosionTranslator extends PacketTranslator<ServerExplosionPac
|
||||
levelEventPacket.setType(LevelEventType.PARTICLE_LARGE_EXPLOSION);
|
||||
levelEventPacket.setData(0);
|
||||
levelEventPacket.setPosition(pos.toFloat());
|
||||
session.getUpstream().sendPacket(levelEventPacket);
|
||||
session.sendUpstreamPacket(levelEventPacket);
|
||||
ChunkUtils.updateBlock(session, BlockTranslator.AIR, pos.toInt());
|
||||
}
|
||||
LevelSoundEventPacket levelSoundEventPacket = new LevelSoundEventPacket();
|
||||
@ -62,6 +61,6 @@ public class JavaExplosionTranslator extends PacketTranslator<ServerExplosionPac
|
||||
levelSoundEventPacket.setSound(SoundEvent.EXPLODE);
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(levelSoundEventPacket);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -61,14 +61,14 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
||||
startRainPacket.setType(LevelEventType.START_RAIN);
|
||||
startRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
|
||||
startRainPacket.setPosition(Vector3f.ZERO);
|
||||
session.getUpstream().sendPacket(startRainPacket);
|
||||
session.sendUpstreamPacket(startRainPacket);
|
||||
break;
|
||||
case STOP_RAIN:
|
||||
LevelEventPacket stopRainPacket = new LevelEventPacket();
|
||||
stopRainPacket.setType(LevelEventType.STOP_RAIN);
|
||||
stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000);
|
||||
stopRainPacket.setPosition(Vector3f.ZERO);
|
||||
session.getUpstream().sendPacket(stopRainPacket);
|
||||
session.sendUpstreamPacket(stopRainPacket);
|
||||
break;
|
||||
case CHANGE_GAMEMODE:
|
||||
Set<AdventureSettingsPacket.Flag> playerFlags = new ObjectOpenHashSet<>();
|
||||
@ -89,14 +89,14 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
||||
|
||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||
playerGameTypePacket.setGamemode(gameMode.ordinal());
|
||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||
session.sendUpstreamPacket(playerGameTypePacket);
|
||||
session.setGameMode(gameMode);
|
||||
|
||||
AdventureSettingsPacket adventureSettingsPacket = new AdventureSettingsPacket();
|
||||
adventureSettingsPacket.setPlayerPermission(PlayerPermission.MEMBER);
|
||||
adventureSettingsPacket.setUniqueEntityId(entity.getGeyserId());
|
||||
adventureSettingsPacket.getFlags().addAll(playerFlags);
|
||||
session.getUpstream().sendPacket(adventureSettingsPacket);
|
||||
session.sendUpstreamPacket(adventureSettingsPacket);
|
||||
|
||||
EntityDataMap metadata = entity.getMetadata();
|
||||
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();
|
||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
entityDataPacket.getMetadata().putAll(metadata);
|
||||
session.getUpstream().sendPacket(entityDataPacket);
|
||||
session.sendUpstreamPacket(entityDataPacket);
|
||||
|
||||
// Update the crafting grid to add/remove barriers for creative inventory
|
||||
PlayerInventoryTranslator.updateCraftingGrid(session, session.getInventory());
|
||||
@ -114,13 +114,13 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
||||
switch ((EnterCreditsValue) packet.getValue()) {
|
||||
case SEEN_BEFORE:
|
||||
ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN);
|
||||
session.getDownstream().getSession().send(javaRespawnPacket);
|
||||
session.sendDownstreamPacket(javaRespawnPacket);
|
||||
break;
|
||||
case FIRST_TIME:
|
||||
ShowCreditsPacket showCreditsPacket = new ShowCreditsPacket();
|
||||
showCreditsPacket.setStatus(ShowCreditsPacket.Status.START_CREDITS);
|
||||
showCreditsPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||
session.getUpstream().sendPacket(showCreditsPacket);
|
||||
session.sendUpstreamPacket(showCreditsPacket);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -57,7 +57,7 @@ public class JavaPlayBuiltinSoundTranslator extends PacketTranslator<ServerPlayB
|
||||
levelEventPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
levelEventPacket.setData(0);
|
||||
levelEventPacket.setType(LevelEventType.valueOf(soundMapping.getBedrock()));
|
||||
session.getUpstream().sendPacket(levelEventPacket);
|
||||
session.sendUpstreamPacket(levelEventPacket);
|
||||
return;
|
||||
}
|
||||
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.setRelativeVolumeDisabled(false);
|
||||
session.getUpstream().sendPacket(soundPacket);
|
||||
session.sendUpstreamPacket(soundPacket);
|
||||
session.getConnector().getLogger().debug("Packet sent - " + packet.toString() + " --> " + soundPacket.toString());
|
||||
}
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
|
||||
soundEvent.setExtraData(-1);
|
||||
soundEvent.setBabySound(false);
|
||||
soundEvent.setRelativeVolumeDisabled(false);
|
||||
session.getUpstream().sendPacket(soundEvent);
|
||||
session.sendUpstreamPacket(soundEvent);
|
||||
break;
|
||||
case BLOCK_LAVA_EXTINGUISH:
|
||||
effect.setType(LevelEventType.SHOOT);
|
||||
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();
|
||||
soundEventPacket.setSound(SoundEvent.EXTINGUISH_FIRE);
|
||||
@ -104,14 +104,14 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
|
||||
soundEventPacket.setExtraData(-1);
|
||||
soundEventPacket.setBabySound(false);
|
||||
soundEventPacket.setRelativeVolumeDisabled(false);
|
||||
session.getUpstream().sendPacket(soundEventPacket);
|
||||
session.sendUpstreamPacket(soundEventPacket);
|
||||
return;
|
||||
default:
|
||||
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()));
|
||||
session.getUpstream().sendPacket(effect);
|
||||
session.sendUpstreamPacket(effect);
|
||||
} else if (packet.getEffect() instanceof SoundEffect) {
|
||||
SoundEffect soundEffect = (SoundEffect) packet.getEffect();
|
||||
Effect geyserEffect = EffectUtils.EFFECTS.get(soundEffect.name());
|
||||
@ -131,7 +131,7 @@ public class JavaPlayEffectTranslator extends PacketTranslator<ServerPlayEffectP
|
||||
soundEvent.setExtraData(geyserEffect.getData());
|
||||
soundEvent.setIdentifier(geyserEffect.getIdentifier());
|
||||
soundEvent.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
session.getUpstream().sendPacket(soundEvent);
|
||||
session.sendUpstreamPacket(soundEvent);
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
effect.setPosition(Vector3f.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
session.getUpstream().sendPacket(effect);
|
||||
session.sendUpstreamPacket(effect);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class JavaPlayerPlaySoundTranslator extends PacketTranslator<ServerPlaySo
|
||||
playSoundPacket.setVolume(packet.getVolume());
|
||||
playSoundPacket.setPitch(packet.getPitch());
|
||||
|
||||
session.getUpstream().sendPacket(playSoundPacket);
|
||||
session.sendUpstreamPacket(playSoundPacket);
|
||||
session.getConnector().getLogger().debug("[PlaySound] Packet sent - " + packet.toString() + " --> " + playSoundPacket);
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
|
||||
particle.setType(LevelEventType.DESTROY);
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
particle.setData(BlockTranslator.getBedrockBlockId(((BlockParticleData) packet.getParticle().getData()).getBlockState()));
|
||||
session.getUpstream().sendPacket(particle);
|
||||
session.sendUpstreamPacket(particle);
|
||||
break;
|
||||
case FALLING_DUST:
|
||||
//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.setData(BlockTranslator.getBedrockBlockId(((FallingDustParticleData)packet.getParticle().getData()).getBlockState()));
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(particle);
|
||||
session.sendUpstreamPacket(particle);
|
||||
break;
|
||||
case ITEM:
|
||||
ItemStack javaItem = ((ItemParticleData)packet.getParticle().getData()).getItemStack();
|
||||
@ -70,7 +70,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
|
||||
particle.setType(LevelEventType.PARTICLE_ITEM_BREAK);
|
||||
particle.setData(id << 16 | damage);
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(particle);
|
||||
session.sendUpstreamPacket(particle);
|
||||
break;
|
||||
case DUST:
|
||||
DustParticleData data = (DustParticleData)packet.getParticle().getData();
|
||||
@ -80,14 +80,14 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
|
||||
particle.setType(LevelEventType.PARTICLE_FALLING_DUST);
|
||||
particle.setData(((0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff));
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(particle);
|
||||
session.sendUpstreamPacket(particle);
|
||||
break;
|
||||
default:
|
||||
LevelEventType typeParticle = EffectUtils.getParticleLevelEventType(packet.getParticle().getType());
|
||||
if (typeParticle != null) {
|
||||
particle.setType(typeParticle);
|
||||
particle.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(particle);
|
||||
session.sendUpstreamPacket(particle);
|
||||
} else {
|
||||
String stringParticle = EffectUtils.getParticleString(packet.getParticle().getType());
|
||||
if (stringParticle != null) {
|
||||
@ -95,7 +95,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator<ServerSpawnPar
|
||||
stringPacket.setIdentifier(stringParticle);
|
||||
stringPacket.setDimensionId(session.getPlayerEntity().getDimension());
|
||||
stringPacket.setPosition(Vector3f.from(packet.getX(), packet.getY(), packet.getZ()));
|
||||
session.getUpstream().sendPacket(stringPacket);
|
||||
session.sendUpstreamPacket(stringPacket);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -42,6 +42,6 @@ public class JavaSpawnPositionTranslator extends PacketTranslator<ServerSpawnPos
|
||||
spawnPositionPacket.setBlockPosition(Vector3i.from(packet.getPosition().getX(), packet.getPosition().getY(), packet.getPosition().getZ()));
|
||||
spawnPositionPacket.setSpawnForced(true);
|
||||
spawnPositionPacket.setSpawnType(SetSpawnPositionPacket.Type.WORLD_SPAWN);
|
||||
session.getUpstream().sendPacket(spawnPositionPacket);
|
||||
session.sendUpstreamPacket(spawnPositionPacket);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class JavaUpdateTimeTranslator extends PacketTranslator<ServerUpdateTimeP
|
||||
// https://minecraft.gamepedia.com/Day-night_cycle#24-hour_Minecraft_day
|
||||
SetTimePacket setTimePacket = new SetTimePacket();
|
||||
setTimePacket.setTime((int) Math.abs(time) % 24000);
|
||||
session.getUpstream().sendPacket(setTimePacket);
|
||||
session.sendUpstreamPacket(setTimePacket);
|
||||
// TODO: Performance efficient to always do this?
|
||||
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) {
|
||||
GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket();
|
||||
gameRulesChangedPacket.getGameRules().add(new GameRuleData<>("dodaylightcycle", doCycle));
|
||||
session.getUpstream().sendPacket(gameRulesChangedPacket);
|
||||
session.sendUpstreamPacket(gameRulesChangedPacket);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class BucketSoundInteractionHandler implements BlockSoundInteractionHandl
|
||||
}
|
||||
if (soundEvent != null) {
|
||||
soundEventPacket.setSound(soundEvent);
|
||||
session.getUpstream().sendPacket(soundEventPacket);
|
||||
session.sendUpstreamPacket(soundEventPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ public class ComparatorSoundInteractHandler implements BlockSoundInteractionHand
|
||||
levelEventPacket.setPosition(position);
|
||||
levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
|
||||
levelEventPacket.setData(powered ? 500 : 550);
|
||||
session.getUpstream().sendPacket(levelEventPacket);
|
||||
session.sendUpstreamPacket(levelEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,6 @@ public class DoorSoundInteractionHandler implements BlockSoundInteractionHandler
|
||||
levelEventPacket.setType(LevelEventType.SOUND_DOOR);
|
||||
levelEventPacket.setPosition(position);
|
||||
levelEventPacket.setData(0);
|
||||
session.getUpstream().sendPacket(levelEventPacket);
|
||||
session.sendUpstreamPacket(levelEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,6 @@ public class FlintAndSteelInteractionHandler implements BlockSoundInteractionHan
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setSound(SoundEvent.IGNITE);
|
||||
levelSoundEventPacket.setExtraData(-1);
|
||||
session.getUpstream().sendPacket(levelSoundEventPacket);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,6 @@ public class GrassPathInteractionHandler implements BlockSoundInteractionHandler
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
||||
levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier)));
|
||||
session.getUpstream().sendPacket(levelSoundEventPacket);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,6 @@ public class HoeInteractionHandler implements BlockSoundInteractionHandler {
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON);
|
||||
levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier)));
|
||||
session.getUpstream().sendPacket(levelSoundEventPacket);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ public class LeverSoundInteractionHandler implements BlockSoundInteractionHandle
|
||||
levelEventPacket.setPosition(position);
|
||||
levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER);
|
||||
levelEventPacket.setData(powered ? 600 : 500);
|
||||
session.getUpstream().sendPacket(levelEventPacket);
|
||||
session.sendUpstreamPacket(levelEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,6 @@ public class MilkCowSoundInteractionHandler implements EntitySoundInteractionHan
|
||||
levelSoundEventPacket.setIdentifier(":");
|
||||
levelSoundEventPacket.setSound(SoundEvent.MILK);
|
||||
levelSoundEventPacket.setExtraData(-1);
|
||||
session.getUpstream().sendPacket(levelSoundEventPacket);
|
||||
session.sendUpstreamPacket(levelSoundEventPacket);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class FlowerPotBlockEntityTranslator implements BedrockOnlyBlockEntity, R
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
session.getUpstream().sendPacket(updateBlockPacket);
|
||||
session.sendUpstreamPacket(updateBlockPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ public class NoteblockBlockEntityTranslator implements RequiresBlockState {
|
||||
blockEventPacket.setBlockPosition(Vector3i.from(position.getX(), position.getY(), position.getZ()));
|
||||
blockEventPacket.setEventType(0);
|
||||
blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState));
|
||||
session.getUpstream().sendPacket(blockEventPacket);
|
||||
session.sendUpstreamPacket(blockEventPacket);
|
||||
|
||||
ChunkUtils.CACHED_BLOCK_ENTITIES.remove(position);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ public class Scoreboard {
|
||||
if (objective.getUpdateType() == REMOVE || update) {
|
||||
RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket();
|
||||
removeObjectivePacket.setObjectiveId(objective.getObjectiveName());
|
||||
session.getUpstream().sendPacket(removeObjectivePacket);
|
||||
session.sendUpstreamPacket(removeObjectivePacket);
|
||||
if (objective.getUpdateType() == REMOVE) {
|
||||
objectives.remove(objective.getObjectiveName()); // now we can deregister
|
||||
}
|
||||
@ -199,7 +199,7 @@ public class Scoreboard {
|
||||
displayObjectivePacket.setCriteria("dummy");
|
||||
displayObjectivePacket.setDisplaySlot(objective.getDisplaySlot());
|
||||
displayObjectivePacket.setSortOrder(1); // ??
|
||||
session.getUpstream().sendPacket(displayObjectivePacket);
|
||||
session.sendUpstreamPacket(displayObjectivePacket);
|
||||
}
|
||||
objective.setUpdateType(NOTHING);
|
||||
}
|
||||
@ -208,21 +208,21 @@ public class Scoreboard {
|
||||
SetScorePacket setScorePacket = new SetScorePacket();
|
||||
setScorePacket.setAction(SetScorePacket.Action.REMOVE);
|
||||
setScorePacket.setInfos(removeScores);
|
||||
session.getUpstream().sendPacket(setScorePacket);
|
||||
session.sendUpstreamPacket(setScorePacket);
|
||||
}
|
||||
|
||||
if (!addScores.isEmpty()) {
|
||||
SetScorePacket setScorePacket = new SetScorePacket();
|
||||
setScorePacket.setAction(SetScorePacket.Action.SET);
|
||||
setScorePacket.setInfos(addScores);
|
||||
session.getUpstream().sendPacket(setScorePacket);
|
||||
session.sendUpstreamPacket(setScorePacket);
|
||||
}
|
||||
}
|
||||
|
||||
public void despawnObjective(Objective objective) {
|
||||
RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket();
|
||||
removeObjectivePacket.setObjectiveId(objective.getObjectiveName());
|
||||
session.getUpstream().sendPacket(removeObjectivePacket);
|
||||
session.sendUpstreamPacket(removeObjectivePacket);
|
||||
objectives.remove(objective.getDisplayName());
|
||||
|
||||
List<ScoreInfo> toRemove = new ArrayList<>();
|
||||
@ -238,7 +238,7 @@ public class Scoreboard {
|
||||
SetScorePacket setScorePacket = new SetScorePacket();
|
||||
setScorePacket.setAction(SetScorePacket.Action.REMOVE);
|
||||
setScorePacket.setInfos(toRemove);
|
||||
session.getUpstream().sendPacket(setScorePacket);
|
||||
session.sendUpstreamPacket(setScorePacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,6 @@ public class BlockEntityUtils {
|
||||
BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket();
|
||||
blockEntityPacket.setBlockPosition(position);
|
||||
blockEntityPacket.setData(blockEntity);
|
||||
session.getUpstream().sendPacket(blockEntityPacket);
|
||||
session.sendUpstreamPacket(blockEntityPacket);
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ public class ChunkUtils {
|
||||
NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket();
|
||||
chunkPublisherUpdatePacket.setPosition(position);
|
||||
chunkPublisherUpdatePacket.setRadius(session.getRenderDistance() << 4);
|
||||
session.getUpstream().sendPacket(chunkPublisherUpdatePacket);
|
||||
session.sendUpstreamPacket(chunkPublisherUpdatePacket);
|
||||
|
||||
session.setLastChunkPosition(newChunkPos);
|
||||
}
|
||||
@ -188,7 +188,7 @@ public class ChunkUtils {
|
||||
updateBlockPacket.setBlockPosition(position);
|
||||
updateBlockPacket.setRuntimeId(blockId);
|
||||
updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS);
|
||||
session.getUpstream().sendPacket(updateBlockPacket);
|
||||
session.sendUpstreamPacket(updateBlockPacket);
|
||||
|
||||
UpdateBlockPacket waterPacket = new UpdateBlockPacket();
|
||||
waterPacket.setDataLayer(1);
|
||||
@ -198,7 +198,7 @@ public class ChunkUtils {
|
||||
} else {
|
||||
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
|
||||
// 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.setData(Translators.EMPTY_LEVEL_CHUNK_DATA);
|
||||
data.setCachingEnabled(false);
|
||||
session.getUpstream().sendPacket(data);
|
||||
session.sendUpstreamPacket(data);
|
||||
|
||||
if (forceUpdate) {
|
||||
Vector3i pos = Vector3i.from(chunkX + x << 4, 80, chunkZ + z << 4);
|
||||
@ -236,7 +236,7 @@ public class ChunkUtils {
|
||||
blockPacket.setBlockPosition(pos);
|
||||
blockPacket.setDataLayer(0);
|
||||
blockPacket.setRuntimeId(1);
|
||||
session.getUpstream().sendPacket(blockPacket);
|
||||
session.sendUpstreamPacket(blockPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class DimensionUtils {
|
||||
changeDimensionPacket.setDimension(bedrockDimension);
|
||||
changeDimensionPacket.setRespawn(true);
|
||||
changeDimensionPacket.setPosition(pos.toFloat());
|
||||
session.getUpstream().sendPacket(changeDimensionPacket);
|
||||
session.sendUpstreamPacket(changeDimensionPacket);
|
||||
player.setDimension(bedrockDimension);
|
||||
player.setPosition(pos.toFloat());
|
||||
session.setSpawned(false);
|
||||
@ -59,7 +59,7 @@ public class DimensionUtils {
|
||||
StopSoundPacket stopSoundPacket = new StopSoundPacket();
|
||||
stopSoundPacket.setStoppingAllSound(true);
|
||||
stopSoundPacket.setSoundName("");
|
||||
session.getUpstream().sendPacket(stopSoundPacket);
|
||||
session.sendUpstreamPacket(stopSoundPacket);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +84,7 @@ public class InventoryUtils {
|
||||
cursorPacket.setContainerId(ContainerId.CURSOR);
|
||||
cursorPacket.setSlot(0);
|
||||
cursorPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, session.getInventory().getCursor()));
|
||||
session.getUpstream().sendPacket(cursorPacket);
|
||||
session.sendUpstreamPacket(cursorPacket);
|
||||
}
|
||||
|
||||
public static boolean canStack(ItemStack item1, ItemStack item2) {
|
||||
|
@ -35,8 +35,6 @@ import com.nukkitx.protocol.bedrock.packet.LoginPacket;
|
||||
import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket;
|
||||
import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
|
||||
|
||||
import net.minidev.json.JSONObject;
|
||||
|
||||
import org.geysermc.common.window.CustomFormBuilder;
|
||||
import org.geysermc.common.window.CustomFormWindow;
|
||||
import org.geysermc.common.window.FormWindow;
|
||||
@ -152,7 +150,7 @@ public class LoginEncryptionUtils {
|
||||
|
||||
ServerToClientHandshakePacket packet = new ServerToClientHandshakePacket();
|
||||
packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize());
|
||||
session.getUpstream().sendPacketImmediately(packet);
|
||||
session.sendUpstreamPacketImmediately(packet);
|
||||
}
|
||||
|
||||
private static int AUTH_FORM_ID = 1336;
|
||||
|
@ -177,12 +177,12 @@ public class SkinUtils {
|
||||
PlayerListPacket playerRemovePacket = new PlayerListPacket();
|
||||
playerRemovePacket.setAction(PlayerListPacket.Action.REMOVE);
|
||||
playerRemovePacket.getEntries().add(updatedEntry);
|
||||
session.getUpstream().sendPacket(playerRemovePacket);
|
||||
session.sendUpstreamPacket(playerRemovePacket);
|
||||
|
||||
PlayerListPacket playerAddPacket = new PlayerListPacket();
|
||||
playerAddPacket.setAction(PlayerListPacket.Action.ADD);
|
||||
playerAddPacket.getEntries().add(updatedEntry);
|
||||
session.getUpstream().sendPacket(playerAddPacket);
|
||||
session.sendUpstreamPacket(playerAddPacket);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren