| 1 | package net.minecraft.network.protocol.game;
|
| 2 |
|
| 3 | import java.util.Optional;
|
| 4 | import net.minecraft.core.Holder;
|
| 5 | import net.minecraft.core.particles.ExplosionParticleInfo;
|
| 6 | import net.minecraft.core.particles.ParticleOptions;
|
| 7 | import net.minecraft.core.particles.ParticleTypes;
|
| 8 | import net.minecraft.network.RegistryFriendlyByteBuf;
|
| 9 | import net.minecraft.network.codec.ByteBufCodecs;
|
| 10 | import net.minecraft.network.codec.StreamCodec;
|
| 11 | import net.minecraft.network.protocol.Packet;
|
| 12 | import net.minecraft.network.protocol.PacketType;
|
| 13 | import net.minecraft.sounds.SoundEvent;
|
| 14 | import net.minecraft.util.random.WeightedList;
|
| 15 | import net.minecraft.world.phys.Vec3;
|
| 16 |
|
| 17 | public record ClientboundExplodePacket(
|
| 18 | Vec3 center,
|
| 19 | float radius,
|
| 20 | int blockCount,
|
| 21 | Optional<Vec3> playerKnockback,
|
| 22 | ParticleOptions explosionParticle,
|
| 23 | Holder<SoundEvent> explosionSound,
|
| 24 | WeightedList<ExplosionParticleInfo> blockParticles,
|
| 25 | boolean playSound
|
| 26 | ) implements Packet<ClientGamePacketListener> {
|
| 27 | public static final StreamCodec<RegistryFriendlyByteBuf, ClientboundExplodePacket> STREAM_CODEC = StreamCodec.composite(
|
| 28 | Vec3.STREAM_CODEC,
|
| 29 | ClientboundExplodePacket::center,
|
| 30 | ByteBufCodecs.FLOAT,
|
| 31 | ClientboundExplodePacket::radius,
|
| 32 | ByteBufCodecs.INT,
|
| 33 | ClientboundExplodePacket::blockCount,
|
| 34 | Vec3.STREAM_CODEC.apply(ByteBufCodecs::optional),
|
| 35 | ClientboundExplodePacket::playerKnockback,
|
| 36 | ParticleTypes.STREAM_CODEC,
|
| 37 | ClientboundExplodePacket::explosionParticle,
|
| 38 | SoundEvent.STREAM_CODEC,
|
| 39 | ClientboundExplodePacket::explosionSound,
|
| 40 | WeightedList.streamCodec(ExplosionParticleInfo.STREAM_CODEC),
|
| 41 | ClientboundExplodePacket::blockParticles,
|
| 42 | ByteBufCodecs.BOOL,
|
| 43 | ClientboundExplodePacket::playSound,
|
| 44 | ClientboundExplodePacket::new
|
| 45 | );
|
| 46 |
|
| 47 | @Override
|
| 48 | public PacketType<ClientboundExplodePacket> type() {
|
| 49 | return GamePacketTypes.CLIENTBOUND_EXPLODE;
|
| 50 | }
|
| 51 |
|
| 52 | public void handle(final ClientGamePacketListener listener) {
|
| 53 | listener.handleExplosion(this);
|
| 54 | }
|
| 55 | }
|
| 56 |
|