Skip to content

Commit

Permalink
Limit particle amount in LevelParticlesPacket
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ-Ferguson committed Jun 28, 2024
1 parent ca2312c commit 973867d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

@Translator(packet = ClientboundLevelParticlesPacket.class)
public class JavaLevelParticlesTranslator extends PacketTranslator<ClientboundLevelParticlesPacket> {
private static final int MAX_PARTICLES = 100;

@Override
public void translate(GeyserSession session, ClientboundLevelParticlesPacket packet) {
Expand All @@ -71,7 +72,8 @@ public void translate(GeyserSession session, ClientboundLevelParticlesPacket pac
session.sendUpstreamPacket(particleCreateFunction.apply(position));
} else {
Random random = ThreadLocalRandom.current();
for (int i = 0; i < packet.getAmount(); i++) {
int amount = Math.min(MAX_PARTICLES, packet.getAmount());
for (int i = 0; i < amount; i++) {
double offsetX = random.nextGaussian() * (double) packet.getOffsetX();
double offsetY = random.nextGaussian() * (double) packet.getOffsetY();
double offsetZ = random.nextGaussian() * (double) packet.getOffsetZ();
Expand Down Expand Up @@ -213,4 +215,4 @@ private static NbtMap buildVec3PositionTag(Vector3f position) {
.putFloat("z", position.getZ())
.build();
}
}
}

0 comments on commit 973867d

Please sign in to comment.