Skip to content

Commit 6e7f5d2

Browse files
committed
Add force parameter to particle options
1 parent d026775 commit 6e7f5d2

File tree

5 files changed

+45
-23
lines changed

5 files changed

+45
-23
lines changed

src/main/java/com/laytonsmith/abstraction/MCPlayer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public interface MCPlayer extends MCCommandSender, MCHumanEntity, MCOfflinePlaye
156156

157157
void stopSound(MCSoundCategory category);
158158

159-
void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data);
159+
void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, boolean force, Object data);
160160

161161
int getFoodLevel();
162162

src/main/java/com/laytonsmith/abstraction/MCWorld.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public interface MCWorld extends MCMetadatable {
8787

8888
void playEffect(MCLocation l, MCEffect mCEffect, Object data, int radius);
8989

90-
void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data);
90+
void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, boolean force, Object data);
9191

9292
void playSound(MCLocation l, MCSound sound, MCSoundCategory category, float volume, float pitch, Long seed);
9393

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ public void playEffect(MCLocation l, MCEffect mcEffect, Object data, int radius)
315315
}
316316

317317
@Override
318-
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
318+
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, boolean force, Object data) {
319319
w.spawnParticle((Particle) pa.getConcrete(), (Location) l.getHandle(), count, offsetX, offsetY, offsetZ,
320-
velocity, ((BukkitMCParticle) pa).getParticleData(l, data));
320+
velocity, ((BukkitMCParticle) pa).getParticleData(l, data), force);
321321
}
322322

323323
@Override

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCPlayer.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,14 @@ public void stopSound(MCSoundCategory category) {
694694
}
695695

696696
@Override
697-
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, Object data) {
698-
p.spawnParticle((Particle) pa.getConcrete(), (Location) l.getHandle(), count, offsetX, offsetY, offsetZ,
699-
velocity, ((BukkitMCParticle) pa).getParticleData(l, data));
697+
public void spawnParticle(MCLocation l, MCParticle pa, int count, double offsetX, double offsetY, double offsetZ, double velocity, boolean force, Object data) {
698+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) {
699+
p.spawnParticle((Particle) pa.getConcrete(), (Location) l.getHandle(), count, offsetX, offsetY, offsetZ,
700+
velocity, ((BukkitMCParticle) pa).getParticleData(l, data), force);
701+
} else {
702+
p.spawnParticle((Particle) pa.getConcrete(), (Location) l.getHandle(), count, offsetX, offsetY, offsetZ,
703+
velocity, ((BukkitMCParticle) pa).getParticleData(l, data));
704+
}
700705
}
701706

702707
@Override

src/main/java/com/laytonsmith/core/functions/Environment.java

