mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Minor tweaks
This commit is contained in:
parent
9a7c07af65
commit
be31c4e03d
@ -116,6 +116,9 @@ public class Player extends LivingEntity {
|
||||
// Vehicle
|
||||
private PlayerVehicleInformation vehicleInformation = new PlayerVehicleInformation();
|
||||
|
||||
// Tick related
|
||||
private final PlayerTickEvent playerTickEvent = new PlayerTickEvent();
|
||||
|
||||
public Player(UUID uuid, String username, PlayerConnection playerConnection) {
|
||||
super(EntityType.PLAYER);
|
||||
this.uuid = uuid;
|
||||
@ -317,7 +320,7 @@ public class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
// Tick event
|
||||
callEvent(PlayerTickEvent.class, new PlayerTickEvent());
|
||||
callEvent(PlayerTickEvent.class, playerTickEvent);
|
||||
|
||||
|
||||
// Multiplayer sync
|
||||
|
@ -163,7 +163,7 @@ public class Chunk implements Viewable {
|
||||
public short getBlockId(int x, int y, int z) {
|
||||
unloadCheck();
|
||||
int index = getBlockIndex(x, y, z);
|
||||
if (index < 0 || index >= blocksId.length) {
|
||||
if (!MathUtils.isBetween(index, 0, blocksId.length)) {
|
||||
return 0; // TODO: custom invalid block
|
||||
}
|
||||
short id = blocksId[index];
|
||||
|
@ -11,7 +11,7 @@ import net.minestom.server.network.packet.client.handler.ClientLoginPacketsHandl
|
||||
import net.minestom.server.network.packet.client.handler.ClientPlayPacketsHandler;
|
||||
import net.minestom.server.network.packet.client.handler.ClientStatusPacketsHandler;
|
||||
import net.minestom.server.network.packet.client.handshake.HandshakePacket;
|
||||
import net.minestom.server.network.player.BasicPlayerConnection;
|
||||
import net.minestom.server.network.player.NettyPlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -42,7 +42,7 @@ public class PacketProcessor {
|
||||
|
||||
public void process(ChannelHandlerContext channel, ByteBuf buffer, int id, int offset) {
|
||||
PlayerConnection playerConnection =
|
||||
connectionPlayerConnectionMap.computeIfAbsent(channel, c -> new BasicPlayerConnection(channel));
|
||||
connectionPlayerConnectionMap.computeIfAbsent(channel, c -> new NettyPlayerConnection(channel));
|
||||
ConnectionState connectionState = playerConnection.getConnectionState();
|
||||
//if (!printBlackList.contains(id)) {
|
||||
//System.out.println("RECEIVED ID: 0x" + Integer.toHexString(id) + " State: " + connectionState);
|
||||
|
@ -11,11 +11,11 @@ import java.net.SocketAddress;
|
||||
* Represent a networking connection with Netty
|
||||
* It is the implementation used for all server connection client
|
||||
*/
|
||||
public class BasicPlayerConnection extends PlayerConnection {
|
||||
public class NettyPlayerConnection extends PlayerConnection {
|
||||
|
||||
private ChannelHandlerContext channel;
|
||||
|
||||
public BasicPlayerConnection(ChannelHandlerContext channel) {
|
||||
public NettyPlayerConnection(ChannelHandlerContext channel) {
|
||||
super();
|
||||
this.channel = channel;
|
||||
}
|
@ -2,22 +2,21 @@ package net.minestom.server.utils.player;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.fakeplayer.FakePlayer;
|
||||
import net.minestom.server.network.player.FakePlayerConnection;
|
||||
import net.minestom.server.network.player.NettyPlayerConnection;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
public static boolean isNettyClient(Entity entity) {
|
||||
return (entity instanceof Player) && !(entity instanceof FakePlayer);
|
||||
public static boolean isNettyClient(PlayerConnection playerConnection) {
|
||||
return playerConnection instanceof NettyPlayerConnection;
|
||||
}
|
||||
|
||||
public static boolean isNettyClient(Player player) {
|
||||
return !(player instanceof FakePlayer);
|
||||
return isNettyClient(player.getPlayerConnection());
|
||||
}
|
||||
|
||||
public static boolean isNettyClient(PlayerConnection playerConnection) {
|
||||
return !(playerConnection instanceof FakePlayerConnection);
|
||||
public static boolean isNettyClient(Entity entity) {
|
||||
return (entity instanceof Player) && isNettyClient((Player) entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user