Skip to content

Commit 8147718

Browse files
committed
Deleted DomeShieldEffect and added half sphere parameters to the SphereEffect
1 parent 4b7194d commit 8147718

4 files changed

Lines changed: 101 additions & 103 deletions

File tree

src/main/java/me/emafire003/dev/particleanimationlib/commands/PALDebugCommand.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,18 @@
33
import com.mojang.brigadier.context.CommandContext;
44
import com.mojang.brigadier.exceptions.CommandSyntaxException;
55
import com.mojang.brigadier.tree.LiteralCommandNode;
6-
import me.emafire003.dev.particleanimationlib.effects.ConeEffect;
7-
import me.emafire003.dev.particleanimationlib.effects.CuboidEffect;
6+
import me.emafire003.dev.particleanimationlib.ParticleAnimationLib;
87
import me.emafire003.dev.particleanimationlib.effects.TextEffect;
9-
import me.emafire003.dev.particleanimationlib.effects.image.BaseImageEffect;
10-
import me.emafire003.dev.particleanimationlib.effects.image.ColoredImageEffect;
118
import net.minecraft.command.CommandRegistryAccess;
129
import net.minecraft.command.argument.EntityArgumentType;
1310
import net.minecraft.entity.Entity;
1411
import net.minecraft.particle.ParticleTypes;
1512
import net.minecraft.server.command.CommandManager;
1613
import net.minecraft.server.command.ServerCommandSource;
1714
import net.minecraft.text.Text;
18-
import net.minecraft.util.math.Vec3d;
1915

2016
import java.awt.*;
2117
import java.util.Collection;
22-
import java.util.concurrent.atomic.AtomicInteger;
2318

2419
public class PALDebugCommand implements PALCommand {
2520

@@ -40,17 +35,31 @@ private int particleEffect(CommandContext<ServerCommandSource> context) throws C
4035
return 0;
4136
}
4237

43-
TextEffect textEffect = new TextEffect(source.getWorld(), ParticleTypes.ELECTRIC_SPARK, target.getPos(), target.getHeadYaw(), target.getPitch(), "Hello world", false, 1, 1, (float) 1 / 10, true, new Font("Times New Roman", Font.PLAIN, 16));
38+
/*TextEffect textEffect = new TextEffect(source.getWorld(), ParticleTypes.ENCHANTED_HIT, target.getPos().add(0,2,0), target.getHeadYaw(), target.getPitch(), "Hello world", false, 1, 1, (float) 1 / 5, true, new Font("Courier New", Font.PLAIN, 13));
4439
//textEffect.runFor(5);
4540
textEffect.runFor(5, ((effect, current_tick) -> {
4641
TextEffect instance = (TextEffect) effect;
4742
instance.text = "hello world " + current_tick;
4843
//instance.text = "hello world " + source.getPlayer().getRandom().nextBetween(0,10);
4944
50-
}));
45+
}));*/
46+
Font a = new Font("Tahoma", Font.PLAIN, 16);
5147

52-
ConeEffect coneEffect = ConeEffect.builder(source.getWorld(), ParticleTypes.WITCH, target.getPos()).build();
53-
coneEffect.runFor(5);
48+
//TODO niente lagga e si blocca se uso il builder
49+
TextEffect textEffect1 = TextEffect.builder(source.getWorld(), ParticleTypes.EGG_CRACK, target.getPos()).text("\uD800\uDC06 Hello worldo \uD800\uDC06").font(new Font("Times New Roman", Font.PLAIN, 13)).build();
50+
ParticleAnimationLib.LOGGER.info("The font: " + textEffect1.font);
51+
ParticleAnimationLib.LOGGER.info("The scale: " + textEffect1.size);
52+
//textEffect1.runFor(5);
53+
54+
TextEffect textEffect2 = TextEffect.builder(source.getWorld(), ParticleTypes.ENCHANTED_HIT, target.getPos()).build();
55+
TextEffect.copy(textEffect1, textEffect2);
56+
textEffect2.setFont(new Font("Verdana", Font.PLAIN, 13));
57+
textEffect2.setParticle(ParticleTypes.ELECTRIC_SPARK);
58+
textEffect2.setOriginPos(target.getPos().add(2,0,0));
59+
//textEffect2.runFor(3);
60+
61+
/*ConeEffect coneEffect = ConeEffect.builder(source.getWorld(), ParticleTypes.WITCH, target.getPos()).build();
62+
coneEffect.runFor(5);*/
5463

5564
/*CuboidEffect effect = CuboidEffect.builder(source.getWorld(), ParticleTypes.ELECTRIC_SPARK, source.getPosition().add(0,10,0)).build();
5665
effect.runFor(5);*/

src/main/java/me/emafire003/dev/particleanimationlib/commands/SphereCommand.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.emafire003.dev.particleanimationlib.commands;
22

3+
import com.mojang.brigadier.arguments.BoolArgumentType;
34
import com.mojang.brigadier.arguments.DoubleArgumentType;
45
import com.mojang.brigadier.arguments.IntegerArgumentType;
56
import com.mojang.brigadier.context.CommandContext;
@@ -28,7 +29,9 @@ private int spawnEffect(CommandContext<ServerCommandSource> context) throws Comm
2829
IntegerArgumentType.getInteger(context, "count"),
2930
DoubleArgumentType.getDouble(context, "radius"),
3031
DoubleArgumentType.getDouble(context, "radiusIncrease"),
31-
IntegerArgumentType.getInteger(context, "particleIncrease")
32+
IntegerArgumentType.getInteger(context, "particleIncrease"),
33+
BoolArgumentType.getBool(context, "halfSphere"),
34+
BoolArgumentType.getBool(context, "invertHalfSphere")
3235
);
3336
effect.runFor(IntegerArgumentType.getInteger(context, "duration"));
3437

@@ -49,8 +52,12 @@ public LiteralCommandNode<ServerCommandSource> getNode(CommandRegistryAccess reg
4952
.then(CommandManager.argument("radius", DoubleArgumentType.doubleArg(0))
5053
.then(CommandManager.argument("radiusIncrease", DoubleArgumentType.doubleArg(0))
5154
.then(CommandManager.argument("particleIncrease", IntegerArgumentType.integer(0))
52-
.then(CommandManager.argument("duration", IntegerArgumentType.integer(0))
53-
.executes(this::spawnEffect)
55+
.then(CommandManager.argument("halfSphere", BoolArgumentType.bool())
56+
.then(CommandManager.argument("invertHalfSphere", BoolArgumentType.bool())
57+
.then(CommandManager.argument("duration", IntegerArgumentType.integer(0))
58+
.executes(this::spawnEffect)
59+
)
60+
)
5461
)
5562
)
5663
)

src/main/java/me/emafire003/dev/particleanimationlib/effects/DomeShieldEffect.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

src/main/java/me/emafire003/dev/particleanimationlib/effects/SphereEffect.java

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)