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();
}