Search in sources :

Example 1 with INMSHandler

use of thpmc.engine.api.nms.INMSHandler in project THP-Engine by TheHollowPlanetMC.

the class PacketHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext channelHandlerContext, Object packet) throws Exception {
    INMSHandler nmsHandler = NMSManager.getNMSHandler();
    if (nmsHandler.isFlyPacket(packet)) {
        super.channelRead(channelHandlerContext, NMSManager.getFlyPacketHandler().rewrite(packet, EnginePlayer, ImplTHPESettings.isUseCachedChunkPacket()));
        return;
    }
    super.channelRead(channelHandlerContext, packet);
}
Also used : INMSHandler(thpmc.engine.api.nms.INMSHandler)

Example 2 with INMSHandler

use of thpmc.engine.api.nms.INMSHandler in project THP-Engine by TheHollowPlanetMC.

the class EnginePlayerEntity method hide.

@Override
public void hide(EnginePlayer player) {
    INMSHandler nmsHandler = THPEngineAPI.getInstance().getNMSHandler();
    Player bukkitPlayer = player.getBukkitPlayer();
    nmsHandler.sendPacket(bukkitPlayer, nmsHandler.createPlayerInfoPacket(nmsEntity, WrappedPlayerInfoAction.REMOVE_PLAYER));
    nmsHandler.sendPacket(bukkitPlayer, nmsHandler.createEntityDestroyPacket(nmsEntity));
}
Also used : EnginePlayer(thpmc.engine.api.player.EnginePlayer) NMSEntityPlayer(thpmc.engine.api.nms.entity.NMSEntityPlayer) Player(org.bukkit.entity.Player) INMSHandler(thpmc.engine.api.nms.INMSHandler)

Example 3 with INMSHandler

use of thpmc.engine.api.nms.INMSHandler in project THP-Engine by TheHollowPlanetMC.

the class EnginePlayerEntity method playTickResult.

@Override
public void playTickResult(EnginePlayer player, boolean absolute) {
    INMSHandler nmsHandler = THPEngineAPI.getInstance().getNMSHandler();
    Player bukkitPlayer = player.getBukkitPlayer();
    nmsHandler.sendPacket(bukkitPlayer, nmsHandler.createHeadRotationPacket(nmsEntity, yaw));
    if (absolute) {
        nmsHandler.sendPacket(bukkitPlayer, nmsHandler.createTeleportPacket(nmsEntity));
    } else {
        nmsHandler.sendPacket(bukkitPlayer, nmsHandler.createRelEntityMoveLookPacket(nmsEntity, x - previousX, y - previousY, z - previousZ, yaw, pitch));
    }
}
Also used : EnginePlayer(thpmc.engine.api.player.EnginePlayer) NMSEntityPlayer(thpmc.engine.api.nms.entity.NMSEntityPlayer) Player(org.bukkit.entity.Player) INMSHandler(thpmc.engine.api.nms.INMSHandler)

Example 4 with INMSHandler

use of thpmc.engine.api.nms.INMSHandler in project THP-Engine by TheHollowPlanetMC.

the class ImplParallelChunk method sendUpdate.

@Override
public void sendUpdate(Player player) {
    INMSHandler nmsHandler = NMSManager.getNMSHandler();
    nmsHandler.sendChunkMultiBlockChangeUpdatePacket(player, this);
    TaskHandler.runSync(() -> {
        World world = Bukkit.getWorld(getWorld().getName());
        if (world == null)
            return;
        TaskHandler.runWorldSync(world, () -> {
            Object lightUpdatePacket = nmsHandler.createLightUpdatePacketAtPrimaryThread(this);
            if (lightUpdatePacket != null)
                nmsHandler.sendPacket(player, lightUpdatePacket);
        });
    });
}
Also used : ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) World(org.bukkit.World) INMSHandler(thpmc.engine.api.nms.INMSHandler)

Example 5 with INMSHandler

use of thpmc.engine.api.nms.INMSHandler in project THP-Engine by TheHollowPlanetMC.

the class ImplParallelWorld method sendMultiBlockUpdate.

@Override
public void sendMultiBlockUpdate(Set<BlockPosition3i> blocks) {
    INMSHandler nmsHandler = NMSManager.getNMSHandler();
    Set<Object> packets = nmsHandler.createMultiBlockChangePacket(this, blocks);
    for (Object packet : packets) {
        parallelUniverse.getResidents().forEach(player -> {
            if (worldName.equals(player.getBukkitPlayer().getWorld().getName()))
                nmsHandler.sendPacket(player.getBukkitPlayer(), packet);
        });
    }
}
Also used : INMSHandler(thpmc.engine.api.nms.INMSHandler)

Aggregations

INMSHandler (thpmc.engine.api.nms.INMSHandler)15 EngineBlock (thpmc.engine.api.world.block.EngineBlock)5 Player (org.bukkit.entity.Player)4 NMSEntityPlayer (thpmc.engine.api.nms.entity.NMSEntityPlayer)4 EngineChunk (thpmc.engine.api.world.cache.EngineChunk)4 Vector (org.bukkit.util.Vector)3 EnginePlayer (thpmc.engine.api.player.EnginePlayer)3 HashSet (java.util.HashSet)2 Location (org.bukkit.Location)2 World (org.bukkit.World)2 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)2 GameProfile (com.mojang.authlib.GameProfile)1 ArrayList (java.util.ArrayList)1 EventHandler (org.bukkit.event.EventHandler)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 EnginePlayerEntity (thpmc.engine.api.entity.EnginePlayerEntity)1 EntityFollowGoal (thpmc.engine.api.entity.ai.navigation.goal.EntityFollowGoal)1 BlockPosition (thpmc.engine.api.entity.ai.pathfinding.BlockPosition)1 NMSEntity (thpmc.engine.api.nms.entity.NMSEntity)1