+33-16
Original file line numberDiff line numberDiff line change
@@ -1612,20 +1612,33 @@ public String docs() {
16121612
+ " array defining the characteristics of the particle to be spawned. The array requires the"
16131613
+ " particle name under the key \"particle\". ----"
16141614
+ " Possible particle types: " + StringUtils.Join(MCParticle.types(), ", ", ", or ", " or ") + "."
1615-
+ " <br><br>Some particles have more specific keys and/or special behavior, but the common keys for"
1616-
+ " the particle array are \"count\" (usually the number of particles to be spawned), \"speed\""
1617-
+ " (usually the velocity of the particle), \"xoffset\", \"yoffset\", and \"zoffset\""
1618-
+ " (usually the ranges from center within which the particle may be offset on that axis)."
1619-
+ " <br><br>BLOCK_DUST, BLOCK_CRACK, BLOCK_CRUMBLE, BLOCK_MARKER, DUST_PILLAR, and FALLING_DUST"
1615+
+ "<br>"
1616+
+ "<br>Some particles have more specific keys and/or special behavior, but the common keys for"
1617+
+ " the particle array are:"
1618+
+ "<br>"
1619+
+ "<br>'''count''' : (int) Usually the number of particles to be spawned. A value of 0 (default)"
1620+
+ " can create different particle data behavior than larger numbers."
1621+
+ "<br>'''speed''' : (double) Usually the velocity of the particle. Can be other things (size for"
1622+
+ " EXPLOSION_LARGE) depending on other values, like the particle type and count."
1623+
+ "<br>'''xoffset''' : (double) Usually the random offset width on the x-axis. An offset can also"
1624+
+ " be other things (velocity vector's x component for SMOKE_NORMAL) depending on other values,"
1625+
+ " like the particle type and count."
1626+
+ "<br>'''yoffset''' : (double) Usually the random offset width on the y-axis."
1627+
+ "<br>'''zoffset''' : (double) Usually the random offset width on the z-axis."
1628+
+ "<br>'''force''' : (boolean) Extends visibility range from 32 to 512 meters and encourages"
1629+
+ " clients to render it despite client settings."
1630+
+ "<br>"
1631+
+ "<br>BLOCK_DUST, BLOCK_CRACK, BLOCK_CRUMBLE, BLOCK_MARKER, DUST_PILLAR, and FALLING_DUST"
16201632
+ " particles can take a block type name parameter under the key \"block\" (default: STONE)."
1621-
+ " <br>ITEM_CRACK particles can take an item array or name under the key \"item\" (default: STONE)."
1622-
+ " <br>REDSTONE and SPELL_MOB particles take an RGB color array (each 0 - 255) or name under the key \"color\""
1623-
+ " (defaults to RED for REDSTONE, WHITE for SPELL_MOB)."
1624-
+ " <br>DUST_COLOR_TRANSITION particles take a \"tocolor\" in addition \"color\"."
1625-
+ " <br>VIBRATION particles take a \"destination\" location array or entity UUID."
1626-
+ " <br>SCULK_CHARGE particles take an \"angle\" in radians. (defaults to 0.0)"
1627-
+ " <br>SHRIEK particles take an integer \"delay\" in ticks before playing. (defaults to 0)"
1628-
+ " <br>TRAIL particles take a \"target\" location array, a \"color\", and a \"duration\" integer in ticks.";
1633+
+ "<br>ITEM_CRACK particles can take an item array or name under the key \"item\" (default: STONE)."
1634+
+ "<br>REDSTONE and SPELL_MOB particles take an RGB color array (each 0 - 255) or name under the key"
1635+
+ " \"color\" (defaults to RED for REDSTONE, WHITE for SPELL_MOB)."
1636+
+ "<br>DUST_COLOR_TRANSITION particles take a \"tocolor\" in addition \"color\"."
1637+
+ "<br>VIBRATION particles take a \"destination\" location array or entity UUID."
1638+
+ "<br>SCULK_CHARGE particles take an \"angle\" in radians. (defaults to 0.0)"
1639+
+ "<br>SHRIEK particles take an integer \"delay\" in ticks before playing. (defaults to 0)"
1640+
+ "<br>TRAIL particles take a \"target\" location array, a \"color\" as an RGB array or name, and a"
1641+
+ " \"duration\" integer in ticks.";
16291642
}
16301643

16311644
@Override
@@ -1653,6 +1666,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro
16531666
double offsetY = 0.0;
16541667
double offsetZ = 0.0;
16551668
double speed = 0.0;
1669+
boolean force = false;
16561670
Object data = null;
16571671

16581672
if(args[1].isInstanceOf(CArray.TYPE)) {
@@ -1679,6 +1693,9 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro
16791693
if(pa.containsKey("speed")) {
16801694
speed = ArgumentValidation.getDouble(pa.get("speed", t), t);
16811695
}
1696+
if(pa.containsKey("force")) {
1697+
force = ArgumentValidation.getBooleanObject(pa.get("force", t), t);
1698+
}
16821699

16831700
data = ObjectGenerator.GetGenerator().particleData(p, l, pa, t);
16841701

@@ -1699,14 +1716,14 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro
16991716
}
17001717
for(Mixed playerName : players.asList()) {
17011718
player = Static.GetPlayer(playerName, t);
1702-
player.spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, data);
1719+
player.spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, force, data);
17031720
}
17041721
} else {
17051722
player = Static.GetPlayer(args[2], t);
1706-
player.spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, data);
1723+
player.spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, force, data);
17071724
}
17081725
} else {
1709-
l.getWorld().spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, data);
1726+
l.getWorld().spawnParticle(l, p, count, offsetX, offsetY, offsetZ, speed, force, data);
17101727
}
17111728
} catch (IllegalArgumentException ex) {
17121729
throw new CREIllegalArgumentException("Given unsupported data for particle type " + p.name(), t);

0 commit comments

Comments
 (0)