Skip to content

Commit e59c8bc

Browse files
committed
update
1 parent 2fb93d9 commit e59c8bc

8 files changed

Lines changed: 90 additions & 67 deletions

File tree

build.gradle.kts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ sourceSets {
1414

1515
repositories {
1616
mavenCentral()
17-
maven("https://jitpack.io")
1817
}
1918

2019
description = "Particle Effects for WorldSeed"
21-
java.sourceCompatibility = JavaVersion.VERSION_17
20+
java.sourceCompatibility = JavaVersion.VERSION_21
2221

2322
tasks.jar {
2423
manifest {
@@ -51,10 +50,10 @@ dependencies {
5150
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
5251
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
5352

54-
compileOnly("net.minestom:minestom-snapshots:5162a00b1e")
55-
testImplementation("net.minestom:minestom-snapshots:5162a00b1e")
53+
compileOnly("net.minestom:minestom-snapshots:f1d5940855")
54+
testImplementation("net.minestom:minestom-snapshots:f1d5940855")
5655

57-
implementation("com.github.hollow-cube.common:mql:2b48ad430f")
56+
implementation("dev.hollowcube:mql:1.0.1")
5857
}
5958

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

gradle/wrapper/gradle-wrapper.jar

-16 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

Lines changed: 28 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import net.minestom.server.coordinate.Vec;
55
import net.minestom.server.network.packet.server.play.ParticlePacket;
66
import net.minestom.server.particle.Particle;
7-
import net.minestom.server.particle.data.DustColorTransitionParticleData;
8-
import net.minestom.server.particle.data.DustParticleData;
97

108
import java.util.Map;
119

@@ -19,7 +17,6 @@ public static ParticlePacket buildParticle(Particle particleType, double x, doub
1917
else if (particleType == Particle.DUST_COLOR_TRANSITION) return buildDustTransition(x, y, z, size, r, g, b, r2, g2, b2);
2018
else if (particleType == Particle.NOTE) return buildNote(x, y, z, r, g, b);
2119
else if (particleType == Particle.ENTITY_EFFECT) return buildEffect(x, y, z, r, g, b);
22-
else if (particleType == Particle.AMBIENT_ENTITY_EFFECT) return buildEffectAmbient(x, y, z, r, g, b);
2320
else if (particleType == Particle.FLAME
2421
|| particleType == Particle.SMOKE
2522
|| particleType == Particle.FIREWORK
@@ -29,8 +26,8 @@ else if (particleType == Particle.FLAME
2926
}
3027

3128
private static ParticlePacket buildDustTransition(double x, double y, double z, double size, double r, double g, double b, double r2, double g2, double b2) {
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);
29+
Particle.DustColorTransition data = Particle.DUST_COLOR_TRANSITION.withProperties(new Color((int) (r * 255), (int) (g * 255), (int) (b * 255)), (float) size, new Color((int) (r2 * 255), (int) (g2 * 255), (int) (b2 * 255))) ;
30+
return new ParticlePacket(data, true, x, y, z, 0, 0, 0, 0, 0);
3431
}
3532

3633
private static ParticlePacket buildGeneric(Particle p, double x, double y, double z) {
@@ -42,20 +39,16 @@ private static ParticlePacket buildDirectional(Particle p, double x, double y, d
4239
double size = vec.length();
4340
vec = vec.normalize();
4441

45-
return new ParticlePacket(p.id(), true, x, y, z, (float) vec.x(), (float) vec.y(), (float) vec.z(), (float) size, 0, p.data());
42+
return new ParticlePacket(p, true, x, y, z, (float) vec.x(), (float) vec.y(), (float) vec.z(), (float) size, 0);
4643
}
4744

4845
private static ParticlePacket buildDust(double x, double y, double z, double size, double r, double g, double b) {
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);
46+
Particle.Dust data = Particle.DUST.withProperties(new Color((int) (r * 255), (int) (g * 255), (int) (b * 255)), (float) size);
47+
return new ParticlePacket(data, true, x, y, z, 0, 0, 0, 0, 0);
5148
}
5249

5350
private static ParticlePacket buildEffect(double x, double y, double z, double r, double g, double b) {
54-
return new ParticlePacket(Particle.ENTITY_EFFECT.id(), true, x, y, z, (float) r, (float) g, (float) b, 1, 0, Particle.ENTITY_EFFECT.data());
55-
}
56-
57-
private static ParticlePacket buildEffectAmbient(double x, double y, double z, double r, double g, double b) {
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());
51+
return new ParticlePacket(Particle.ENTITY_EFFECT, true, x, y, z, (float) r, (float) g, (float) b, 1, 0);
5952
}
6053

6154
private static final Map<Vec, Double> noteColours = Map.ofEntries(
@@ -79,6 +72,6 @@ private static double calculateMinDiff(double r, double g, double b) {
7972
}
8073

8174
private static ParticlePacket buildNote(double x, double y, double z, double r, double g, double b) {
82-
return new ParticlePacket(Particle.NOTE.id(), true, x, y, z, (float) (calculateMinDiff(r, g, b)), 0, 0, 1, 0, Particle.NOTE.data());
75+
return new ParticlePacket(Particle.NOTE, true, x, y, z, (float) (calculateMinDiff(r, g, b)), 0, 0, 1, 0);
8376
}
8477
}

src/test/java/Demo.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
import java.io.*;
2525
import java.lang.reflect.InvocationTargetException;
26-
import java.util.ArrayList;
27-
import java.util.Collection;
28-
import java.util.List;
26+
import java.util.*;
2927

3028
public class Demo {
3129
static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
@@ -65,24 +63,26 @@ public static void main(String[] args) throws FileNotFoundException, Unsupported
6563
}
6664
});
6765

68-
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
69-
try {
70-
for (var emitter : emitters) {
71-
Collection<ParticlePacket> packets = emitter.tick();
66+
new Timer().schedule(new TimerTask() {
67+
public void run() {
68+
try {
69+
for (var emitter : emitters) {
70+
Collection<ParticlePacket> packets = emitter.tick();
7271

73-
if (emitter.status() != EmitterLifetime.LifetimeState.DEAD) {
74-
packets.forEach(packet -> {
75-
instanceContainer.getPlayers().forEach(p -> p.sendPackets(packet));
76-
});
77-
} else {
78-
emitter.reset();
72+
if (emitter.status() != EmitterLifetime.LifetimeState.DEAD) {
73+
packets.forEach(packet -> {
74+
instanceContainer.getPlayers().forEach(p -> p.sendPackets(packet));
75+
});
76+
} else {
77+
emitter.reset();
78+
}
7979
}
80+
} catch (InvocationTargetException | NoSuchMethodException | InstantiationException |
81+
IllegalAccessException e) {
82+
throw new RuntimeException(e);
8083
}
81-
} catch (InvocationTargetException | NoSuchMethodException | InstantiationException |
82-
IllegalAccessException e) {
83-
throw new RuntimeException(e);
8484
}
85-
}, TaskSchedule.immediate(), TaskSchedule.millis(1), ExecutionType.ASYNC);
85+
}, 1, 1);
8686

8787
// Start the server on port 25565
8888
minecraftServer.start("0.0.0.0", 25565);

src/test/resources/particles/disc.particle.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"format_version": "1.10.0",
33
"particle_effect": {
44
"description": {
5-
"identifier": "snowstorm:loading",
5+
"identifier": "snowstorm:magic",
66
"basic_render_parameters": {
77
"material": "particles_alpha",
88
"texture": "textures/particle/particles"
@@ -17,32 +17,43 @@
1717
"spawn_rate": 500,
1818
"max_particles": 1000
1919
},
20-
"minecraft:emitter_lifetime_looping": {
21-
"active_time": 1
20+
"minecraft:emitter_lifetime_expression": {
21+
"activation_expression": 1
2222
},
2323
"minecraft:emitter_shape_disc": {
24-
"radius": 2,
25-
"plane_normal": [1, 1, 0],
24+
"offset": ["math.sin(variable.emitter_age*200)*6", "math.cos(variable.emitter_age*260)*6", 5],
25+
"radius": 1.6,
26+
"plane_normal": ["math.sin(variable.emitter_age*200)*6", 0, 1],
2627
"surface_only": true,
2728
"direction": "outwards"
2829
},
2930
"minecraft:particle_lifetime_expression": {
30-
"max_lifetime": 1
31+
"max_lifetime": "math.random(3, 4)"
32+
},
33+
"minecraft:particle_initial_spin": {
34+
"rotation_rate": "Math.random(-100, 100)"
3135
},
3236
"minecraft:particle_initial_speed": 0,
33-
"minecraft:particle_motion_dynamic": {},
37+
"minecraft:particle_motion_dynamic": {
38+
"linear_acceleration": ["math.random(0, 4)", "math.random(0, 8)", "variable.particle_random_3>0.2 ? -10 : -4"]
39+
},
3440
"minecraft:particle_appearance_billboard": {
35-
"size": ["0.08*(1-variable.particle_age)", "0.08*(1-variable.particle_age)"],
41+
"size": ["0.04+variable.particle_random_2/5", "0.04+variable.particle_random_2/5"],
3642
"facing_camera_mode": "rotate_xyz",
3743
"uv": {
3844
"texture_width": 128,
3945
"texture_height": 128,
40-
"uv": [32, 88],
41-
"uv_size": [8, 8]
46+
"flipbook": {
47+
"base_UV": [64, 96],
48+
"size_UV": [8, 8],
49+
"step_UV": [-8, 0],
50+
"max_frame": 8,
51+
"stretch_to_lifetime": true
52+
}
4253
}
4354
},
4455
"minecraft:particle_appearance_tinting": {
45-
"color": [0.41961, 1, 0.57647, 1]
56+
"color": ["Math.clamp(0.3 + variable.particle_random_4/7 + (variable.particle_random_3>0.2 ? 0.4 : 0), 0, 1)", "Math.clamp(0.2+variable.particle_random_4/5, 0, 1)", "Math.clamp(0.88 + variable.particle_random_4/8, 0, 1)", 1]
4657
}
4758
}
4859
}

0 commit comments

Comments
 (0)