Search in sources :

Example 1 with PacketByteBuf

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);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) AtomicReference(java.util.concurrent.atomic.AtomicReference) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SchedulerTask(me.lucko.luckperms.common.plugin.scheduler.SchedulerTask) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 2 with PacketByteBuf

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);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 3 with PacketByteBuf

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);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 4 with PacketByteBuf

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);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 5 with PacketByteBuf

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);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

PacketByteBuf (net.minecraft.network.PacketByteBuf)117 PlayerEntity (net.minecraft.entity.player.PlayerEntity)21 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)14 Identifier (net.minecraft.util.Identifier)8 NbtCompound (net.minecraft.nbt.NbtCompound)7 Environment (net.fabricmc.api.Environment)5 CustomPayloadC2SPacket (net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)5 CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)4 Nullable (org.jetbrains.annotations.Nullable)4 Inject (org.spongepowered.asm.mixin.injection.Inject)4 ArrayList (java.util.ArrayList)3 UUID (java.util.UUID)3 JSONSource (de.modprog.blockmeter.util.JSONSource)2 Map (java.util.Map)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2 LivingEntity (net.minecraft.entity.LivingEntity)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 ListTag (net.minecraft.nbt.ListTag)2 ParticleType (net.minecraft.particle.ParticleType)2 LiteralText (net.minecraft.text.LiteralText)2