Search in sources :

Example 11 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class C2SMessageSelectCraft method send.

public static void send(int index) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeInt(index);
    ClientPlayNetworking.send(PacketHandler.lock_slot, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 12 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class EntityPacket method createPacket.

public static Packet<?> createPacket(Entity entity) {
    PacketByteBuf buf = createBuffer();
    buf.writeVarInt(Registry.ENTITY_TYPE.getRawId(entity.getType()));
    buf.writeUuid(entity.getUuid());
    buf.writeVarInt(entity.getId());
    buf.writeDouble(entity.getX());
    buf.writeDouble(entity.getY());
    buf.writeDouble(entity.getZ());
    buf.writeByte(MathHelper.floor(entity.getPitch() * 256.0F / 360.0F));
    buf.writeByte(MathHelper.floor(entity.getYaw() * 256.0F / 360.0F));
    buf.writeFloat(entity.getPitch());
    buf.writeFloat(entity.getYaw());
    return ServerPlayNetworking.createS2CPacket(ID, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 13 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MCDoom by AzureDoom.

the class AxeMarauderItem 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 AxeMarauderItem && ClientInit.reload.isPressed() && selected) {
            PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
            passedData.writeBoolean(true);
            ClientPlayNetworking.send(DoomMod.MARAUDERAXE, passedData);
        }
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 14 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Polymorph by TheIllusiveC4.

the class PolymorphPacketDistributorImpl method sendStackRecipeSelectionC2S.

@Override
public void sendStackRecipeSelectionC2S(Identifier pIdentifier) {
    PacketByteBuf buf = PacketByteBufs.create();
    buf.writeIdentifier(pIdentifier);
    ClientPlayNetworking.send(PolymorphPackets.STACK_SELECT, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 15 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Polymorph by TheIllusiveC4.

the class PolymorphPacketDistributorImpl method sendPlayerSyncS2C.

@Override
public void sendPlayerSyncS2C(ServerPlayerEntity pPlayer, SortedSet<RecipePair> pRecipesList, Identifier pSelected) {
    PacketByteBuf buf = PacketByteBufs.create();
    if (!pRecipesList.isEmpty()) {
        buf.writeInt(pRecipesList.size());
        for (RecipePair data : pRecipesList) {
            buf.writeIdentifier(data.getIdentifier());
            buf.writeItemStack(data.getOutput());
        }
        if (pSelected != null) {
            buf.writeIdentifier(pSelected);
        }
    }
    ServerPlayNetworking.send(pPlayer, PolymorphPackets.RECIPE_SYNC, buf);
}
Also used : RecipePair(top.theillusivec4.polymorph.api.common.base.RecipePair) PacketByteBuf(net.minecraft.network.PacketByteBuf)

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