|
1 | 1 | package birsy.clinker.client.particle; |
2 | 2 |
|
3 | 3 | import birsy.clinker.client.render.utilities.RenderUtils; |
4 | | -import birsy.clinker.common.alchemy.effects.ChainLightningHandler; |
5 | 4 | import birsy.clinker.core.registry.ClinkerParticles; |
6 | 5 | import com.mojang.blaze3d.vertex.PoseStack; |
7 | 6 | import com.mojang.blaze3d.vertex.VertexConsumer; |
@@ -64,11 +63,11 @@ protected ChainLightningParticle(ClientLevel pLevel, Vec3 startPos, Vec3 endPos, |
64 | 63 | for (int i = 1; i < boltPositions.size(); i++) { |
65 | 64 | Vec3 pos1 = boltPositions.get(i - 1); |
66 | 65 | Vec3 pos2 = boltPositions.get(i); |
67 | | - this.totalDistance += pos1.distanceTo(pos2); |
| 66 | + this.totalDistance += (float) pos1.distanceTo(pos2); |
68 | 67 | boltDistances.add(this.totalDistance); |
69 | 68 | } |
70 | 69 |
|
71 | | - this.setLifetime(ChainLightningHandler.BOLT_TRAVEL_TIME); |
| 70 | + this.setLifetime(15); |
72 | 71 | } |
73 | 72 |
|
74 | 73 | @Override |
@@ -112,68 +111,59 @@ public void render(VertexConsumer pBuffer, Camera camera, float pPartialTicks) { |
112 | 111 | float v2 = Mth.lerp(1.0f - d2, sprite.getV0(), sprite.getV1()); |
113 | 112 |
|
114 | 113 | RenderUtils.drawFaceBetweenPoints(pBuffer, posestack, 0.05f, pos1, tangent1, biTangent1, normal1, sprite.getU0(), v1, 1, 1, 1, time, |
115 | | - pos2, tangent2, biTangent2, normal2, sprite.getU1(), v2, 1, 1, 1, time); |
| 114 | + pos2, tangent2, biTangent2, normal2, sprite.getU1(), v2, 1, 1, 1, time); |
116 | 115 | } |
117 | 116 | } |
118 | 117 |
|
119 | 118 |
|
120 | | - public static class Provider implements ParticleProvider<ChainLightningParticleOptions>, ParticleEngine.SpriteParticleRegistration<ChainLightningParticleOptions> { |
| 119 | + public static class Provider implements ParticleProvider<Options>, ParticleEngine.SpriteParticleRegistration<Options> { |
121 | 120 | private final SpriteSet sprites; |
122 | 121 |
|
123 | 122 | public Provider(SpriteSet pSprites) { |
124 | 123 | this.sprites = pSprites; |
125 | 124 | } |
126 | 125 |
|
127 | | - public Particle createParticle(ChainLightningParticleOptions pType, ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed) { |
| 126 | + public Particle createParticle(Options pType, ClientLevel pLevel, double pX, double pY, double pZ, double pXSpeed, double pYSpeed, double pZSpeed) { |
128 | 127 | return new ChainLightningParticle(pLevel, new Vec3(pType.startX, pType.startY, pType.startZ), new Vec3(pType.endX, pType.endY, pType.endZ), this.sprites); |
129 | 128 | } |
130 | 129 |
|
131 | 130 | @Override |
132 | | - public ParticleProvider<ChainLightningParticleOptions> create(SpriteSet pSprites) { |
| 131 | + public ParticleProvider<Options> create(SpriteSet pSprites) { |
133 | 132 | return new Provider(pSprites); |
134 | 133 | } |
135 | 134 | } |
136 | 135 |
|
137 | | - public static class ChainLightningParticleOptions implements ParticleOptions { |
138 | | - public static final MapCodec<ChainLightningParticleOptions> CODEC = RecordCodecBuilder.mapCodec( |
| 136 | + public static class Options implements ParticleOptions { |
| 137 | + public static final MapCodec<Options> CODEC = RecordCodecBuilder.mapCodec( |
139 | 138 | builder -> builder.group( |
140 | 139 | Codec.DOUBLE.fieldOf("startX").forGetter(particleOptions -> particleOptions.startX), |
141 | 140 | Codec.DOUBLE.fieldOf("startY").forGetter(particleOptions -> particleOptions.startY), |
142 | 141 | Codec.DOUBLE.fieldOf("startZ").forGetter(particleOptions -> particleOptions.startZ), |
143 | 142 | Codec.DOUBLE.fieldOf("endX").forGetter(particleOptions -> particleOptions.endX), |
144 | 143 | Codec.DOUBLE.fieldOf("endY").forGetter(particleOptions -> particleOptions.endY), |
145 | 144 | Codec.DOUBLE.fieldOf("endZ").forGetter(particleOptions -> particleOptions.endZ) |
146 | | - ).apply(builder, ChainLightningParticleOptions::new) |
| 145 | + ).apply(builder, Options::new) |
147 | 146 | ); |
148 | | - public static final StreamCodec<RegistryFriendlyByteBuf, ChainLightningParticleOptions> STREAM_CODEC = StreamCodec.composite( |
| 147 | + public static final StreamCodec<RegistryFriendlyByteBuf, Options> STREAM_CODEC = StreamCodec.composite( |
149 | 148 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.startX, |
150 | 149 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.startY, |
151 | 150 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.startZ, |
152 | 151 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.endX, |
153 | 152 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.endY, |
154 | 153 | ByteBufCodecs.DOUBLE, particleOptions -> particleOptions.endZ, |
155 | | - ChainLightningParticleOptions::new |
| 154 | + Options::new |
156 | 155 | ); |
157 | 156 |
|
158 | | - protected final double startX, startY, startZ; |
159 | | - protected final double endX, endY, endZ; |
| 157 | + protected final double startX, startY, startZ, endX, endY, endZ; |
160 | 158 |
|
161 | | - public ChainLightningParticleOptions(double startX, double startY, double startZ, double endX, double endY, double endZ) { |
162 | | - this.startX = startX; |
163 | | - this.startY = startY; |
164 | | - this.startZ = startZ; |
165 | | - this.endX = endX; |
166 | | - this.endY = endY; |
167 | | - this.endZ = endZ; |
| 159 | + public Options(double startX, double startY, double startZ, double endX, double endY, double endZ) { |
| 160 | + this.startX = startX; this.startY = startY; this.startZ = startZ; |
| 161 | + this.endX = endX; this.endY = endY; this.endZ = endZ; |
168 | 162 | } |
169 | 163 |
|
170 | | - public ChainLightningParticleOptions(Vec3 start, Vec3 end) { |
171 | | - this.startX = start.x(); |
172 | | - this.startY = start.y(); |
173 | | - this.startZ = start.z(); |
174 | | - this.endX = end.x(); |
175 | | - this.endY = end.y(); |
176 | | - this.endZ = end.z(); |
| 164 | + public Options(Vec3 start, Vec3 end) { |
| 165 | + this.startX = start.x(); this.startY = start.y(); this.startZ = start.z(); |
| 166 | + this.endX = end.x(); this.endY = end.y(); this.endZ = end.z(); |
177 | 167 | } |
178 | 168 |
|
179 | 169 | @Override |
|
0 commit comments