Skip to content

Commit a713727

Browse files
25w33a
1 parent 8b70285 commit a713727

File tree

4 files changed

+90
-2
lines changed

4 files changed

+90
-2
lines changed

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/codec/MinecraftCodec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@
224224

225225
public class MinecraftCodec {
226226
public static final PacketCodec CODEC = PacketCodec.builder()
227-
.protocolVersion((1 << 30) | 260)
228-
.minecraftVersion("25w32a")
227+
.protocolVersion((1 << 30) | 262)
228+
.minecraftVersion("25w33a")
229229
.state(ProtocolState.HANDSHAKE, MinecraftPacketRegistry.builder()
230230
.registerServerboundPacket(ClientIntentionPacket.class, ClientIntentionPacket::new)
231231
)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.geysermc.mcprotocollib.protocol.data.game;
2+
3+
import io.netty.buffer.ByteBuf;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import org.checkerframework.checker.index.qual.NonNegative;
7+
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
8+
9+
import java.util.List;
10+
import java.util.function.BiConsumer;
11+
import java.util.function.Function;
12+
13+
@Data
14+
@AllArgsConstructor
15+
public class WeightedList<T> {
16+
private final List<Entry<T>> entries;
17+
18+
public WeightedList(ByteBuf in, Function<ByteBuf, T> reader) {
19+
entries = MinecraftTypes.readList(in, input -> new Entry<>(input, reader));
20+
}
21+
22+
public void write(ByteBuf out, BiConsumer<T, ByteBuf> writer) {
23+
MinecraftTypes.writeList(out, entries, (output, entry) -> entry.write(out, writer));
24+
}
25+
26+
public WeightedList<T> with(T value, @NonNegative int weight) {
27+
add(value, weight);
28+
return this;
29+
}
30+
31+
public void add(T value, @NonNegative int weight) {
32+
add(new Entry<>(value, weight));
33+
}
34+
35+
public void add(Entry<T> entry) {
36+
entries.add(entry);
37+
}
38+
39+
public Entry<T> get(int index) {
40+
return entries.get(index);
41+
}
42+
43+
public boolean contains(T value) {
44+
for (Entry<T> entry : entries) {
45+
if (entry.value.equals(value)) {
46+
return true;
47+
}
48+
}
49+
return false;
50+
}
51+
52+
public record Entry<T>(T value, @NonNegative int weight) {
53+
54+
public Entry(ByteBuf in, Function<ByteBuf, T> reader) {
55+
this(reader.apply(in), MinecraftTypes.readVarInt(in));
56+
}
57+
58+
public void write(ByteBuf out, BiConsumer<T, ByteBuf> writer) {
59+
writer.accept(value, out);
60+
MinecraftTypes.writeVarInt(out, weight);
61+
}
62+
}
63+
}

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/data/game/level/sound/BuiltinSound.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ public enum BuiltinSound implements Sound {
394394
BLOCK_COPPER_GOLEM_STATUE_STEP("block.copper_golem_statue.step"),
395395
BLOCK_COPPER_GOLEM_STATUE_FALL("block.copper_golem_statue.fall"),
396396
ENTITY_COPPER_GOLEM_SPAWN("entity.copper_golem.spawn"),
397+
ENTITY_COPPER_GOLEM_SHEAR("entity.copper_golem.shear"),
397398
BLOCK_COPPER_GRATE_BREAK("block.copper_grate.break"),
398399
BLOCK_COPPER_GRATE_STEP("block.copper_grate.step"),
399400
BLOCK_COPPER_GRATE_PLACE("block.copper_grate.place"),
@@ -1645,6 +1646,7 @@ public enum BuiltinSound implements Sound {
16451646
BLOCK_HANGING_SIGN_WAXED_INTERACT_FAIL("block.hanging_sign.waxed_interact_fail"),
16461647
BLOCK_SIGN_WAXED_INTERACT_FAIL("block.sign.waxed_interact_fail"),
16471648
BLOCK_WATER_AMBIENT("block.water.ambient"),
1649+
WEATHER_END_FLASH("weather.end_flash"),
16481650
WEATHER_RAIN("weather.rain"),
16491651
WEATHER_RAIN_ABOVE("weather.rain.above"),
16501652
BLOCK_WET_GRASS_BREAK("block.wet_grass.break"),

protocol/src/main/java/org/geysermc/mcprotocollib/protocol/packet/ingame/clientbound/level/ClientboundExplodePacket.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.cloudburstmc.math.vector.Vector3d;
99
import org.geysermc.mcprotocollib.protocol.codec.MinecraftPacket;
1010
import org.geysermc.mcprotocollib.protocol.codec.MinecraftTypes;
11+
import org.geysermc.mcprotocollib.protocol.data.game.WeightedList;
1112
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.Particle;
1213
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.BuiltinSound;
1314
import org.geysermc.mcprotocollib.protocol.data.game.level.sound.CustomSound;
@@ -19,22 +20,30 @@
1920
@AllArgsConstructor
2021
public class ClientboundExplodePacket implements MinecraftPacket {
2122
private final Vector3d center;
23+
private final float radius;
24+
private final int blockCount;
2225
private final @Nullable Vector3d playerKnockback;
2326
private final @NonNull Particle explosionParticle;
2427
private final @NonNull Sound explosionSound;
28+
private final @NonNull WeightedList<BlockParticleInfo> blockParticles;
2529

2630
public ClientboundExplodePacket(ByteBuf in) {
2731
this.center = Vector3d.from(in.readDouble(), in.readDouble(), in.readDouble());
32+
this.radius = in.readFloat();
33+
this.blockCount = in.readInt();
2834
this.playerKnockback = MinecraftTypes.readNullable(in, (input) -> Vector3d.from(input.readDouble(), input.readDouble(), input.readDouble()));
2935
this.explosionParticle = MinecraftTypes.readParticle(in);
3036
this.explosionSound = MinecraftTypes.readById(in, BuiltinSound::from, MinecraftTypes::readSoundEvent);
37+
this.blockParticles = new WeightedList<>(in, BlockParticleInfo::new);
3138
}
3239

3340
@Override
3441
public void serialize(ByteBuf out) {
3542
out.writeDouble(this.center.getX());
3643
out.writeDouble(this.center.getY());
3744
out.writeDouble(this.center.getZ());
45+
out.writeFloat(radius);
46+
out.writeInt(blockCount);
3847
MinecraftTypes.writeNullable(out, this.playerKnockback, (output, playerKnockback) -> {
3948
output.writeDouble(playerKnockback.getX());
4049
output.writeDouble(playerKnockback.getY());
@@ -47,10 +56,24 @@ public void serialize(ByteBuf out) {
4756
} else {
4857
MinecraftTypes.writeVarInt(out, ((BuiltinSound) this.explosionSound).ordinal() + 1);
4958
}
59+
blockParticles.write(out, BlockParticleInfo::write);
5060
}
5161

5262
@Override
5363
public boolean shouldRunOnGameThread() {
5464
return true;
5565
}
66+
67+
public record BlockParticleInfo(Particle particle, float scaling, float speed) {
68+
69+
public BlockParticleInfo(ByteBuf in) {
70+
this(MinecraftTypes.readParticle(in), in.readFloat(), in.readFloat());
71+
}
72+
73+
public void write(ByteBuf out) {
74+
MinecraftTypes.writeParticle(out, particle);
75+
out.writeFloat(scaling);
76+
out.writeFloat(speed);
77+
}
78+
}
5679
}

0 commit comments

Comments
 (0)