Files
Purpur/patches/server/0030-Charged-creeper-naturally-spawn.patch
William Blake Galbreath 471d6bf4c1 Preliminary update to 1.17.1
2021-07-06 16:25:46 -05:00

46 lines
2.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
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 b71a6af3c2d1ca2a946b23efb11b0e794840cf25..b2b3630a90c685b0a692efb9bf8bb111e321c9d1 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -134,6 +134,14 @@ public class Creeper extends Monster implements PowerableMob {
public void initAttributes() {
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, @Nullable CompoundTag entityNbt) {
+ double chance = world.getMinecraftWorld().purpurConfig.creeperChargedChance;
+ if (chance > 0D && random.nextDouble() <= chance) {
+ setPowered(true);
+ }
+ return super.finalizeSpawn(world, difficulty, spawnReason, entityData, entityNbt);
+ }
// Purpur end
@Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 4c45a692a62fd451718c72ce031552bcd0261048..b8dcd087a87e031aeca1e3c4c68aaaefd18164b7 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -274,6 +274,7 @@ public class PurpurWorldConfig {
public boolean creeperRidable = false;
public boolean creeperRidableInWater = false;
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);
@@ -283,6 +284,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;