@@ -28,8 +28,15 @@ public class SphereEffect extends Effect {
2828 */
2929 public double radiusIncrease = 0 ;
3030
31- // Amount to increase the particles per tick
31+ /** Amount to increase the particles per tick*/
3232 public int particleIncrease = 0 ;
33+
34+ //TODO new stuff
35+ /**Should it display as an half sphere?*/
36+ public boolean halfSphere = false ;
37+
38+ /**If it is an half sphere, should it be inverted the other way around? Like upside down*/
39+ public boolean invertHalfSphere = false ;
3340
3441 /**
3542 * Creates a new sphere effect.
@@ -41,13 +48,17 @@ public class SphereEffect extends Effect {
4148 * @param radius The radius of the sphere
4249 * @param radiusIncrease The amount to increase the radius per iteration/tick
4350 * @param particleIncrease The amount to increase the particles per iteration/tick
51+ * @param half_sphere If true, displays as an half sphere/dome
52+ * @param invert_half_sphere If true and displaying as an half sphere, displays the bottom half
4453 * */
45- public SphereEffect (ServerWorld world , ParticleEffect particle , Vec3d origin , int particles , double radius , double radiusIncrease , int particleIncrease ) {
54+ public SphereEffect (ServerWorld world , ParticleEffect particle , Vec3d origin , int particles , double radius , double radiusIncrease , int particleIncrease , boolean half_sphere , boolean invert_half_sphere ) {
4655 super (world , EffectType .REPEATING , particle , origin );
4756 this .particles = particles ;
4857 this .radius = radius ;
4958 this .radiusIncrease = radiusIncrease ;
5059 this .particleIncrease = particleIncrease ;
60+ this .halfSphere = half_sphere ;
61+ this .invertHalfSphere = invert_half_sphere ;
5162 }
5263
5364
@@ -57,6 +68,8 @@ public static void copy(SphereEffect original, SphereEffect copy) {
5768 copy .setRadiusIncrease (original .getRadiusIncrease ());
5869 copy .setParticleIncrease (original .getParticleIncrease ());
5970 copy .setParticles (original .getParticles ());
71+ copy .setHalfSphere (original .isHalfSphere ());
72+ copy .setInvertedHalfSphere (original .isInvertHalSphere ());
6073 }
6174
6275 /**
@@ -100,6 +113,8 @@ private SphereEffect(Builder builder) {
100113 setParticleIncrease (builder .particleIncrease );
101114 setUseEyePosAsOrigin (builder .useEyePosAsOrigin );
102115 setExecuteOnStop (builder .executeOnStop );
116+ setHalfSphere (builder .halfSphere );
117+ setInvertedHalfSphere (builder .invertHalfSphere );
103118 }
104119
105120
@@ -129,11 +144,19 @@ public void onRun() {
129144
130145 //Should be already adding the stuff
131146 //origin.add(0, yOffset, 0);
132- Vec3d v ;
147+ Vec3d vector ;
133148
134149 for (int i = 0 ; i < particles ; i ++) {
135- v = RandomUtils .getRandomVector ().multiply (radius );
136- this .displayParticle (particle , origin .add (v ));
150+ vector = RandomUtils .getRandomVector ().multiply (radius );
151+ if (halfSphere ) {
152+ if (invertHalfSphere ){
153+ vector = new Vec3d (vector .getX (), Math .abs (vector .getY ()) * -1 , vector .getZ ());
154+ }
155+ else {
156+ vector = new Vec3d (vector .getX (), Math .abs (vector .getY ()), vector .getZ ());
157+ }
158+ }
159+ this .displayParticle (particle , origin .add (vector ));
137160 }
138161 }
139162
@@ -168,6 +191,22 @@ public void setParticles(int particles) {
168191 this .particles = particles ;
169192 }
170193
194+ public boolean isHalfSphere () {
195+ return halfSphere ;
196+ }
197+
198+ public void setHalfSphere (boolean half_sphere ) {
199+ this .halfSphere = half_sphere ;
200+ }
201+
202+ public boolean isInvertHalSphere () {
203+ return invertHalfSphere ;
204+ }
205+
206+ public void setInvertedHalfSphere (boolean invert_half_sphere ) {
207+ this .invertHalfSphere = invert_half_sphere ;
208+ }
209+
171210 /**
172211 * {@code SphereEffect} builder static inner class.
173212 */
@@ -200,6 +239,12 @@ public static final class Builder {
200239 // Amount to increase the particles per tick
201240 private int particleIncrease = 0 ;
202241
242+ /**Should it display as an half sphere?*/
243+ public boolean halfSphere = false ;
244+
245+ /**If it is an half sphere, should it be inverted the other way around? Like upside down*/
246+ public boolean invertHalfSphere = false ;
247+
203248
204249 private Builder () {
205250 }
@@ -347,6 +392,28 @@ public Builder particleIncrease(int particleIncrease) {
347392 return this ;
348393 }
349394
395+ /**
396+ * Sets the {@code halfSphere} and returns a reference to this Builder enabling method chaining.
397+ *
398+ * @param halfSphere the {@code halfSphere} to set
399+ * @return a reference to this Builder
400+ */
401+ public Builder halfSphere (boolean halfSphere ) {
402+ this .halfSphere = halfSphere ;
403+ return this ;
404+ }
405+
406+ /**
407+ * Sets the {@code invertHalfSphere} and returns a reference to this Builder enabling method chaining.
408+ *
409+ * @param invertHalfSphere the {@code invertHalfSphere} to set
410+ * @return a reference to this Builder
411+ */
412+ public Builder invertHalfSphere (boolean invertHalfSphere ) {
413+ this .invertHalfSphere = invertHalfSphere ;
414+ return this ;
415+ }
416+
350417 /**
351418 * Returns a {@code SphereEffect} built from the parameters previously set.
352419 *
0 commit comments