Skip to content

Commit 683e491

Browse files
committed
Add rule spawnLeaderZombieProbably
1 parent a1664ce commit 683e491

8 files changed

Lines changed: 155 additions & 0 deletions

File tree

src/main/java/carpettisaddition/CarpetTISAdditionSettings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,14 @@ public ValidateNetherPortalMaxSize()
657657
)
658658
public static double spawnJockeyProbably = -1;
659659

660+
@Rule(
661+
categories = {TIS, CREATIVE},
662+
validators = OptionalProbablyValidator.class,
663+
options = {"-1", "0", "0.5", "1"},
664+
strict = false
665+
)
666+
public static double spawnLeaderZombieProbably = -1;
667+
660668
@Rule(
661669
options = {"10", "100", "1024", "10240"},
662670
strict = false,
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* This file is part of the Carpet TIS Addition project, licensed under the
3+
* GNU Lesser General Public License v3.0
4+
*
5+
* Copyright (C) 2026 Fallen_Breath and contributors
6+
*
7+
* Carpet TIS Addition is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* Carpet TIS Addition is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
package carpettisaddition.helpers.rule.spawnLeaderZombieProbably;
22+
23+
import carpettisaddition.CarpetTISAdditionSettings;
24+
25+
import java.util.Random;
26+
27+
public class SpawnLeaderZombieProbablyHelper
28+
{
29+
public static final Random RANDOM = new Random();
30+
31+
public static boolean isEnabled()
32+
{
33+
return CarpetTISAdditionSettings.spawnLeaderZombieProbably >= 0;
34+
}
35+
36+
public static boolean shouldSpawnLeader()
37+
{
38+
double p = CarpetTISAdditionSettings.spawnLeaderZombieProbably;
39+
return p > 0 && RANDOM.nextFloat() <= p;
40+
}
41+
42+
public static float tweak(float originalValue, float leaderValue, float notLeaderValue)
43+
{
44+
if (isEnabled())
45+
{
46+
return shouldSpawnLeader() ? leaderValue : notLeaderValue;
47+
}
48+
return originalValue;
49+
}
50+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* This file is part of the Carpet TIS Addition project, licensed under the
3+
* GNU Lesser General Public License v3.0
4+
*
5+
* Copyright (C) 2026 Fallen_Breath and contributors
6+
*
7+
* Carpet TIS Addition is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU Lesser General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* Carpet TIS Addition is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU Lesser General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU Lesser General Public License
18+
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
19+
*/
20+
21+
package carpettisaddition.mixins.rule.spawnLeaderZombieProbably;
22+
23+
import carpettisaddition.helpers.rule.spawnLeaderZombieProbably.SpawnLeaderZombieProbablyHelper;
24+
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
25+
import net.minecraft.world.entity.monster.Zombie;
26+
import org.objectweb.asm.Opcodes;
27+
import org.spongepowered.asm.mixin.Mixin;
28+
import org.spongepowered.asm.mixin.injection.At;
29+
import org.spongepowered.asm.mixin.injection.Slice;
30+
31+
@Mixin(Zombie.class)
32+
public abstract class ZombieMixin
33+
{
34+
@ModifyExpressionValue(
35+
method = "handleAttributes",
36+
slice = @Slice(
37+
from = @At(
38+
value = "FIELD",
39+
target = "Lnet/minecraft/world/entity/monster/SharedMonsterAttributes;FOLLOW_RANGE:Lnet/minecraft/world/entity/ai/attributes/Attribute;",
40+
opcode = Opcodes.GETSTATIC
41+
)
42+
),
43+
at = @At(
44+
value = "INVOKE",
45+
//#if MC >= 11900
46+
//$$ target = "Lnet/minecraft/util/RandomSource;nextFloat()F"
47+
//#else
48+
target = "Ljava/util/Random;nextFloat()F"
49+
//#endif
50+
)
51+
)
52+
private float spawnLeaderZombieProbably_tweak(float original)
53+
{
54+
return SpawnLeaderZombieProbablyHelper.tweak(original, -0.1f, Float.MAX_VALUE);
55+
}
56+
}

src/main/resources/assets/carpettisaddition/lang/en_us.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,12 @@ carpettisaddition:
14241424
'0': 'Affected jockeys: chicken jockey, spider jockey, strider jockey'
14251425
'1': 'For striders, the spawn ratio between zombified piglin and baby strider is still 1:3'
14261426
'2': Set it to -1 to disable the rule and use vanilla logic
1427+
spawnLeaderZombieProbably:
1428+
name: spawnLeaderZombieProbably
1429+
desc: When spawning zombies, override the probability of spawning a leader zombie
1430+
extra:
1431+
'0': A leader zombie can call for reinforcements, has higher max health, and can break doors
1432+
'1': Set it to -1 to disable the rule and use vanilla logic
14271433
speedTestCommandMaxTestSize:
14281434
name: speedTestCommandMaxTestSize
14291435
desc: The max test size in MiB when using the /speedtest command for network speed test

src/main/resources/assets/carpettisaddition/lang/zh_cn.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,12 @@ carpettisaddition:
14241424
'0': '影响的骑手类型: 鸡骑士、蜘蛛骑士、炽足兽骑手'
14251425
'1': '对于炽足兽,生成僵尸猪灵、幼年炽足兽的概率比将保持1:3'
14261426
'2': 将其设为-1以禁用本规则并使用原版逻辑
1427+
spawnLeaderZombieProbably:
1428+
name: 生成领头僵尸概率
1429+
desc: 调整刷怪时生成领头僵尸的概率
1430+
extra:
1431+
'0': 领头僵尸是那种能召唤援军、血量上限更高且能拆门的僵尸
1432+
'1': 将其设为-1以禁用本规则并使用原版逻辑
14271433
speedTestCommandMaxTestSize:
14281434
name: 测速指令最大测试大小
14291435
desc: 在使用/speedtest测速指令进行网络速度测试时,最大的测试数据大小,单位MiB

src/main/resources/carpet-tis-addition.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@
488488
"rule.spawnJockeyProbably.SpiderEntityMixin",
489489
"rule.spawnJockeyProbably.StriderEntityMixin",
490490
"rule.spawnJockeyProbably.ZombieEntityMixin",
491+
"rule.spawnLeaderZombieProbably.ZombieMixin",
491492
"rule.structureBlockDoNotPreserveFluid.StructureBlockBlockEntityMixin",
492493
"rule.structureBlockDoNotPreserveFluid.StructurePlacementDataAccessor",
493494
"rule.structureBlockLimit.StructureBlockBlockEntityMixin",

website/docs/rules.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,20 @@ Set it to `-1` to disable the rule and use vanilla logic
14861486
- Categories: `TIS`, `CREATIVE`
14871487

14881488

1489+
## spawnLeaderZombieProbably
1490+
1491+
When spawning zombies, override the probability of spawning a leader zombie
1492+
1493+
A leader zombie can call for reinforcements, has higher max health, and can break doors
1494+
1495+
Set it to `-1` to disable the rule and use vanilla logic
1496+
1497+
- Type: `double`
1498+
- Default value: `-1`
1499+
- Suggested options: `-1`, `0`, `0.5`, `1`
1500+
- Categories: `TIS`, `CREATIVE`
1501+
1502+
14891503
## speedTestCommandMaxTestSize
14901504

14911505
The max test size in MiB when using the `/speedtest` command for network speed test

website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/rules.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,20 @@ sidebar_position: 1
14861486
- 分类: `TIS`, `CREATIVE`
14871487

14881488

1489+
## 生成领头僵尸概率 (spawnLeaderZombieProbably)
1490+
1491+
调整刷怪时生成领头僵尸的概率
1492+
1493+
领头僵尸是那种能召唤援军、血量上限更高且能拆门的僵尸
1494+
1495+
将其设为 `-1` 以禁用本规则并使用原版逻辑
1496+
1497+
- 类型: `double`
1498+
- 默认值: `-1`
1499+
- 参考选项: `-1`, `0`, `0.5`, `1`
1500+
- 分类: `TIS`, `CREATIVE`
1501+
1502+
14891503
## 测速指令最大测试大小 (speedTestCommandMaxTestSize)
14901504

14911505
在使用 `/speedtest` 测速指令进行网络速度测试时,最大的测试数据大小,单位 MiB

0 commit comments

Comments
 (0)