From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath Date: Fri, 29 Nov 2019 22:37:44 -0600 Subject: [PATCH] Charged creeper naturally spawn diff --git a/src/main/java/net/minecraft/world/entity/monster/Creeper.java b/src/main/java/net/minecraft/world/entity/monster/Creeper.java index 4cb68050f93027225b63176724b2c882902d8b71..a3b8b874dba75b0b2dfb89d8a31f875c396c9a9a 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java +++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java @@ -257,6 +257,14 @@ public class Creeper extends Monster implements PowerableMob { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level().purpurConfig.creeperMaxHealth); } + public net.minecraft.world.entity.SpawnGroupData finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor world, net.minecraft.world.DifficultyInstance difficulty, net.minecraft.world.entity.MobSpawnType spawnReason, @Nullable net.minecraft.world.entity.SpawnGroupData entityData) { + double chance = world.getLevel().purpurConfig.creeperChargedChance; + if (chance > 0D && random.nextDouble() <= chance) { + setPowered(true); + } + return super.finalizeSpawn(world, difficulty, spawnReason, entityData); + } + @Override protected SoundEvent getHurtSound(DamageSource source) { return SoundEvents.CREEPER_HURT; diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 72172293aedfef696b6649946746d39edf056363..4a05d99d81fd487fda33ec2aee7f981bb24766aa 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -367,6 +367,7 @@ public class PurpurWorldConfig { public boolean creeperRidableInWater = true; public boolean creeperControllable = true; public double creeperMaxHealth = 20.0D; + public double creeperChargedChance = 0.0D; private void creeperSettings() { creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable); creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater); @@ -377,6 +378,7 @@ public class PurpurWorldConfig { set("mobs.creeper.attributes.max_health", oldValue); } creeperMaxHealth = getDouble("mobs.creeper.attributes.max_health", creeperMaxHealth); + creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance); } public boolean dolphinRidable = false;