-
-
Notifications
You must be signed in to change notification settings - Fork 147
/
particle.java.ftl
137 lines (112 loc) · 4.53 KB
/
particle.java.ftl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<#--
# MCreator (https://mcreator.net/)
# Copyright (C) 2012-2020, Pylo
# Copyright (C) 2020-2024, Pylo, opensource contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# Additional permission for code generator templates (*.ftl files)
#
# As a special exception, you may create a larger work that contains part or
# all of the MCreator code generator templates (*.ftl files) and distribute
# that work under terms of your choice, so long as that work isn't itself a
# template for code generation. Alternatively, if you modify or redistribute
# the template itself, you may (at your option) remove this special exception,
# which will cause the template and the resulting code generator output files
# to be licensed under the GNU General Public License without this special
# exception.
-->
<#-- @formatter:off -->
<#include "procedures.java.ftl">
package ${package}.client.particle;
<#compress>
@OnlyIn(Dist.CLIENT) public class ${name}Particle extends TextureSheetParticle {
public static ${name}ParticleProvider provider(SpriteSet spriteSet) {
return new ${name}ParticleProvider(spriteSet);
}
public static class ${name}ParticleProvider implements ParticleProvider<SimpleParticleType> {
private final SpriteSet spriteSet;
public ${name}ParticleProvider(SpriteSet spriteSet) {
this.spriteSet = spriteSet;
}
public Particle createParticle(SimpleParticleType typeIn, ClientLevel worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new ${name}Particle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed, this.spriteSet);
}
}
private final SpriteSet spriteSet;
<#if data.angularVelocity != 0 || data.angularAcceleration != 0>
private float angularVelocity;
private float angularAcceleration;
</#if>
protected ${name}Particle(ClientLevel world, double x, double y, double z, double vx, double vy, double vz, SpriteSet spriteSet) {
super(world, x, y, z);
this.spriteSet = spriteSet;
this.setSize(${data.width}f, ${data.height}f);
<#if !hasProcedure(data.scale)>this.quadSize *= ${data.scale}f;</#if>
<#if (data.maxAgeDiff > 0)>
this.lifetime = (int) Math.max(1, ${data.maxAge} + (this.random.nextInt(${data.maxAgeDiff * 2}) - ${data.maxAgeDiff}));
<#else>
this.lifetime = ${data.maxAge};
</#if>
this.gravity = ${data.gravity}f;
this.hasPhysics = ${data.canCollide};
this.xd = vx * ${data.speedFactor};
this.yd = vy * ${data.speedFactor};
this.zd = vz * ${data.speedFactor};
<#if data.angularVelocity != 0 || data.angularAcceleration != 0>
this.angularVelocity = ${data.angularVelocity}f;
this.angularAcceleration = ${data.angularAcceleration}f;
</#if>
<#if data.animate>
this.setSpriteFromAge(spriteSet);
<#else>
this.pickSprite(spriteSet);
</#if>
}
<#if data.renderType == "LIT">
@Override public int getLightColor(float partialTick) {
return 15728880;
}
</#if>
@Override public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_${data.renderType};
}
<#if hasProcedure(data.scale)>
@Override public float getQuadSize(float scale) {
Level world = this.level;
return (float) <@procedureOBJToConditionCode data.scale/>;
}
</#if>
@Override public void tick() {
super.tick();
<#if data.angularVelocity != 0 || data.angularAcceleration != 0>
this.oRoll = this.roll;
this.roll += this.angularVelocity;
this.angularVelocity += this.angularAcceleration;
</#if>
<#if data.animate>
if(!this.removed) {
<#assign frameCount = data.getTextureTileCount()>
this.setSprite(this.spriteSet.get((this.age / ${data.frameDuration}) % ${frameCount} + 1, ${frameCount}));
}
</#if>
<#if hasProcedure(data.additionalExpiryCondition)>
Level world = this.level;
if (<@procedureOBJToConditionCode data.additionalExpiryCondition/>)
this.remove();
</#if>
}
}
</#compress>
<#-- @formatter:on -->