Files
Purpur/patches/server/0028-Charged-creeper-naturally-spawn.patch
BillyGalbreath 82ef35225f progress
2021-06-16 17:17:33 -05:00

75 lines
3.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 e8c36e8541f041a0d72a86f49ced2a3ce1549be0..27d8279b71f55ae711b0455bb4c5f1527a0e1ccb 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Creeper.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Creeper.java
@@ -11,6 +11,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
+import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.damagesource.DamageSource;
@@ -20,7 +21,9 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LightningBolt;
import net.minecraft.world.entity.LivingEntity;
+import net.minecraft.world.entity.MobSpawnType;
import net.minecraft.world.entity.PowerableMob;
+import net.minecraft.world.entity.SpawnGroupData;
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.AvoidEntityGoal;
@@ -38,10 +41,7 @@ import net.minecraft.world.entity.animal.goat.Goat;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
-import net.minecraft.world.level.Explosion;
-import net.minecraft.world.level.GameRules;
-import net.minecraft.world.level.ItemLike;
-import net.minecraft.world.level.Level;
+import net.minecraft.world.level.*;
import net.minecraft.world.level.gameevent.GameEvent;
// CraftBukkit start
@@ -65,6 +65,17 @@ public class Creeper extends Monster implements PowerableMob {
super(type, world);
}
+ // Purpur start
+ @Override
+ public SpawnGroupData finalizeSpawn(ServerLevelAccessor world, DifficultyInstance difficulty, MobSpawnType spawnReason, @Nullable 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
protected void registerGoals() {
this.goalSelector.addGoal(1, new FloatGoal(this));
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index d8011e5fe28458ae62f764cc355838bd08491f94..375eb6499a91e73310e93d6d42eaa799751f22a2 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -180,9 +180,11 @@ public class PurpurWorldConfig {
public boolean creeperRidable = false;
public boolean creeperRidableInWater = false;
+ public double creeperChargedChance = 0.0D;
private void creeperSettings() {
creeperRidable = getBoolean("mobs.creeper.ridable", creeperRidable);
creeperRidableInWater = getBoolean("mobs.creeper.ridable-in-water", creeperRidableInWater);
+ creeperChargedChance = getDouble("mobs.creeper.naturally-charged-chance", creeperChargedChance);
}
public boolean dolphinRidable = false;