Skip to content

Commit fe20ca4

Browse files
committed
修复 由于ControlableParticleData 构造了EnvType.CLIENT的 ParticleTextureSheet 导致无法在服务器使用粒子发射器的BUG
但是所有使用了textureSheet = XXX这种方法的kotlin代码均失效 使用setTextureSheet(sheet)
1 parent c2a3e00 commit fe20ca4

9 files changed

Lines changed: 33 additions & 18 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ loom_version=1.10-SNAPSHOT
1111
fabric_kotlin_version=1.13.2+kotlin.2.1.20
1212

1313
# Mod Properties
14-
mod_version=1.10.0
14+
mod_version=1.10.1
1515
maven_group=cn.coostack
1616
archives_base_name=coo-particles-api
1717

src/main/kotlin/cn/coostack/cooparticlesapi/items/TestParticleItem.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
7979
.also {
8080
it.maxTick = 240
8181
it.templateData.apply {
82-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
82+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
8383
color = Math3DUtil.colorOf(100, 100, 210)
8484
effect = TestEndRodEffect(uuid)
8585
size = 0.1f
@@ -95,7 +95,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
9595
it.maxTick = 240
9696
it.templateData.apply {
9797
maxAge = 1
98-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
98+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
9999
color = Math3DUtil.colorOf(100, 100, 210)
100100
effect = TestEndRodEffect(uuid)
101101
}
@@ -110,7 +110,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
110110
it.maxTick = 120
111111
it.templateData.apply {
112112
maxAge = 20
113-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
113+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
114114
color = Math3DUtil.colorOf(100, 100, 210)
115115
effect = TestEndRodEffect(uuid)
116116
}
@@ -125,7 +125,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
125125
it.maxTick = 10
126126
it.templateData.apply {
127127
maxAge = 60
128-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
128+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
129129
color = Math3DUtil.colorOf(255, 255, 255)
130130
effect = TestEndRodEffect(uuid)
131131
}
@@ -141,7 +141,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
141141
it.maxTick = -1
142142
it.templateData.apply {
143143
maxAge = 30
144-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
144+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
145145
color = Math3DUtil.colorOf(255, 255, 255)
146146
effect = TestEndRodEffect(uuid)
147147
}
@@ -159,7 +159,7 @@ class TestParticleItem(settings: Settings) : Item(settings) {
159159
it.moveDirection = user.rotationVector.normalize().multiply(0.5)
160160
it.templateData.apply {
161161
maxAge = 20
162-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
162+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
163163
color = Math3DUtil.colorOf(217, 137, 146)
164164
effect = ControlableCloudEffect(uuid)
165165
}

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/ClassParticleEmitters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ abstract class ClassParticleEmitters(
249249
this.color = data.color
250250
this.currentAge = data.age
251251
this.maxAge = data.maxAge
252-
this.textureSheet = data.textureSheet
252+
this.textureSheet = data.getTextureSheet()
253253
this.particleAlpha = data.alpha
254254
}
255255
control.addPreTickAction {

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/ControlableParticleData.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cn.coostack.cooparticlesapi.network.particle.emitters
22

3+
import cn.coostack.cooparticlesapi.CooParticleAPI
34
import cn.coostack.cooparticlesapi.particles.ControlableParticleEffect
45
import cn.coostack.cooparticlesapi.particles.ControlableParticleEffectManager
56
import cn.coostack.cooparticlesapi.particles.impl.TestEndRodEffect
@@ -31,9 +32,6 @@ open class ControlableParticleData {
3132
buf.writeString(data.effect::class.java.name)
3233
buf.writeUuid(data.uuid)
3334
buf.writeDouble(data.speed)
34-
// val effectPacketCodec =
35-
// data.effect.getPacketCodec() as PacketCodec<RegistryByteBuf, ControlableParticleEffect>
36-
// effectPacketCodec.encode(buf, data.effect)
3735
}
3836

3937
private fun decode(
@@ -65,7 +63,7 @@ open class ControlableParticleData {
6563
this.visibleRange = visibleRange
6664
this.age = age
6765
this.maxAge = maxAge
68-
this.textureSheet = this.textureSheetFromString(textureSheet)
66+
this.textureSheet = textureSheet
6967
this.effect = effect
7068
this.speed = speed
7169
}
@@ -81,7 +79,9 @@ open class ControlableParticleData {
8179
var maxAge = 120
8280
var visibleRange = 128f
8381
var effect: ControlableParticleEffect = TestEndRodEffect(uuid)
84-
var textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
82+
83+
// 脑瘫东西设置了客户端专属
84+
private var textureSheet: String = "PARTICLE_SHEET_TRANSLUCENT"
8585

8686
/**
8787
* 粒子移动速度
@@ -99,6 +99,21 @@ open class ControlableParticleData {
9999
}
100100
}
101101

102+
fun getTextureSheet(): ParticleTextureSheet {
103+
return textureSheetFromString(textureSheet) ?: let {
104+
CooParticleAPI.logger.error("can not find textureSheet $textureSheet")
105+
ParticleTextureSheet.PARTICLE_SHEET_OPAQUE
106+
}
107+
}
108+
109+
fun setTextureSheet(value: String) {
110+
this.textureSheet = value
111+
}
112+
113+
fun setTextureSheet(value: ParticleTextureSheet) {
114+
this.textureSheet = value.toString()
115+
}
116+
102117
open fun getCodec(): PacketCodec<PacketByteBuf, out ControlableParticleData> {
103118
return PACKET_CODEC
104119
}

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/impl/DefendClassParticleEmitters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class DefendClassParticleEmitters(var player: UUID, pos: Vec3d, world: World?) :
7676
.associateBy {
7777
templateData.clone().also {
7878
it.alpha = 0.15f
79-
it.textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
79+
it.setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
8080
}
8181
}
8282
)

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/impl/PhysicsParticleEmitters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class PhysicsParticleEmitters(
318318
this.color = data.color
319319
this.currentAge = data.age
320320
this.maxAge = data.maxAge
321-
this.textureSheet = data.textureSheet
321+
this.textureSheet = data.getTextureSheet()
322322
this.particleAlpha = data.alpha
323323
}
324324
control.addPreTickAction {

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/impl/PresetLaserEmitters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class PresetLaserEmitters(pos: Vec3d, world: World?) : ClassParticleEmitters(pos
182182
spawnPos: Vec3d,
183183
spawnWorld: World
184184
) {
185-
data.textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
185+
data.setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
186186
var tick = 0
187187
var speed = 0f
188188
data.maxAge = lineMaxTick

src/main/kotlin/cn/coostack/cooparticlesapi/network/particle/emitters/impl/SimpleParticleEmitters.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class SimpleParticleEmitters(
261261
this.color = data.color
262262
this.currentAge = data.age
263263
this.maxAge = data.maxAge
264-
this.textureSheet = data.textureSheet
264+
this.textureSheet = data.getTextureSheet()
265265
this.particleAlpha = data.alpha
266266
}
267267
control.addPreTickAction {

src/main/kotlin/cn/coostack/cooparticlesapi/test/entity/goal/TestPlayerAttackGoal.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class TestPlayerAttackGoal(entity: TestPlayerEntity, speed: Double, pauseWhenMob
6969
it.maxTick = 5
7070
it.templateData.apply {
7171
maxAge = 60
72-
textureSheet = ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT
72+
setTextureSheet(ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT)
7373
color = Math3DUtil.colorOf(255, 255, 255)
7474
effect = TestEndRodEffect(uuid)
7575
}

0 commit comments

Comments
 (0)