Search in sources :

Example 96 with PacketByteBuf

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

the class DirectionalDataScreen method done.

private void done() {
    PacketByteBuf buf = PacketByteBufs.create();
    buf.writeBlockPos(block.getPos());
    buf.writeString(inputMetadata.getText());
    ClientPlayNetworking.send(BMNetwork.CL_UPDATE_DIR_DATA, buf);
    this.client.openScreen(null);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 97 with PacketByteBuf

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

the class RootlingEntity method interactMob.

@Override
public ActionResult interactMob(PlayerEntity player, Hand hand) {
    ItemStack itemStack = player.getStackInHand(hand);
    if (itemStack.getItem() == Items.SHEARS) {
        if (!this.world.isClient && this.isShearable()) {
            this.sheared(SoundCategory.PLAYERS);
            itemStack.damage(1, player, (p) -> p.sendToolBreakStatus(hand));
            return ActionResult.SUCCESS;
        } else {
            return ActionResult.CONSUME;
        }
    } else if (itemStack.getItem() == Items.BONE_MEAL) {
        if (!hasFlower()) {
            if (world.isClient()) {
                return ActionResult.CONSUME;
            } else {
                PacketByteBuf buf = PacketByteBufs.create();
                buf.writeDouble(getX());
                buf.writeDouble(getY());
                buf.writeDouble(getZ());
                NetworkUtil.serverSendTracking(world, getBlockPos(), BMNetwork.SPAWN_BONEMEAL_ENTITY_PARTICLES, buf);
                if (random.nextInt(3) == 0) {
                    setFlowered(true);
                }
                if (!player.isCreative())
                    itemStack.decrement(1);
                return ActionResult.SUCCESS;
            }
        }
    }
    return super.interactMob(player, hand);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ItemStack(net.minecraft.item.ItemStack)

Example 98 with PacketByteBuf

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

the class NetworkUtil method doEnderParticles.

public static void doEnderParticles(World world, Entity entity, int count) {
    if (world.isClient)
        return;
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeInt(entity.getEntityId());
    buf.writeInt(count);
    serverSendTracking(world, entity.getBlockPos(), BMNetwork.SPAWN_ENDER_PARTICLES, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf)

Example 99 with PacketByteBuf

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

the class NetworkUtil method doCenteredEntityParticle.

public static void doCenteredEntityParticle(World world, ParticleEffect effect, Entity e, int count, boolean varyY) {
    if (world.isClient)
        return;
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeInt(e.getEntityId());
    buf.writeInt(Registry.PARTICLE_TYPE.getRawId((ParticleType<?>) effect));
    buf.writeInt(count);
    buf.writeBoolean(varyY);
    buf.writeDouble(world.random.nextGaussian() * 0.02D);
    buf.writeDouble(world.random.nextGaussian() * 0.02D);
    buf.writeDouble(world.random.nextGaussian() * 0.02D);
    serverSendTracking(world, e.getBlockPos(), BMNetwork.ENTITY_PARTICLE_CENTERED, buf);
}
Also used : PacketByteBuf(net.minecraft.network.PacketByteBuf) ParticleType(net.minecraft.particle.ParticleType)

Example 100 with PacketByteBuf

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

the class NetworkUtil method doBlockEnderParticles.

public static void doBlockEnderParticles(World world, BlockPos pos, int count) {
    if (world.isClient)
        return;
    PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
    buf.writeBlockPos(pos);
    buf.writeInt(count);
    serverSendTracking(world, pos, BMNetwork.SPAWN_BLOCK_ENDER_PARTICLES, 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