Skip to content

Commit 2fb93d9

Browse files
committed
update minestom
1 parent a000cd9 commit 2fb93d9

3 files changed

Lines changed: 22 additions & 32 deletions

File tree

build.gradle.kts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ publishing {
3030
publications.create<MavenPublication>("maven") {
3131
groupId = "net.worldseed.particleemitter"
3232
artifactId = "ParticleEmitter"
33-
version = "1.3.32"
33+
version = "1.3.35"
3434

3535
from(components["java"])
3636
}
@@ -50,9 +50,11 @@ publishing {
5050
dependencies {
5151
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
5252
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
53-
compileOnly("com.github.Minestom:Minestom:8ad2c7701f")
54-
testImplementation("com.github.Minestom:Minestom:8ad2c7701f")
55-
implementation("com.github.hollow-cube.common:mql:117d7c64b1")
53+
54+
compileOnly("net.minestom:minestom-snapshots:5162a00b1e")
55+
testImplementation("net.minestom:minestom-snapshots:5162a00b1e")
56+
57+
implementation("com.github.hollow-cube.common:mql:2b48ad430f")
5658
}
5759

5860
tasks.getByName<Test>("test") {

src/main/java/net/worldseed/particleemitter/generator/ParticleGenerator.java

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package net.worldseed.particleemitter.generator;
22

3+
import net.minestom.server.color.Color;
34
import net.minestom.server.coordinate.Vec;
45
import net.minestom.server.network.packet.server.play.ParticlePacket;
56
import net.minestom.server.particle.Particle;
6-
import net.minestom.server.utils.binary.BinaryWriter;
7+
import net.minestom.server.particle.data.DustColorTransitionParticleData;
8+
import net.minestom.server.particle.data.DustParticleData;
79

810
import java.util.Map;
911

@@ -27,44 +29,33 @@ else if (particleType == Particle.FLAME
2729
}
2830

2931
private static ParticlePacket buildDustTransition(double x, double y, double z, double size, double r, double g, double b, double r2, double g2, double b2) {
30-
BinaryWriter writer = new BinaryWriter();
31-
writer.writeFloat((float) r);
32-
writer.writeFloat((float) g);
33-
writer.writeFloat((float) b);
34-
writer.writeFloat((float) size);
35-
writer.writeFloat((float) r2);
36-
writer.writeFloat((float) g2);
37-
writer.writeFloat((float) b2);
38-
return new ParticlePacket(Particle.DUST_COLOR_TRANSITION.id(), true, x, y, z, 0, 0, 0, 0, 0, writer.toByteArray());
32+
DustColorTransitionParticleData data = new DustColorTransitionParticleData(new Color((int) (r * 255), (int) (g * 255), (int) (b * 255)), (float) size, new Color((int) (r2 * 255), (int) (g2 * 255), (int) (b2 * 255)));
33+
return new ParticlePacket(Particle.DUST_COLOR_TRANSITION.id(), true, x, y, z, 0, 0, 0, 0, 0, data);
3934
}
4035

4136
private static ParticlePacket buildGeneric(Particle p, double x, double y, double z) {
42-
return new ParticlePacket(p.id(), true, x, y, z, 0, 0, 0, 0, 0, new byte[0]);
37+
return new ParticlePacket(p, true, x, y, z, 0, 0, 0, 0, 0);
4338
}
4439

4540
private static ParticlePacket buildDirectional(Particle p, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
4641
Vec vec = new Vec(velocityX, velocityY, velocityZ);
4742
double size = vec.length();
4843
vec = vec.normalize();
4944

50-
return new ParticlePacket(p.id(), true, x, y, z, (float) vec.x(), (float) vec.y(), (float) vec.z(), (float) size, 0, new byte[0]);
45+
return new ParticlePacket(p.id(), true, x, y, z, (float) vec.x(), (float) vec.y(), (float) vec.z(), (float) size, 0, p.data());
5146
}
5247

5348
private static ParticlePacket buildDust(double x, double y, double z, double size, double r, double g, double b) {
54-
BinaryWriter writer = new BinaryWriter();
55-
writer.writeFloat((float) r);
56-
writer.writeFloat((float) g);
57-
writer.writeFloat((float) b);
58-
writer.writeFloat((float) size);
59-
return new ParticlePacket(Particle.DUST.id(), true, x, y, z, 0, 0, 0, 0, 0, writer.toByteArray());
49+
DustParticleData data = new DustParticleData(new Color((int) (r * 255), (int) (g * 255), (int) (b * 255)), (float) size);
50+
return new ParticlePacket(Particle.DUST.id(), true, x, y, z, 0, 0, 0, 0, 0, data);
6051
}
6152

6253
private static ParticlePacket buildEffect(double x, double y, double z, double r, double g, double b) {
63-
return new ParticlePacket(Particle.ENTITY_EFFECT.id(), true, x, y, z, (float) r, (float) g, (float) b, 1, 0, new byte[0]);
54+
return new ParticlePacket(Particle.ENTITY_EFFECT.id(), true, x, y, z, (float) r, (float) g, (float) b, 1, 0, Particle.ENTITY_EFFECT.data());
6455
}
6556

6657
private static ParticlePacket buildEffectAmbient(double x, double y, double z, double r, double g, double b) {
67-
return new ParticlePacket(Particle.AMBIENT_ENTITY_EFFECT.id(), true, x, y, z, (float) r, (float) g, (float) b, 1, 0, new byte[0]);
58+
return new ParticlePacket(Particle.AMBIENT_ENTITY_EFFECT.id(), true, x, y, z, (float) r, (float) g, (float) b, 1, 0, Particle.AMBIENT_ENTITY_EFFECT.data());
6859
}
6960

7061
private static final Map<Vec, Double> noteColours = Map.ofEntries(
@@ -88,6 +79,6 @@ private static double calculateMinDiff(double r, double g, double b) {
8879
}
8980

9081
private static ParticlePacket buildNote(double x, double y, double z, double r, double g, double b) {
91-
return new ParticlePacket(Particle.NOTE.id(), true, x, y, z, (float) (calculateMinDiff(r, g, b)), 0, 0, 1, 0, new byte[0]);
82+
return new ParticlePacket(Particle.NOTE.id(), true, x, y, z, (float) (calculateMinDiff(r, g, b)), 0, 0, 1, 0, Particle.NOTE.data());
9283
}
9384
}

src/test/java/Demo.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import com.google.gson.GsonBuilder;
33
import com.google.gson.JsonObject;
44
import com.google.gson.stream.JsonReader;
5+
import net.minestom.server.event.player.AsyncPlayerConfigurationEvent;
6+
import net.minestom.server.instance.LightingChunk;
57
import net.minestom.server.particle.Particle;
68
import net.worldseed.particleemitter.emitters.EmitterLifetime;
79
import net.minestom.server.MinecraftServer;
@@ -10,7 +12,6 @@
1012
import net.minestom.server.entity.GameMode;
1113
import net.minestom.server.entity.Player;
1214
import net.minestom.server.event.GlobalEventHandler;
13-
import net.minestom.server.event.player.PlayerLoginEvent;
1415
import net.minestom.server.instance.InstanceContainer;
1516
import net.minestom.server.instance.InstanceManager;
1617
import net.minestom.server.instance.block.Block;
@@ -36,6 +37,7 @@ public static void main(String[] args) throws FileNotFoundException, Unsupported
3637
InstanceManager instanceManager = MinecraftServer.getInstanceManager();
3738
InstanceContainer instanceContainer = instanceManager.createInstanceContainer();
3839
instanceContainer.setGenerator(unit -> unit.modifier().fillHeight(0, 40, Block.STONE));
40+
instanceContainer.setChunkSupplier(LightingChunk::new);
3941

4042
File file = new File("./src/test/resources/particles/rgb.particle.json");
4143
FileInputStream fis = new FileInputStream(file);
@@ -51,7 +53,7 @@ public static void main(String[] args) throws FileNotFoundException, Unsupported
5153

5254
// Add an event callback to specify the spawning instance (and the spawn position)
5355
GlobalEventHandler globalEventHandler = MinecraftServer.getGlobalEventHandler();
54-
globalEventHandler.addListener(PlayerLoginEvent.class, event -> {
56+
globalEventHandler.addListener(AsyncPlayerConfigurationEvent.class, event -> {
5557
final Player player = event.getPlayer();
5658
player.setPermissionLevel(2);
5759
player.setGameMode(GameMode.CREATIVE);
@@ -63,11 +65,6 @@ public static void main(String[] args) throws FileNotFoundException, Unsupported
6365
}
6466
});
6567

66-
// globalEventHandler.addListener(PlayerMoveEvent.class, event -> {
67-
// emitter.setRotation(-event.getPlayer().getPosition().yaw());
68-
// emitter.setPosition(event.getPlayer().getPosition().add(0, 1.1, 0));
69-
// });
70-
7168
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
7269
try {
7370
for (var emitter : emitters) {

0 commit comments

Comments
 (0)