Search in sources :

Example 51 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Hypnotic-Client by Hypnotic-Development.

the class Criticals method getEntity.

public static Entity getEntity(PlayerInteractEntityC2SPacket packet) {
    PacketByteBuf packetBuf = new PacketByteBuf(Unpooled.buffer());
    packet.write(packetBuf);
    return mc.world.getEntityById(packetBuf.readVarInt());
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 52 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Paradise-Lost by devs-immortal.

the class AetherNonLivingEntity method createSpawnPacket.

@Override
public final Packet<?> createSpawnPacket() {
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    Identifier id = this.createSpawnPacket(buf);
    for (ServerPlayerEntity playerEntity : ((ServerWorld) this.world).getPlayers()) {
        ServerSidePacketRegistry.INSTANCE.sendToPlayer(playerEntity, id, buf);
    }
    return new EntitySpawnS2CPacket(this);
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Identifier(net.minecraft.util.Identifier) EntitySpawnS2CPacket(net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket) PacketByteBuf(net.minecraft.network.PacketByteBuf) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 53 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project Paradise-Lost by devs-immortal.

the class PoisonDartEntity method onHit.

@Override
protected void onHit(LivingEntity entityIn) {
    super.onHit(entityIn);
    if (entityIn instanceof ServerPlayerEntity) {
        // AetherAPI.get((PlayerEntity) entityIn).inflictPoison(500);
        PacketByteBuf byteBuf = new PacketByteBuf(Unpooled.buffer());
        byteBuf.writeInt(500);
        ((ServerPlayerEntity) entityIn).networkHandler.sendPacket(new CustomPayloadC2SPacket(Aether.locate("poison"), byteBuf));
    } else {
        this.victim = entityIn;
        this.poison = new AetherPoisonMovement(this.victim);
        this.poison.inflictPoison(500);
        this.removed = false;
    }
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) CustomPayloadC2SPacket(net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) AetherPoisonMovement(com.aether.entities.util.AetherPoisonMovement)

Example 54 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class LMSoundPacket method sendS2CPacket.

public static void sendS2CPacket(Entity entity, String soundName) {
    PacketByteBuf passedData = createS2CPacket(entity, soundName);
    PlayerLookup.tracking(entity).forEach(watchingPlayer -> ServerPlayNetworking.send(watchingPlayer, ID, passedData));
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 55 with PacketByteBuf

use of net.minecraft.network.PacketByteBuf in project LittleMaidModelLoader-Fabric by SistrScarlet.

the class SyncMultiModelPacket method sendS2CPacket.

public static void sendS2CPacket(Entity entity, IHasMultiModel hasMultiModel) {
    PacketByteBuf passedData = createS2CPacket(entity, hasMultiModel);
    PlayerLookup.tracking(entity).forEach(watchingPlayer -> ServerPlayNetworking.send(watchingPlayer, ID, passedData));
}
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