From 00e90c66e1e76d9d58bcebf829220f69edc2ee6e Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Tue, 1 Oct 2024 23:33:02 +0800 Subject: [PATCH] Ported rule `spawnBabyProbably` and `spawnJockeyProbably` --- .../entity/monster/EntitySpider.java.patch | 24 ++++++++++++ .../entity/monster/EntityZombie.java.patch | 38 +++++++++++++++++-- .../java/carpet/settings/CarpetSettings.java | 24 ++++++++++++ .../resources/assets/carpet/lang/zh_cn.yml | 12 ++++++ 4 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 patches/net/minecraft/entity/monster/EntitySpider.java.patch diff --git a/patches/net/minecraft/entity/monster/EntitySpider.java.patch b/patches/net/minecraft/entity/monster/EntitySpider.java.patch new file mode 100644 index 00000000..16cb6baf --- /dev/null +++ b/patches/net/minecraft/entity/monster/EntitySpider.java.patch @@ -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); diff --git a/patches/net/minecraft/entity/monster/EntityZombie.java.patch b/patches/net/minecraft/entity/monster/EntityZombie.java.patch index 4dbc94c1..93d0f4ef 100644 --- a/patches/net/minecraft/entity/monster/EntityZombie.java.patch +++ b/patches/net/minecraft/entity/monster/EntityZombie.java.patch @@ -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; } @@ -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())) { @@ -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 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); diff --git a/src/main/java/carpet/settings/CarpetSettings.java b/src/main/java/carpet/settings/CarpetSettings.java index d59ba1ba..b3ae6b09 100644 --- a/src/main/java/carpet/settings/CarpetSettings.java +++ b/src/main/java/carpet/settings/CarpetSettings.java @@ -926,6 +926,30 @@ public String validate(CommandSource source, ParsedRule 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; + // /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ //|__ $$__/|_ $$_/ /$$__ $$ /$$__ $$| $$$ /$$$ diff --git a/src/main/resources/assets/carpet/lang/zh_cn.yml b/src/main/resources/assets/carpet/lang/zh_cn.yml index 71ef3f4d..4fb43d18 100644 --- a/src/main/resources/assets/carpet/lang/zh_cn.yml +++ b/src/main/resources/assets/carpet/lang/zh_cn.yml @@ -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: 结构方块在放置含水方块时,不保留已存在的流体