Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameter for hiding particles for potion effects #388

Open
wants to merge 1 commit into
base: 1.18
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/main/java/mcjty/incontrol/tools/rules/RuleBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ protected void addPotionsAction(List<String> potions) {
List<MobEffectInstance> effects = new ArrayList<>();
for (String p : potions) {
String[] splitted = StringUtils.split(p, ',');
if (splitted == null || splitted.length != 3) {
if (splitted == null || (splitted.length != 3 && splitted.length != 4)) {
ErrorHandler.error("Bad potion specifier '" + p + "'! Use <potion>,<duration>,<amplifier>");
continue;
}
Expand All @@ -601,21 +601,29 @@ protected void addPotionsAction(List<String> potions) {
}
int duration = 0;
int amplifier = 0;
boolean hideParticles = false;
try {
duration = Integer.parseInt(splitted[1]);
amplifier = Integer.parseInt(splitted[2]);
} catch (NumberFormatException e) {
ErrorHandler.error("Bad duration or amplifier integer for '" + p + "'!");
continue;
}
effects.add(new MobEffectInstance(potion, duration, amplifier));
if (splitted.length == 4)
{
try {
hideParticles = splitted[3].equalsIgnoreCase("true");
}
catch (Exception ignored){}
}
effects.add(new MobEffectInstance(potion, duration, amplifier, hideParticles, !hideParticles));
}
if (!effects.isEmpty()) {
actions.add(event -> {
LivingEntity living = event.getEntityLiving();
if (living != null) {
for (MobEffectInstance effect : effects) {
MobEffectInstance neweffect = new MobEffectInstance(effect.getEffect(), effect.getDuration(), effect.getAmplifier());
MobEffectInstance neweffect = new MobEffectInstance(effect.getEffect(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.isVisible());
living.addEffect(neweffect);
}
}
Expand Down