Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package me.machinemaker.papertweaks.modules.experimental.confetticreepers;

import me.machinemaker.lectern.annotations.Description;
import me.machinemaker.lectern.annotations.Key;
import me.machinemaker.papertweaks.config.PTConfig;
import me.machinemaker.papertweaks.modules.ModuleConfig;

Expand All @@ -28,4 +29,8 @@ class Config extends ModuleConfig {

@Description("Value between 0 (inclusive) and 1.0 (inclusive) for the chance a creeper will be a confetti creeper")
public double chance = 1D;

@Key("allow-charged-creepers")
@Description("Allows charged creepers to explode normally, restoring the ability to obtain mob heads")
public boolean allowChargedCreepers = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import me.machinemaker.papertweaks.modules.ModuleListener;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -57,6 +58,10 @@ public ExplosionListener(final Config config) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(final ExplosionPrimeEvent event) {
if (event.getEntityType() != EntityType.CREEPER) return;
if (this.config.allowChargedCreepers) {
Creeper creeper = (Creeper) event.getEntity();
if (creeper.isPowered()) return;
}
if (ThreadLocalRandom.current().nextDouble() < this.config.chance) {
event.setFire(false);
event.setRadius(0);
Expand Down