use of net.minecraft.network.PacketByteBuf in project LuckPerms by lucko.
the class PluginMessageMessenger method sendOutgoingMessage.
@Override
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
AtomicReference<SchedulerTask> taskRef = new AtomicReference<>();
SchedulerTask task = this.plugin.getBootstrap().getScheduler().asyncRepeating(() -> {
MinecraftServer server = this.plugin.getBootstrap().getServer().orElse(null);
if (server == null) {
return;
}
Collection<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
ServerPlayerEntity p = Iterables.getFirst(players, null);
if (p == null) {
return;
}
PacketByteBuf buf = PacketByteBufs.create();
buf.writeString(outgoingMessage.asEncodedString());
ServerPlayNetworking.send(p, CHANNEL, buf);
SchedulerTask t = taskRef.getAndSet(null);
if (t != null) {
t.cancel();
}
}, 10, TimeUnit.SECONDS);
taskRef.set(task);
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class SwordCrucibleItem method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
PlayerEntity playerentity = (PlayerEntity) entity;
if (world.isClient) {
if (playerentity.getMainHandStack().getItem() instanceof SwordCrucibleItem && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.CRUCIBLE, passedData);
}
}
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class DShotgun method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (world.isClient) {
if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof DShotgun && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.DSG, passedData);
}
}
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class DarkLordCrucibleItem method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
PlayerEntity playerentity = (PlayerEntity) entity;
if (world.isClient) {
if (playerentity.getMainHandStack().getItem() instanceof DarkLordCrucibleItem && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.DARKLORDCRUCIBLE, passedData);
}
}
}
use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.
the class PistolItem method inventoryTick.
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
if (world.isClient) {
if (((PlayerEntity) entity).getMainHandStack().getItem() instanceof PistolItem && ClientInit.reload.isPressed() && selected) {
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
passedData.writeBoolean(true);
ClientPlayNetworking.send(DoomMod.PISTOL, passedData);
}
}
}
Aggregations