forked from GeyserMC/Geyser
Merge branch 'master' into inventory
This commit is contained in:
commit
659d52d18a
7 changed files with 16 additions and 14 deletions
|
@ -28,6 +28,7 @@ package org.geysermc.connector.network.session;
|
||||||
import com.github.steveice10.mc.auth.data.GameProfile;
|
import com.github.steveice10.mc.auth.data.GameProfile;
|
||||||
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
import com.github.steveice10.mc.auth.exception.request.RequestException;
|
||||||
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
import com.github.steveice10.mc.protocol.MinecraftProtocol;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
|
||||||
import com.github.steveice10.packetlib.Client;
|
import com.github.steveice10.packetlib.Client;
|
||||||
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
|
||||||
|
@ -95,9 +96,7 @@ public class GeyserSession implements Player {
|
||||||
private boolean closed;
|
private boolean closed;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private Vector3i blockDiggingPos = Vector3i.ZERO;
|
private GameMode gameMode = GameMode.SURVIVAL;
|
||||||
@Setter
|
|
||||||
private BlockFace blockDiggingFace = BlockFace.DOWN;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|
|
@ -93,12 +93,9 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||||
case START_BREAK:
|
case START_BREAK:
|
||||||
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(),
|
ClientPlayerActionPacket startBreakingPacket = new ClientPlayerActionPacket(PlayerAction.START_DIGGING, new Position(packet.getBlockPosition().getX(),
|
||||||
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]);
|
packet.getBlockPosition().getY(), packet.getBlockPosition().getZ()), BlockFace.values()[packet.getFace()]);
|
||||||
session.setBlockDiggingPos(packet.getBlockPosition());
|
|
||||||
session.setBlockDiggingFace(BlockFace.values()[packet.getFace()]);
|
|
||||||
session.getDownstream().getSession().send(startBreakingPacket);
|
session.getDownstream().getSession().send(startBreakingPacket);
|
||||||
break;
|
break;
|
||||||
case CONTINUE_BREAK:
|
case CONTINUE_BREAK:
|
||||||
session.setBlockDiggingFace(BlockFace.values()[packet.getFace()]);
|
|
||||||
break;
|
break;
|
||||||
case ABORT_BREAK:
|
case ABORT_BREAK:
|
||||||
ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(),
|
ClientPlayerActionPacket abortBreakingPacket = new ClientPlayerActionPacket(PlayerAction.CANCEL_DIGGING, new Position(packet.getBlockPosition().getX(),
|
||||||
|
@ -106,10 +103,7 @@ public class BedrockActionTranslator extends PacketTranslator<PlayerActionPacket
|
||||||
session.getDownstream().getSession().send(abortBreakingPacket);
|
session.getDownstream().getSession().send(abortBreakingPacket);
|
||||||
break;
|
break;
|
||||||
case STOP_BREAK:
|
case STOP_BREAK:
|
||||||
Vector3i pos = session.getBlockDiggingPos();
|
// Handled in BedrockInventoryTransactionTranslator
|
||||||
ClientPlayerActionPacket stopBreakingPacket = new ClientPlayerActionPacket(PlayerAction.FINISH_DIGGING, new Position(pos.getX(),
|
|
||||||
pos.getY(), pos.getZ()), session.getBlockDiggingFace());
|
|
||||||
session.getDownstream().getSession().send(stopBreakingPacket);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||||
import com.nukkitx.math.vector.Vector3f;
|
import com.nukkitx.math.vector.Vector3f;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.ItemStack;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
import com.github.steveice10.mc.protocol.data.game.entity.metadata.Position;
|
||||||
|
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.Hand;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
||||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||||
|
@ -325,6 +326,11 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator<Inve
|
||||||
if (packet.getActionType() == 1) {
|
if (packet.getActionType() == 1) {
|
||||||
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
ClientPlayerUseItemPacket useItemPacket = new ClientPlayerUseItemPacket(Hand.MAIN_HAND);
|
||||||
session.getDownstream().getSession().send(useItemPacket);
|
session.getDownstream().getSession().send(useItemPacket);
|
||||||
|
} else if (packet.getActionType() == 2) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ITEM_RELEASE:
|
case ITEM_RELEASE:
|
||||||
|
|
|
@ -52,6 +52,7 @@ public class JavaJoinGameTranslator extends PacketTranslator<ServerJoinGamePacke
|
||||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
|
playerGameTypePacket.setGamemode(packet.getGameMode().ordinal());
|
||||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||||
|
session.setGameMode(packet.getGameMode());
|
||||||
|
|
||||||
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
SetEntityDataPacket entityDataPacket = new SetEntityDataPacket();
|
||||||
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
entityDataPacket.setRuntimeEntityId(entity.getGeyserId());
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class JavaRespawnTranslator extends PacketTranslator<ServerRespawnPacket>
|
||||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
playerGameTypePacket.setGamemode(packet.getGamemode().ordinal());
|
||||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||||
|
session.setGameMode(packet.getGamemode());
|
||||||
|
|
||||||
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
PlayStatusPacket playStatusPacket = new PlayStatusPacket();
|
||||||
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN);
|
||||||
|
|
|
@ -57,10 +57,11 @@ public class JavaNotifyClientTranslator extends PacketTranslator<ServerNotifyCli
|
||||||
session.getUpstream().sendPacket(stopRainPacket);
|
session.getUpstream().sendPacket(stopRainPacket);
|
||||||
break;
|
break;
|
||||||
case CHANGE_GAMEMODE:
|
case CHANGE_GAMEMODE:
|
||||||
int gamemode = ((GameMode) packet.getValue()).ordinal();
|
GameMode gameMode = (GameMode) packet.getValue();
|
||||||
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket();
|
||||||
playerGameTypePacket.setGamemode(gamemode);
|
playerGameTypePacket.setGamemode(gameMode.ordinal());
|
||||||
session.getUpstream().sendPacket(playerGameTypePacket);
|
session.getUpstream().sendPacket(playerGameTypePacket);
|
||||||
|
session.setGameMode(gameMode);
|
||||||
break;
|
break;
|
||||||
case ENTER_CREDITS:
|
case ENTER_CREDITS:
|
||||||
Entity entity = session.getPlayerEntity();
|
Entity entity = session.getPlayerEntity();
|
||||||
|
|
|
@ -22,7 +22,7 @@ remote:
|
||||||
port: 25565
|
port: 25565
|
||||||
|
|
||||||
# Authentication type. Can be offline, online, or hybrid (see the wiki).
|
# Authentication type. Can be offline, online, or hybrid (see the wiki).
|
||||||
auth-type: offline
|
auth-type: online
|
||||||
|
|
||||||
## the Xbox/MCPE username is the key for the Java server auth-info
|
## the Xbox/MCPE username is the key for the Java server auth-info
|
||||||
## this allows automatic configuration/login to the remote Java server
|
## this allows automatic configuration/login to the remote Java server
|
||||||
|
|
Loading…
Reference in a new issue