From 04520086269c32d99bd99f63225965ddde0a3ad1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 23 Jul 2023 19:21:57 -0500 Subject: [PATCH] Add optional parameter for hiding particles for potion effects --- .../java/mcjty/incontrol/tools/rules/RuleBase.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/mcjty/incontrol/tools/rules/RuleBase.java b/src/main/java/mcjty/incontrol/tools/rules/RuleBase.java index 433cd9f..a37ebd2 100644 --- a/src/main/java/mcjty/incontrol/tools/rules/RuleBase.java +++ b/src/main/java/mcjty/incontrol/tools/rules/RuleBase.java @@ -590,7 +590,7 @@ protected void addPotionsAction(List potions) { List 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 ,,"); continue; } @@ -601,6 +601,7 @@ protected void addPotionsAction(List potions) { } int duration = 0; int amplifier = 0; + boolean hideParticles = false; try { duration = Integer.parseInt(splitted[1]); amplifier = Integer.parseInt(splitted[2]); @@ -608,14 +609,21 @@ protected void addPotionsAction(List potions) { 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); } }