Piglin portal spawn modifier

Allows changing the modifier for the piglin spawn chance from a portal block based on the world difficulty.

For example, with the default vanilla value of 2000 there is a 2 out of 2000 chance for a piglin to spawn in a portal block each tick in normal mode.

Equation: random.nextInt(modifier) < difficulty

Difficulties:
0 - peaceful
1 - easy
2 - normal
3 - hard
This commit is contained in:
William Blake Galbreath
2025-01-11 18:16:33 -08:00
committed by granny
parent 8ce5e9f17f
commit 5ea7aa4cc1
3 changed files with 13 additions and 52 deletions

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/level/block/NetherPortalBlock.java
+++ b/net/minecraft/world/level/block/NetherPortalBlock.java
@@ -72,7 +_,7 @@
protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.dimensionType().natural() // Spigot
&& level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)
- && random.nextInt(2000) < level.getDifficulty().getId()) {
+ && random.nextInt(level.purpurConfig.piglinPortalSpawnModifier) < level.getDifficulty().getId()) { // Purpur - Piglin portal spawn modifier
while (level.getBlockState(pos).is(this)) {
pos = pos.below();
}

View File

@@ -1707,6 +1707,7 @@ public class PurpurWorldConfig {
public double piglinScale = 1.0D;
public boolean piglinBypassMobGriefing = false;
public boolean piglinTakeDamageFromWater = false;
public int piglinPortalSpawnModifier = 2000;
private void piglinSettings() {
piglinRidable = getBoolean("mobs.piglin.ridable", piglinRidable);
piglinRidableInWater = getBoolean("mobs.piglin.ridable-in-water", piglinRidableInWater);
@@ -1720,6 +1721,7 @@ public class PurpurWorldConfig {
piglinScale = Mth.clamp(getDouble("mobs.piglin.attributes.scale", piglinScale), 0.0625D, 16.0D);
piglinBypassMobGriefing = getBoolean("mobs.piglin.bypass-mob-griefing", piglinBypassMobGriefing);
piglinTakeDamageFromWater = getBoolean("mobs.piglin.takes-damage-from-water", piglinTakeDamageFromWater);
piglinPortalSpawnModifier = getInt("mobs.piglin.portal-spawn-modifier", piglinPortalSpawnModifier);
}
public boolean piglinBruteRidable = false;