Search in sources :

Example 86 with PacketByteBuf

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

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

Example 87 with PacketByteBuf

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

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

Example 88 with PacketByteBuf

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

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

Example 89 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project MasaGadget by plusls.

the class BborProtocol method bborInitializeHandler.

private static void bborInitializeHandler(ClientPlayNetworkHandler clientPlayNetworkHandler, PacketByteBuf data) {
    long seed = data.readLong();
    int spawnX = data.readInt();
    int spawnZ = data.readInt();
    BborProtocol.seedCache = seed;
    BborProtocol.spawnPos = new BlockPos(spawnX, 0, spawnZ);
    // 因此无需对是否加载 MiniHUD 进行特判
    if (!BborProtocol.carpetOrServux) {
        BborProtocol.enable = true;
        if (Configs.Minihud.COMPACT_BBOR_PROTOCOL.getBooleanValue()) {
            initMetaData();
        }
        ModInfo.LOGGER.info("init seed: {}", BborProtocol.seedCache);
        if (!ModInfo.isModLoaded(ModInfo.BBOR_MOD_ID)) {
            ModInfo.LOGGER.debug("SUBSCRIBE BBOR.");
            clientPlayNetworkHandler.sendPacket(new CustomPayloadC2SPacket(SUBSCRIBE, new PacketByteBuf(Unpooled.buffer())));
        }
    }
}
Also used : CustomPayloadC2SPacket(net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf) BlockPos(net.minecraft.util.math.BlockPos)

Example 90 with PacketByteBuf

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

the class PolymorphPacketDistributorImpl method sendPersistentRecipeSelectionC2S.

@Override
public void sendPersistentRecipeSelectionC2S(Identifier pIdentifier) {
    PacketByteBuf buf = PacketByteBufs.create();
    buf.writeIdentifier(pIdentifier);
    ClientPlayNetworking.send(PolymorphPackets.PERSISTENT_SELECT, buf);
}
Also used : 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