use of thpmc.vanilla_source.api.nms.INMSHandler in project VanillaSource 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);
});
}
}
use of thpmc.vanilla_source.api.nms.INMSHandler in project VanillaSource by TheHollowPlanetMC.
the class ImplParallelWorld method sendBlockUpdate.
@Override
public void sendBlockUpdate(int blockX, int blockY, int blockZ) {
INMSHandler nmsHandler = NMSManager.getNMSHandler();
Object packet = nmsHandler.createBlockChangePacket(this, blockX, blockY, blockZ);
if (packet != null) {
parallelUniverse.getResidents().forEach(player -> {
if (worldName.equals(player.getBukkitPlayer().getWorld().getName()))
nmsHandler.sendPacket(player.getBukkitPlayer(), packet);
});
}
}
use of thpmc.vanilla_source.api.nms.INMSHandler in project VanillaSource by TheHollowPlanetMC.
the class PacketHandler method write.
@Override
public void write(ChannelHandlerContext channelHandlerContext, Object packet, ChannelPromise channelPromise) throws Exception {
INMSHandler nmsHandler = NMSManager.getNMSHandler();
if (nmsHandler.isMapChunkPacket(packet)) {
super.write(channelHandlerContext, NMSManager.getMapChunkPacketHandler().rewrite(packet, EnginePlayer, ImplVSSettings.isUseCachedChunkPacket()), channelPromise);
return;
}
if (nmsHandler.isLightUpdatePacket(packet) && ImplVSSettings.isRewriteLightPacket()) {
super.write(channelHandlerContext, NMSManager.getLightUpdatePacketHandler().rewrite(packet, EnginePlayer, ImplVSSettings.isUseCachedChunkPacket()), channelPromise);
return;
}
if (nmsHandler.isBlockChangePacket(packet)) {
super.write(channelHandlerContext, NMSManager.getBlockChangePacketHandler().rewrite(packet, EnginePlayer, ImplVSSettings.isUseCachedChunkPacket()), channelPromise);
return;
}
if (nmsHandler.isMultiBlockChangePacket(packet)) {
super.write(channelHandlerContext, NMSManager.getMultiBlockChangePacketHandler().rewrite(packet, EnginePlayer, ImplVSSettings.isUseCachedChunkPacket()), channelPromise);
return;
}
super.write(channelHandlerContext, packet, channelPromise);
}
use of thpmc.vanilla_source.api.nms.INMSHandler in project VanillaSource 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, ImplVSSettings.isUseCachedChunkPacket()));
return;
}
super.channelRead(channelHandlerContext, packet);
}
use of thpmc.vanilla_source.api.nms.INMSHandler in project VanillaSource by TheHollowPlanetMC.
the class TestListener method onChat.
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (!event.getMessage().equals("spawn"))
return;
TaskHandler.runSync(() -> {
Location location = player.getLocation();
INMSHandler nmsHandler = VanillaSourceAPI.getInstance().getNMSHandler();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "NPC");
NMSEntityController entityPlayer = nmsHandler.createNMSEntityController(location.getWorld(), location.getX(), location.getY(), location.getZ(), EntityType.PLAYER, gameProfile);
entityPlayer.setPositionRaw(location.getX(), location.getY(), location.getZ());
CollideOption collideOption = new CollideOption(FluidCollisionMode.NEVER, true);
/*
collideOption.setCollideBlockFunction(engineBlock -> {
return engineBlock.getMaterial() != Material.GLASS;
});*/
/*
VanillaSourceAPI.getInstance().getTickRunnerPool().spawn(tickRunner -> {
EnginePlayerEntity npc = new EnginePlayerEntity(tickRunner.getThreadLocalCache().getWorld(location.getWorld().getName()), (NMSEntityPlayer) entityPlayer, tickRunner, true);
npc.getGoalSelector().registerGoal(0, new EntityFollowGoal(player));
npc.setMovementCollideOption(collideOption);
tickRunner.addEntity(npc);
});*/
});
}
Aggregations