Skip to content
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