Skip to content

Commit f2ae807

Browse files
[1.13.0.1]新增Particle模块,用于粒子特效渲染
1 parent fc7afe6 commit f2ae807

File tree

3 files changed

+58
-27
lines changed

3 files changed

+58
-27
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
java.sourceCompatibility = JavaVersion.VERSION_1_8
22
java.targetCompatibility = JavaVersion.VERSION_1_8
33
rootProject.group = "com.crypticlib"
4-
rootProject.version = "1.12.3.5"
4+
rootProject.version = "1.13.0.1"
55
//当全项目重构时更新大版本号,当添加模块或有较大更改时更新子版本号,当bug修复和功能补充时更新小版本号
66

77
var repositoryUrl = "https://repo.crypticlib.com:8081/repository/"

module/bukkit/particle/src/main/java/com/crypticlib/particle/pobject/ParticleObject.java

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@
1919
*/
2020
public abstract class ParticleObject {
2121

22-
private Location origin;
23-
24-
private ShowType showType = ShowType.NONE;
25-
private TaskWrapper task;
26-
private long period;
27-
private boolean running = false;
28-
29-
private Particle particle = Particle.VILLAGER_HAPPY;
30-
private int count = 1;
31-
private double offsetX = 0;
32-
private double offsetY = 0;
33-
private double offsetZ = 0;
34-
private double extra = 0;
35-
private Object data = null;
36-
private Color color;
37-
private Entity entity;
22+
protected Location origin;
23+
24+
protected ShowType showType = ShowType.NONE;
25+
protected TaskWrapper showTask;
26+
protected long period;
27+
protected boolean running = false;
28+
29+
protected Particle particle = Particle.VILLAGER_HAPPY;
30+
protected int count = 1;
31+
protected double offsetX = 0;
32+
protected double offsetY = 0;
33+
protected double offsetZ = 0;
34+
protected double extra = 0;
35+
protected Object data = null;
36+
protected Color color;
37+
protected Entity entity;
3838
/**
3939
* X的变化量
4040
*/
41-
private double incrementX;
42-
private double incrementY;
43-
private double incrementZ;
41+
protected double incrementX;
42+
protected double incrementY;
43+
protected double incrementZ;
4444
/**
4545
* 表示该特效对象所拥有的矩阵
4646
*/
47-
private Matrix matrix;
47+
protected Matrix matrix;
4848

4949
/**
5050
* 将计算好的粒子展示位置以列表的方式返回
@@ -67,7 +67,7 @@ public void alwaysShow() {
6767
// 此处的延迟 2tick 是为了防止turnOffTask还没把特效给关闭时的缓冲
6868
CrypticLibBukkit.scheduler().syncLater(() -> {
6969
running = true;
70-
task = CrypticLibBukkit.scheduler().syncTimer(() -> {
70+
showTask = CrypticLibBukkit.scheduler().syncTimer(() -> {
7171
if (!running) {
7272
return;
7373
}
@@ -86,7 +86,7 @@ public void alwaysShowAsync() {
8686
// 此处的延迟 2tick 是为了防止turnOffTask还没把特效给关闭时的缓冲
8787
CrypticLibBukkit.scheduler().syncLater(() -> {
8888
running = true;
89-
task = CrypticLibBukkit.scheduler().asyncTimer(() -> {
89+
showTask = CrypticLibBukkit.scheduler().asyncTimer(() -> {
9090
if (!running) {
9191
return;
9292
}
@@ -115,7 +115,7 @@ public void alwaysPlay() {
115115
// 此处的延迟 2tick 是为了防止turnOffTask还没把特效给关闭时的缓冲
116116
CrypticLibBukkit.scheduler().syncLater(() -> {
117117
running = true;
118-
task = CrypticLibBukkit.scheduler().syncTimer(() -> {
118+
showTask = CrypticLibBukkit.scheduler().syncTimer(() -> {
119119
if (!running) {
120120
return;
121121
}
@@ -143,7 +143,7 @@ public void alwaysPlayAsync() {
143143
// 此处的延迟 2tick 是为了防止turnOffTask还没把特效给关闭时的缓冲
144144
CrypticLibBukkit.scheduler().syncLater(() -> {
145145
running = true;
146-
task = CrypticLibBukkit.scheduler().asyncTimer(() -> {
146+
showTask = CrypticLibBukkit.scheduler().asyncTimer(() -> {
147147
if (!running) {
148148
return;
149149
}
@@ -157,9 +157,9 @@ public void alwaysPlayAsync() {
157157
* 将正在展示或播放的特效关闭
158158
*/
159159
public void turnOffTask() {
160-
if (task != null) {
160+
if (showTask != null) {
161161
running = false;
162-
task.cancel();
162+
showTask.cancel();
163163
setShowType(ShowType.NONE);
164164
}
165165
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.crypticlib.particle.pobject;
2+
3+
import org.bukkit.Location;
4+
import org.jetbrains.annotations.NotNull;
5+
6+
import java.util.Collections;
7+
import java.util.List;
8+
9+
public class Point extends ParticleObject {
10+
11+
/**
12+
* 构造一个点
13+
* @param origin 点的原始坐标
14+
*/
15+
public Point(@NotNull Location origin) {
16+
this.origin = origin;
17+
}
18+
19+
@Override
20+
public List<Location> calculateLocations() {
21+
Location loc = getOrigin().clone();
22+
loc.add(getIncrementX(), getIncrementY(), getIncrementZ());
23+
return Collections.singletonList(loc);
24+
}
25+
26+
@Override
27+
public void show() {
28+
spawnParticle(getOrigin().clone());
29+
}
30+
31+
}

0 commit comments

Comments
 (0)