Skip to content

Commit

Permalink
Ported rule spawnBabyProbably and spawnJockeyProbably
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Oct 1, 2024
1 parent c6826b5 commit 00e90c6
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 3 deletions.
24 changes: 24 additions & 0 deletions patches/net/minecraft/entity/monster/EntitySpider.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--- a/net/minecraft/entity/monster/EntitySpider.java
+++ b/net/minecraft/entity/monster/EntitySpider.java
@@ -2,6 +2,9 @@

import java.util.Random;
import javax.annotation.Nullable;
+
+import carpet.CarpetServer;
+import carpet.settings.CarpetSettings;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.CreatureAttribute;
import net.minecraft.entity.EntityLivingBase;
@@ -168,7 +171,10 @@
{
entityLivingData = super.onInitialSpawn(difficulty, entityLivingData, itemNbt);

- if (this.world.rand.nextInt(100) == 0)
+ // TISCM spawnJockeyProbably
+ boolean forcedJockeyTISCM = CarpetSettings.spawnJockeyProbably > 0 && CarpetServer.rand.nextFloat() <= CarpetSettings.spawnJockeyProbably;
+
+ if (this.world.rand.nextInt(100) == 0 || forcedJockeyTISCM)
{
EntitySkeleton entityskeleton = new EntitySkeleton(this.world);
entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
38 changes: 35 additions & 3 deletions patches/net/minecraft/entity/monster/EntityZombie.java.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
--- a/net/minecraft/entity/monster/EntityZombie.java
+++ b/net/minecraft/entity/monster/EntityZombie.java
@@ -5,6 +5,9 @@
@@ -5,6 +5,10 @@
import java.util.List;
import java.util.UUID;
import javax.annotation.Nullable;
+
+import carpet.CarpetServer;
+import carpet.commands.lifetime.spawning.LiteralSpawningReason;
+import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.CreatureAttribute;
@@ -283,6 +286,12 @@
@@ -283,6 +287,12 @@
flag = false;
}

Expand All @@ -23,7 +24,7 @@
if (flag)
{
this.setFire(8);
@@ -368,6 +377,8 @@
@@ -368,6 +378,8 @@

if (!this.world.isAnyPlayerWithinRangeAt((double)i1, (double)j1, (double)k1, 7.0D) && this.world.checkNoEntityCollision(entityzombie, entityzombie.getBoundingBox()) && this.world.isCollisionBoxesEmpty(entityzombie, entityzombie.getBoundingBox()) && !this.world.containsAnyLiquid(entityzombie.getBoundingBox()))
{
Expand All @@ -32,3 +33,34 @@
this.world.spawnEntity(entityzombie);
entityzombie.setAttackTarget(entitylivingbase);
entityzombie.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null, (NBTTagCompound)null);
@@ -548,7 +560,10 @@

if (entityLivingData == null)
{
- entityLivingData = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F);
+ // TISCM spawnBabyProbably
+// entityLivingData = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F);
+ boolean forcedBabyTISCM = CarpetSettings.spawnBabyProbably > 0 && CarpetServer.rand.nextFloat() <= CarpetSettings.spawnBabyProbably;
+ entityLivingData = new EntityZombie.GroupData(this.world.rand.nextFloat() < 0.05F || forcedBabyTISCM);
}

if (entityLivingData instanceof EntityZombie.GroupData)
@@ -559,6 +574,9 @@
{
this.setChild(true);

+ // TISCM spawnJockeyProbably
+ boolean forcedJockeyTISCM = CarpetSettings.spawnJockeyProbably > 0 && CarpetServer.rand.nextFloat() <= CarpetSettings.spawnJockeyProbably;
+
if ((double)this.world.rand.nextFloat() < 0.05D)
{
List<EntityChicken> list = this.world.getEntitiesWithinAABB(EntityChicken.class, this.getBoundingBox().grow(5.0D, 3.0D, 5.0D), EntitySelectors.IS_STANDALONE);
@@ -570,7 +588,7 @@
this.startRiding(entitychicken);
}
}
- else if ((double)this.world.rand.nextFloat() < 0.05D)
+ else if ((double)this.world.rand.nextFloat() < 0.05D || forcedJockeyTISCM /* TISCM spawnJockeyProbably */)
{
EntityChicken entitychicken1 = new EntityChicken(this.world);
entitychicken1.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
24 changes: 24 additions & 0 deletions src/main/java/carpet/settings/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,30 @@ public String validate(CommandSource source, ParsedRule<String> currentRule, Str
)
public static boolean debugNbtQueryNoPermission = false;

@Rule(
desc = "When spawning mobs, if baby variant exists, spawn the baby variant with given probably",
extra = {
"Set it to -1 to disable the rule and use vanilla logic"
},
category = {CREATIVE},
options = {"-1", "0", "0.5", "1"},
strict = false
)
public static double spawnBabyProbably = -1;

@Rule(
desc = "When spawning mobs, if jockey variant exists, spawn the jockey variant with given probably",
extra = {
"Affected jockeys: chicken jockey, spider jockey, strider jockey",
"For striders, the spawn ratio between zombified piglin and baby strider is still 1:3",
"Set it to -1 to disable the rule and use vanilla logic"
},
category = {CREATIVE},
options = {"-1", "0", "0.5", "1"},
strict = false
)
public static double spawnJockeyProbably = -1;


// /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$
//|__ $$__/|_ $$_/ /$$__ $$ /$$__ $$| $$$ /$$$
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/carpet/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ rule:
'1': 将其设为0以将所有位于你建筑上的烦人的雪片融化
'2': 将其设为与防止降雪的最小亮度等级(12)来方便地测试你的建筑是否能借助亮度来防降雪
'3': 你可以修改游戏规则randomTickSpeed来加速雪的融化,也可以修改地毯规则chunkTickSpeed来加速降雪的过程
spawnBabyProbably:
name: 生成幼年生物概率
desc: 调整刷怪时生成幼年生物变种的概率
extra:
'0': 将其设为-1以禁用本规则并使用原版逻辑
spawnJockeyProbably:
name: 生成骑手概率
desc: 调整刷怪时生成骑手变种的概率
extra:
'0': '影响的骑手类型: 鸡骑士、蜘蛛骑士、炽足兽骑手'
'1': '对于炽足兽,生成僵尸猪灵、幼年炽足兽的概率比将保持1:3'
'2': 将其设为-1以禁用本规则并使用原版逻辑
structureBlockDoNotPreserveFluid:
name: 结构方块不保留流体
desc: 结构方块在放置含水方块时,不保留已存在的流体
Expand Down

0 comments on commit 00e90c6

Please sign in to comment.