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

@@ -1,52 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Tue, 13 Apr 2021 11:19:35 -0500
Subject: [PATCH] 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
diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java
index 5169cba4c43d80ce3597c57bf7d40bd0148ec8a0..2d53c57c961fa8977e37931775863665381595eb 100644
--- a/net/minecraft/world/level/block/NetherPortalBlock.java
+++ b/net/minecraft/world/level/block/NetherPortalBlock.java
@@ -78,7 +78,7 @@ public class NetherPortalBlock extends Block implements Portal {
@Override
protected void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
- if (world.spigotConfig.enableZombiePigmenPortalSpawns && world.dimensionType().natural() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && random.nextInt(2000) < world.getDifficulty().getId()) { // Spigot
+ if (world.spigotConfig.enableZombiePigmenPortalSpawns && world.dimensionType().natural() && world.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && random.nextInt(world.purpurConfig.piglinPortalSpawnModifier) < world.getDifficulty().getId()) { // Spigot // Purpur
while (world.getBlockState(pos).is((Block) this)) {
pos = pos.below();
}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index e85eb5d3dbf35c89295302db5431a7b3cb2d3ba1..be247fe9ca24407350044b020db613ce9a70ff26 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -1715,6 +1715,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);
@@ -1728,6 +1729,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;