Search in sources :

Example 61 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Biome-Makeover by Lemonszz.

the class NetworkUtil method doLightningSplash.

public static void doLightningSplash(World world, boolean doBottle, BlockPos pos) {
    if (world.isClient)
        return;
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeBoolean(doBottle);
    buf.writeBlockPos(pos);
    serverSendTracking(world, pos, BMNetwork.SPAWN_LIGHTNING_BOTTLE_PARTICLES, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 62 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LevelZ by Globox1997.

the class PlayerStatsClientPacket method writeC2SIncreaseLevelPacket.

public static void writeC2SIncreaseLevelPacket(PlayerStatsManager playerStatsManager, String string) {
    playerStatsManager.setLevel(string, playerStatsManager.getLevel(string) + 1);
    playerStatsManager.setLevel("points", playerStatsManager.getLevel("points") - 1);
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeString(string);
    buf.writeInt(playerStatsManager.getLevel(string));
    CustomPayloadC2SPacket packet = new CustomPayloadC2SPacket(PlayerStatsServerPacket.STATS_INCREASE_PACKET, buf);
    MinecraftClient.getInstance().getNetworkHandler().sendPacket(packet);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) CustomPayloadC2SPacket(net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)

Example 63 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LevelZ by Globox1997.

the class PlayerStatsServerPacket method writeS2CXPPacket.

public static void writeS2CXPPacket(PlayerStatsManager playerStatsManager, ServerPlayerEntity serverPlayerEntity) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeFloat(playerStatsManager.levelProgress);
    buf.writeInt(playerStatsManager.totalLevelExperience);
    buf.writeInt(playerStatsManager.getLevel("level"));
    CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(XP_PACKET, buf);
    serverPlayerEntity.networkHandler.sendPacket(packet);
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 64 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LevelZ by Globox1997.

the class PlayerStatsServerPacket method writeS2CListPacket.

public static void writeS2CListPacket(ServerPlayerEntity serverPlayerEntity) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    for (int i = 0; i < LevelLists.getListNames().size(); i++) {
        String listName = LevelLists.getListNames().get(i);
        ArrayList<Object> list = LevelLists.getList(listName);
        for (int u = 0; u < list.size(); u++) {
            buf.writeString(list.get(u).toString());
        }
    }
    for (int k = 0; k < LevelLists.miningLevelList.size(); k++) {
        buf.writeString("mining:level");
        buf.writeString(LevelLists.miningLevelList.get(k).toString());
        for (int u = 0; u < LevelLists.miningBlockList.get(k).size(); u++) {
            buf.writeString(LevelLists.miningBlockList.get(k).get(u).toString());
        }
    }
    for (int k = 0; k < LevelLists.brewingLevelList.size(); k++) {
        buf.writeString("brewing:level");
        buf.writeString(LevelLists.brewingLevelList.get(k).toString());
        for (int u = 0; u < LevelLists.brewingItemList.get(k).size(); u++) {
            buf.writeString(LevelLists.brewingItemList.get(k).get(u).toString());
        }
    }
    CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(LIST_PACKET, buf);
    serverPlayerEntity.networkHandler.sendPacket(packet);
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 65 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LevelZ by Globox1997.

the class PlayerStatsServerPacket method writeS2CStrengthPacket.

public static void writeS2CStrengthPacket(ServerPlayerEntity serverPlayerEntity) {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeDouble(serverPlayerEntity.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE).getBaseValue());
    CustomPayloadS2CPacket packet = new CustomPayloadS2CPacket(STRENGTH_PACKET, buf);
    serverPlayerEntity.networkHandler.sendPacket(packet);
}
Also used : CustomPayloadS2CPacket(net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf)

Aggregations

PacketByteBuf (net.minecraft.network.PacketByteBuf)158 PlayerEntity (net.minecraft.entity.player.PlayerEntity)40 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)18 Identifier (net.minecraft.util.Identifier)12 CustomPayloadS2CPacket (net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket)9 NbtCompound (net.minecraft.nbt.NbtCompound)7 CustomPayloadC2SPacket (net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket)7 Inject (org.spongepowered.asm.mixin.injection.Inject)6 Environment (net.fabricmc.api.Environment)5 UUID (java.util.UUID)4 LivingEntity (net.minecraft.entity.LivingEntity)4 Nullable (org.jetbrains.annotations.Nullable)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 LiteralText (net.minecraft.text.LiteralText)3 GenderPlayer (com.wildfire.main.GenderPlayer)2 JSONSource (de.modprog.blockmeter.util.JSONSource)2 IHungerManager (de.siphalor.spiceoffabric.util.IHungerManager)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ServerPlayNetworking (net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking)2