From 94228610ba9e65b7720d1b32c7668a8a10ca82e2 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:42:52 +0800 Subject: [PATCH 1/8] =?UTF-8?q?:globe=5Fwith=5Fmeridians:=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=BD=91=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- website/source/Rules/index.md | 72 ++++++++++++++++++++++++++ website/source/_posts/v2.49.0.md | 65 +++++++++++++++++++++++ website/source/en_us/Rules_en/index.md | 72 ++++++++++++++++++++++++++ 3 files changed, 209 insertions(+) create mode 100644 website/source/_posts/v2.49.0.md diff --git a/website/source/Rules/index.md b/website/source/Rules/index.md index 9adf9bd5..e9e1bab2 100644 --- a/website/source/Rules/index.md +++ b/website/source/Rules/index.md @@ -2168,6 +2168,60 @@ json位置: +- 分类: `AMS`, `FEATURE`, `SURVIVAL` + +## jeb羊掉落随机颜色羊毛(jebSheepDropRandomColorWool) + +当羊被命名为`jeb_`后,修剪羊毛会掉落随机颜色的羊毛。 + +- 类型: `boolean` + + + +- 默认值: `false` + + + +- 参考选项: `false`, `true` + + + +- 分类: `AMS`, `FEATURE`, `SURVIVAL` + +## 哭泣的黑曜石下界传送门(cryingObsidianNetherPortal) + +可以使用哭泣的黑曜石构建下界传送门。 + +- 类型: `boolean` + + + +- 默认值: `false` + + + +- 参考选项: `false`, `true` + + + +- 分类: `AMS`, `FEATURE`, `SURVIVAL` + +## 炉膛冶炼时间控制器(furnaceSmeltingTimeController) + +控制熔炉冶炼物品所需要的时间(单位:Tick)。 + +- 类型: `int` + + + +- 默认值: `-1` + + + +- 参考选项: `-1`, `-1 - ?` + + + - 分类: `AMS`, `FEATURE`, `SURVIVAL` ## 可合成附魔金苹果(craftableEnchantedGoldenApples) @@ -2298,4 +2352,22 @@ json位置: +- 分类: `AMS`, `SURVIVAL`, `CRAFTING` + +## 腐肉烧皮革(rottenFleshBurnedIntoLeather) + +腐肉可以在熔炉中烧成皮革。 + +- 类型: `boolean` + + + +- 默认值: `false` + + + +- 参考选项: `false`, `true` + + + - 分类: `AMS`, `SURVIVAL`, `CRAFTING` diff --git a/website/source/_posts/v2.49.0.md b/website/source/_posts/v2.49.0.md new file mode 100644 index 00000000..9c697334 --- /dev/null +++ b/website/source/_posts/v2.49.0.md @@ -0,0 +1,65 @@ +--- +title: Carpet AMS Addition v2.49.0 +date: 2024-9-30 17:22:13 +--- + +# 新规则 + +- **jeb羊掉落随机颜色羊毛(jebSheepDropRandomColorWool)** + + 当羊被命名为`jeb_`后,修剪羊毛会掉落随机颜色的羊毛。 [#143](https://github.com/Minecraft-AMS/Carpet-AMS-Addition/issues/143) + +- **哭泣的黑曜石下界传送门(cryingObsidianNetherPortal)** + + 可以使用哭泣的黑曜石构建下界传送门。 + +- **炉膛冶炼时间控制器(furnaceSmeltingTimeController)** + + 控制熔炉冶炼物品所需要的时间(单位:Tick)。 + +- **腐肉烧皮革(rottenFleshBurnedIntoLeather)** + + 腐肉可以在熔炉中烧成皮革。 + + + +# 修复 + +- 修复合成表系列规则切换为false后需要手动重载世界的BUG。 + + + +--- + + + +# New Rules + +- **jebSheepDropRandomColorWool** + + When a sheep is named `jeb_`, shearing its wool will drop wool of a random color. [#143](https://github.com/Minecraft-AMS/Carpet-AMS-Addition/issues/143) + +- **cryingObsidianNetherPortal** + + Nether portals can be constructed using crying obsidian. + +- **furnaceSmeltingTimeController** + + The time required to control the smelting of items in the furnace (unit: Tick). + +- **rottenFleshBurnedIntoLeather** + + Rotten flesh can be burned into leather in a furnace. + + + +# Fix + +- The bug where the world needs to be manually reloaded after switching the rules for the recipe series to false. + +  + +  + +***Translate into English from Chat-GPT*** + diff --git a/website/source/en_us/Rules_en/index.md b/website/source/en_us/Rules_en/index.md index 38d115f5..24eb5a6f 100644 --- a/website/source/en_us/Rules_en/index.md +++ b/website/source/en_us/Rules_en/index.md @@ -2187,6 +2187,60 @@ When a villager has not made a deal with the player before, each time the trade +- Categroies: `AMS`, `FEATURE`, `SURVIVAL` + +## jebSheepDropRandomColorWool + +When a sheep is named `jeb_`, shearing its wool will drop wool of a random color. + +- Type: `boolean` + + + +- Default: `false` + + + +- Suggested options: `false`, `true` + + + +- Categroies: `AMS`, `FEATURE`, `SURVIVAL` + +## cryingObsidianNetherPortal + +Nether portals can be constructed using crying obsidian. + +- Type: `boolean` + + + +- Default: `false` + + + +- Suggested options: `false`, `true` + + + +- Categroies: `AMS`, `FEATURE`, `SURVIVAL` + +## furnaceSmeltingTimeController + +The time required to control the smelting of items in the furnace (unit: Tick). + +- Type: `int` + + + +- Default: `-1` + + + +- Suggested options: `-1`, `1 - ?` + + + - Categroies: `AMS`, `FEATURE`, `SURVIVAL` ## craftableEnchantedGoldApple @@ -2315,4 +2369,22 @@ Use deepslate to crafted polished_blackstone_button in minecraft. +- Categroies: `AMS`, `SURVIVAL`, `CRAFTING` + +## rottenFleshBurnedIntoLeather + +Rotten flesh can be burned into leather in a furnace. + +- Type: `boolean` + + + +- Default: `false` + + + +- Suggested options: `false`, `true` + + + - Categroies: `AMS`, `SURVIVAL`, `CRAFTING` From 3aa9cbc944eafccab18b373be9f895445f2ddb00 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:43:37 +0800 Subject: [PATCH 2/8] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=90=88?= =?UTF-8?q?=E6=88=90=E8=A1=A8=E7=B3=BB=E5=88=97=E8=A7=84=E5=88=99=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E4=B8=BAfalse=E5=90=8E=E9=9C=80=E8=A6=81=E6=89=8B?= =?UTF-8?q?=E5=8A=A8=E9=87=8D=E8=BD=BD=E4=B8=96=E7=95=8C=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../carpet/observers/rule/recipeRule/RecipeRuleObserver.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/club/mcams/carpet/observers/rule/recipeRule/RecipeRuleObserver.java b/src/main/java/club/mcams/carpet/observers/rule/recipeRule/RecipeRuleObserver.java index 4005266a..e1261ff7 100644 --- a/src/main/java/club/mcams/carpet/observers/rule/recipeRule/RecipeRuleObserver.java +++ b/src/main/java/club/mcams/carpet/observers/rule/recipeRule/RecipeRuleObserver.java @@ -27,8 +27,6 @@ public class RecipeRuleObserver extends SimpleRuleObserver { @Override public void onValueChange(Boolean oldValue, Boolean newValue) { - if (newValue) { - RecipeRuleHelper.onValueChange(AmsServer.minecraftServer); - } + RecipeRuleHelper.onValueChange(AmsServer.minecraftServer); } } From bc2af45099851b6ca6f47c0670e304510201f6e0 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:44:29 +0800 Subject: [PATCH 3/8] =?UTF-8?q?:zap:=20=E4=BC=98=E5=8C=96recipe=20api?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=90=88=E6=88=90=E8=A1=A8=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ipeRegistry.java => AmsRecipeBuilder.java} | 119 ++++++++---------- .../recipe/template/ShapedRecipeTemplate.java | 4 +- .../template/ShapelessRecipeTemplate.java | 2 +- .../mcams/carpet/utils/ChainableHashMap.java | 30 +++++ .../mcams/carpet/utils/ChainableList.java | 30 +++++ .../NetherPortalMixin.java | 47 +++++++ 6 files changed, 162 insertions(+), 70 deletions(-) rename src/main/java/club/mcams/carpet/api/recipe/{AmsRecipeRegistry.java => AmsRecipeBuilder.java} (56%) create mode 100644 src/main/java/club/mcams/carpet/utils/ChainableHashMap.java create mode 100644 src/main/java/club/mcams/carpet/utils/ChainableList.java create mode 100644 versions/1.19.4/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java diff --git a/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeRegistry.java b/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeBuilder.java similarity index 56% rename from src/main/java/club/mcams/carpet/api/recipe/AmsRecipeRegistry.java rename to src/main/java/club/mcams/carpet/api/recipe/AmsRecipeBuilder.java index 8496371e..b12db5df 100644 --- a/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeRegistry.java +++ b/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeBuilder.java @@ -24,40 +24,40 @@ import club.mcams.carpet.AmsServerSettings; import club.mcams.carpet.api.recipe.template.ShapedRecipeTemplate; import club.mcams.carpet.api.recipe.template.ShapelessRecipeTemplate; +import club.mcams.carpet.api.recipe.template.SmeltingRecipeTemplate; +import club.mcams.carpet.utils.ChainableHashMap; +import club.mcams.carpet.utils.ChainableList; import club.mcams.carpet.utils.IdentifierUtil; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; -public class AmsRecipeRegistry { +public class AmsRecipeBuilder { private static final String MOD_ID = AmsServer.compactName; - private static final AmsRecipeRegistry instance = new AmsRecipeRegistry(); + private static final AmsRecipeBuilder instance = new AmsRecipeBuilder(); public List shapedRecipeList = new ArrayList<>(); public List shapelessRecipeList = new ArrayList<>(); + public List smeltingRecipeList = new ArrayList<>(); - public static AmsRecipeRegistry getInstance() { + public static AmsRecipeBuilder getInstance() { return instance; } - public void register() { - // Shaped Recipe List + public void build() { + /* + * 有序合成配方 + */ if (AmsServerSettings.craftableEnchantedGoldenApples) { - String[][] enchantedGoldenApplePattern = { + String[][] notchApplePattern = { {"#", "#", "#"}, {"#", "A", "#"}, {"#", "#", "#"} }; - Map enchantedGoldenAppleIngredients = new HashMap<>(); - enchantedGoldenAppleIngredients.put('#', "minecraft:gold_block"); - enchantedGoldenAppleIngredients.put('A', "minecraft:apple"); + ChainableHashMap notchAppleIngredients = new ChainableHashMap<>(); + notchAppleIngredients.cPut('#', "minecraft:gold_block").cPut('A', "minecraft:apple"); shapedRecipeList.add(new ShapedRecipeTemplate( IdentifierUtil.of(MOD_ID, "enchanted_golden_apple"), - enchantedGoldenApplePattern, - enchantedGoldenAppleIngredients, - "minecraft:enchanted_golden_apple", - 1 + notchApplePattern, notchAppleIngredients, "minecraft:enchanted_golden_apple", 1 )); } @@ -67,14 +67,11 @@ public void register() { {"#", "#", "#"}, {"#", "#", "#"} }; - Map boneBlockIngredients = new HashMap<>(); - boneBlockIngredients.put('#', "minecraft:bone"); + ChainableHashMap boneBlockIngredients = new ChainableHashMap<>(); + boneBlockIngredients.cPut('#', "minecraft:bone"); shapedRecipeList.add(new ShapedRecipeTemplate( IdentifierUtil.of(MOD_ID, "bone_block"), - bonePattern, - boneBlockIngredients, - "minecraft:bone_block", - 3 + bonePattern, boneBlockIngredients, "minecraft:bone_block", 3 )); } @@ -84,16 +81,11 @@ public void register() { {"S", "D", "X"}, {" ", "S", "X"} }; - Map dispenserIngredients = new HashMap<>(); - dispenserIngredients.put('D', "minecraft:dropper"); - dispenserIngredients.put('S', "minecraft:stick"); - dispenserIngredients.put('X', "minecraft:string"); + ChainableHashMap dispenserIngredients = new ChainableHashMap<>(); + dispenserIngredients.cPut('D', "minecraft:dropper").cPut('S', "minecraft:stick").cPut('X', "minecraft:string"); shapedRecipeList.add(new ShapedRecipeTemplate( IdentifierUtil.of(MOD_ID, "dispenser1"), - dispenserPattern, - dispenserIngredients, - "minecraft:dispenser", - 1 + dispenserPattern, dispenserIngredients, "minecraft:dispenser", 1 )); } @@ -103,17 +95,11 @@ public void register() { {"P", "*", "P"}, {"P", "L", "P"} }; - Map elytraIngredients = new HashMap<>(); - elytraIngredients.put('P', "minecraft:phantom_membrane"); - elytraIngredients.put('S', "minecraft:stick"); - elytraIngredients.put('*', "minecraft:saddle"); - elytraIngredients.put('L', "minecraft:string"); + ChainableHashMap elytraIngredients = new ChainableHashMap<>(); + elytraIngredients.cPut('P', "minecraft:phantom_membrane").cPut('S', "minecraft:stick").cPut('*', "minecraft:saddle").cPut('L', "minecraft:string"); shapedRecipeList.add(new ShapedRecipeTemplate( IdentifierUtil.of(MOD_ID, "elytra"), - elytraPattern, - elytraIngredients, - "minecraft:elytra", - 1 + elytraPattern, elytraIngredients, "minecraft:elytra", 1 )); } @@ -124,61 +110,60 @@ public void register() { {"R", "Q", "R"}, {"D", "D", "D"} }; - Map sculkSensorIngredients = new HashMap<>(); - sculkSensorIngredients.put('D', "minecraft:deepslate"); - sculkSensorIngredients.put('R', "minecraft:redstone"); - sculkSensorIngredients.put('Q', "minecraft:quartz"); + ChainableHashMap sculkSensorIngredients = new ChainableHashMap<>(); + sculkSensorIngredients.cPut('D', "minecraft:deepslate").cPut('R', "minecraft:redstone").cPut('Q', "minecraft:quartz"); shapedRecipeList.add(new ShapedRecipeTemplate( IdentifierUtil.of(MOD_ID, "sculk_sensor"), - sculkSensorPattern, - sculkSensorIngredients, - "minecraft:sculk_sensor", - 1 + sculkSensorPattern, sculkSensorIngredients, "minecraft:sculk_sensor", 1 )); } //#endif - // Shapeless Recipe List + /* + * 无序合成配方 + */ if (AmsServerSettings.betterCraftableDispenser) { - List dispenserIngredients = List.of( - "minecraft:bow", - "minecraft:dropper" - ); + ChainableList dispenserIngredients = new ChainableList<>(); + dispenserIngredients.cAdd("minecraft:bow").cAdd("minecraft:dropper"); shapelessRecipeList.add(new ShapelessRecipeTemplate( IdentifierUtil.of(MOD_ID, "dispenser2"), - dispenserIngredients, - "minecraft:dispenser", - 1 + dispenserIngredients, "minecraft:dispenser", 1 )); } //#if MC>=11700 && MC<12102 if (AmsServerSettings.craftableBundle) { - List bundleIngredients = List.of( - "minecraft:string", - "minecraft:leather" - ); + ChainableList bundleIngredients = new ChainableList<>(); + bundleIngredients.cAdd("minecraft:string").cAdd("minecraft:leather"); shapelessRecipeList.add(new ShapelessRecipeTemplate( IdentifierUtil.of(MOD_ID, "bundle"), - bundleIngredients, - "minecraft:bundle", - 1 + bundleIngredients, "minecraft:bundle", 1 )); } //#endif //#if MC>=11700 if (AmsServerSettings.betterCraftablePolishedBlackStoneButton) { - List polishedBlackstoneButtonIngredients = List.of( - "minecraft:deepslate" - ); + ChainableList polishedBlackstoneButtonIngredients = new ChainableList<>(); + polishedBlackstoneButtonIngredients.cAdd("minecraft:deepslate"); shapelessRecipeList.add(new ShapelessRecipeTemplate( IdentifierUtil.of(MOD_ID, "polished_blackstone_button"), - polishedBlackstoneButtonIngredients, - "minecraft:polished_blackstone_button", - 1 + polishedBlackstoneButtonIngredients, "minecraft:polished_blackstone_button", 1 )); } //#endif + + /* + * 熔炉烧炼配方 + */ + if (AmsServerSettings.rottenFleshBurnedIntoLeather) { + smeltingRecipeList.add( + new SmeltingRecipeTemplate( + IdentifierUtil.of(MOD_ID, "leather"), + "minecraft:rotten_flesh", "minecraft:leather", + 0.1F, 50 + ) + ); + } } } diff --git a/src/main/java/club/mcams/carpet/api/recipe/template/ShapedRecipeTemplate.java b/src/main/java/club/mcams/carpet/api/recipe/template/ShapedRecipeTemplate.java index 263bd987..19058154 100644 --- a/src/main/java/club/mcams/carpet/api/recipe/template/ShapedRecipeTemplate.java +++ b/src/main/java/club/mcams/carpet/api/recipe/template/ShapedRecipeTemplate.java @@ -28,7 +28,7 @@ import java.util.Map; -public class ShapedRecipeTemplate implements RecipeTemplateInterface{ +public class ShapedRecipeTemplate implements RecipeTemplateInterface { private final Identifier recipeId; private final String[][] pattern; private final Map ingredients; @@ -43,12 +43,12 @@ public ShapedRecipeTemplate(Identifier recipeId, String[][] pattern, Map ingredients; private final String resultItem; diff --git a/src/main/java/club/mcams/carpet/utils/ChainableHashMap.java b/src/main/java/club/mcams/carpet/utils/ChainableHashMap.java new file mode 100644 index 00000000..cd830d96 --- /dev/null +++ b/src/main/java/club/mcams/carpet/utils/ChainableHashMap.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.utils; + +import java.util.HashMap; + +public class ChainableHashMap extends HashMap { + public ChainableHashMap cPut(K key, V value) { + put(key, value); + return this; + } +} diff --git a/src/main/java/club/mcams/carpet/utils/ChainableList.java b/src/main/java/club/mcams/carpet/utils/ChainableList.java new file mode 100644 index 00000000..3a301e08 --- /dev/null +++ b/src/main/java/club/mcams/carpet/utils/ChainableList.java @@ -0,0 +1,30 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.utils; + +import java.util.ArrayList; + +public class ChainableList extends ArrayList { + public ChainableList cAdd(T element) { + add(element); + return this; + } +} \ No newline at end of file diff --git a/versions/1.19.4/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java b/versions/1.19.4/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java new file mode 100644 index 00000000..c8d47c40 --- /dev/null +++ b/versions/1.19.4/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java @@ -0,0 +1,47 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.mixin.rule.cryingObsidianNetherPortal; + +import club.mcams.carpet.AmsServerSettings; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.world.dimension.NetherPortal; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import top.byteeeee.annotationtoolbox.annotation.GameVersion; + +@GameVersion(version = "Minecraft >= 1.19") +@Mixin(NetherPortal.class) +public abstract class NetherPortalMixin { + @ModifyReturnValue(method = "method_30487", at = @At("RETURN")) + private static boolean acceptCryingObsidianCreateNetherPortal(boolean original, BlockState state) { + if (AmsServerSettings.cryingObsidianNetherPortal) { + return original || state.getBlock().equals(Blocks.CRYING_OBSIDIAN); + } else { + return original; + } + } +} From c0baaaf554c7fe01a48cc23b3fd5a63564d7b557 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:46:01 +0800 Subject: [PATCH 4/8] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=86=94=E7=82=89=E9=85=8D=E6=96=B9=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../carpet/api/recipe/AmsRecipeManager.java | 27 ++++--- .../template/SmeltingRecipeTemplate.java | 76 +++++++++++++++++++ 2 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 src/main/java/club/mcams/carpet/api/recipe/template/SmeltingRecipeTemplate.java diff --git a/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeManager.java b/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeManager.java index e2f37961..569b4060 100644 --- a/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeManager.java +++ b/src/main/java/club/mcams/carpet/api/recipe/AmsRecipeManager.java @@ -22,6 +22,7 @@ import club.mcams.carpet.api.recipe.template.ShapedRecipeTemplate; import club.mcams.carpet.api.recipe.template.ShapelessRecipeTemplate; +import club.mcams.carpet.api.recipe.template.SmeltingRecipeTemplate; import com.google.gson.JsonElement; //#if MC>=12102 @@ -41,10 +42,12 @@ public class AmsRecipeManager { private final List shapelessRecipes; private final List shapedRecipes; + private final List smeltingRecipes; - public AmsRecipeManager(List shapelessRecipes, List shapedRecipes) { + public AmsRecipeManager(List shapelessRecipes, List shapedRecipes, List smeltingRecipes) { this.shapelessRecipes = shapelessRecipes; this.shapedRecipes = shapedRecipes; + this.smeltingRecipes = smeltingRecipes; } public void registerRecipes( @@ -57,28 +60,24 @@ public void registerRecipes( //#if MC>=12102 //$$ Map recipeMap = new HashMap<>(); //#endif - for (ShapelessRecipeTemplate recipe : shapelessRecipes) { - recipe.addToRecipeMap(recipeMap); - } - for (ShapedRecipeTemplate recipe : shapedRecipes) { - recipe.addToRecipeMap(recipeMap); - } + shapelessRecipes.forEach(recipe -> recipe.addToRecipeMap(recipeMap)); + shapedRecipes.forEach(recipe -> recipe.addToRecipeMap(recipeMap)); + smeltingRecipes.forEach(recipe -> recipe.addToRecipeMap(recipeMap)); //#if MC>=12102 - //$$ for (Map.Entry entry : recipeMap.entrySet()) { - //$$ Identifier id = entry.getKey(); - //$$ JsonElement json = entry.getValue(); + //$$ recipeMap.forEach((id, json) -> { //$$ try { //$$ RecipeEntry recipeEntry = RecipeManager.deserialize(id, json.getAsJsonObject(), wrapperLookup); //$$ map.put(id, recipeEntry.value()); //$$ } catch (JsonParseException e) { //$$ AmsServer.LOGGER.warn("Failed to parse recipe: {}", id); //$$ } - //$$ } + //$$ }); //#endif } - public static void clearRecipeListMemory(AmsRecipeRegistry amsRecipeRegistry) { - amsRecipeRegistry.shapedRecipeList.clear(); - amsRecipeRegistry.shapelessRecipeList.clear(); + public static void clearRecipeListMemory(AmsRecipeBuilder amsRecipeBuilder) { + amsRecipeBuilder.shapedRecipeList.clear(); + amsRecipeBuilder.shapelessRecipeList.clear(); + amsRecipeBuilder.smeltingRecipeList.clear(); } } diff --git a/src/main/java/club/mcams/carpet/api/recipe/template/SmeltingRecipeTemplate.java b/src/main/java/club/mcams/carpet/api/recipe/template/SmeltingRecipeTemplate.java new file mode 100644 index 00000000..264a309c --- /dev/null +++ b/src/main/java/club/mcams/carpet/api/recipe/template/SmeltingRecipeTemplate.java @@ -0,0 +1,76 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.api.recipe.template; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +import net.minecraft.util.Identifier; + +import java.util.Map; + +public class SmeltingRecipeTemplate implements RecipeTemplateInterface { + private final Identifier recipeId; + private final String ingredient; + private final String resultItem; + private final float experience; + private final int cookingTime; + + public SmeltingRecipeTemplate(Identifier recipeId, String ingredient, String resultItem, float experience, int cookingTime) { + this.recipeId = recipeId; + this.ingredient = ingredient; + this.resultItem = resultItem; + this.experience = experience; + this.cookingTime = cookingTime; + } + + @Override + public JsonObject toJson() { + JsonObject recipeJson = new JsonObject(); + recipeJson.addProperty("type", "minecraft:smelting"); + + //#if MC<12102 + JsonObject ingredientJson = new JsonObject(); + ingredientJson.addProperty("item", ingredient); + recipeJson.add("ingredient", ingredientJson); + //#else + //$$ recipeJson.addProperty("ingredient", ingredient); + //#endif + + //#if MC<12005 + recipeJson.addProperty("result", resultItem); + //#else + //$$ JsonObject resultJson = new JsonObject(); + //$$ resultJson.addProperty(this.compatResultItemIdKey(), resultItem); + //$$ recipeJson.add("result", resultJson); + //#endif + + recipeJson.addProperty("experience", experience); + recipeJson.addProperty("cookingtime", cookingTime); + + return recipeJson; + } + + @Override + public void addToRecipeMap(Map recipeMap) { + recipeMap.put(recipeId, toJson()); + } +} From 6832179718a8f5a81c50b8a197c10798340f0b83 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:46:24 +0800 Subject: [PATCH 5/8] =?UTF-8?q?:zap:=20=E5=BA=94=E8=AF=A5=E7=94=A8HashSet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UpdateSuppressionException.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/club/mcams/carpet/helpers/rule/amsUpdateSuppressionCrashFix/UpdateSuppressionException.java b/src/main/java/club/mcams/carpet/helpers/rule/amsUpdateSuppressionCrashFix/UpdateSuppressionException.java index 3b5ff2d5..e0fbb136 100644 --- a/src/main/java/club/mcams/carpet/helpers/rule/amsUpdateSuppressionCrashFix/UpdateSuppressionException.java +++ b/src/main/java/club/mcams/carpet/helpers/rule/amsUpdateSuppressionCrashFix/UpdateSuppressionException.java @@ -20,12 +20,11 @@ package club.mcams.carpet.helpers.rule.amsUpdateSuppressionCrashFix; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; import java.util.function.Predicate; public class UpdateSuppressionException { - private static final List> exceptionPredicates = new ArrayList<>(); + private static final HashSet> exceptionPredicates = new HashSet<>(); public static boolean isUpdateSuppression(Throwable throwable) { return exceptionPredicates.stream().anyMatch(predicate -> predicate.test(throwable)); From 691d353dfdbcafaa4b428de03e1af75a3f9e2b54 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:46:53 +0800 Subject: [PATCH 6/8] =?UTF-8?q?:art:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/club/mcams/carpet/AmsServer.java | 35 ++++++++++++++++++- .../CustomCommandPermissionLevelConfig.java | 1 - .../rule/recipeRule/RecipeRuleHelper.java | 8 +++-- .../RecipeRule}/RecipeManagerMixin.java | 20 ++++------- .../rule/cakeBlockDropOnBreak/BlockMixin.java | 5 +-- 5 files changed, 47 insertions(+), 22 deletions(-) rename src/main/java/club/mcams/carpet/mixin/{hook => hooks/RecipeRule}/RecipeManagerMixin.java (78%) diff --git a/src/main/java/club/mcams/carpet/AmsServer.java b/src/main/java/club/mcams/carpet/AmsServer.java index b636376a..86847fa2 100644 --- a/src/main/java/club/mcams/carpet/AmsServer.java +++ b/src/main/java/club/mcams/carpet/AmsServer.java @@ -26,6 +26,8 @@ //$$ import carpet.network.ServerNetworkHandler; //#endif +import club.mcams.carpet.api.recipe.AmsRecipeManager; +import club.mcams.carpet.api.recipe.AmsRecipeBuilder; import club.mcams.carpet.commands.RegisterCommands; import club.mcams.carpet.commands.rule.commandPlayerLeader.LeaderCommandRegistry; import club.mcams.carpet.config.LoadConfigFromJson; @@ -41,6 +43,7 @@ import com.google.common.collect.Maps; +import com.google.gson.JsonElement; import com.mojang.brigadier.CommandDispatcher; import net.minecraft.server.MinecraftServer; @@ -49,6 +52,11 @@ //$$ import net.minecraft.command.CommandRegistryAccess; //#endif import net.minecraft.server.network.ServerPlayerEntity; +//#if MC>=12102 +//$$ import net.minecraft.recipe.Recipe; +//$$ import net.minecraft.registry.RegistryWrapper; +//#endif +import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -65,6 +73,10 @@ public class AmsServer implements CarpetExtension { public static final Logger LOGGER = LogManager.getLogger(fancyName); private static final AmsServer INSTANCE = new AmsServer(); + public static AmsServer getInstance() { + return INSTANCE; + } + public static void init() { CarpetServer.manageExtension(INSTANCE); AMSTranslations.loadTranslations(); @@ -89,7 +101,6 @@ public void registerLoggers() { AmsCarpetLoggerRegistry.registerLoggers(); } - @Override public void registerCommands( CommandDispatcher dispatcher @@ -105,6 +116,28 @@ public void registerCommands( ); } + public void registerCustomRecipes( + //#if MC>=12102 + //$$ Map> map, RegistryWrapper.WrapperLookup wrapperLookup + //#else + Map map + //#endif + ) { + AmsRecipeBuilder amsRecipeBuilder = AmsRecipeBuilder.getInstance(); + AmsRecipeManager amsRecipeManager = new AmsRecipeManager( + amsRecipeBuilder.shapelessRecipeList, + amsRecipeBuilder.shapedRecipeList, + amsRecipeBuilder.smeltingRecipeList + ); + AmsRecipeManager.clearRecipeListMemory(amsRecipeBuilder); + amsRecipeBuilder.build(); + //#if MC>=12102 + //$$ amsRecipeManager.registerRecipes(map, wrapperLookup); + //#else + amsRecipeManager.registerRecipes(map); + //#endif + } + @Override public void onPlayerLoggedIn(ServerPlayerEntity player) { //#if MC==12005 diff --git a/src/main/java/club/mcams/carpet/config/rule/commandCustomCommandPermissionLevel/CustomCommandPermissionLevelConfig.java b/src/main/java/club/mcams/carpet/config/rule/commandCustomCommandPermissionLevel/CustomCommandPermissionLevelConfig.java index e8bd4893..179ae02d 100644 --- a/src/main/java/club/mcams/carpet/config/rule/commandCustomCommandPermissionLevel/CustomCommandPermissionLevelConfig.java +++ b/src/main/java/club/mcams/carpet/config/rule/commandCustomCommandPermissionLevel/CustomCommandPermissionLevelConfig.java @@ -39,7 +39,6 @@ import java.util.HashMap; import java.util.Map; - public class CustomCommandPermissionLevelConfig { @SuppressWarnings("ReadWriteStringCanBeUsed") public static void loadFromJson(String configFilePath) { diff --git a/src/main/java/club/mcams/carpet/helpers/rule/recipeRule/RecipeRuleHelper.java b/src/main/java/club/mcams/carpet/helpers/rule/recipeRule/RecipeRuleHelper.java index 56bf3dbb..cb581a77 100644 --- a/src/main/java/club/mcams/carpet/helpers/rule/recipeRule/RecipeRuleHelper.java +++ b/src/main/java/club/mcams/carpet/helpers/rule/recipeRule/RecipeRuleHelper.java @@ -23,7 +23,7 @@ import club.mcams.carpet.AmsServer; import club.mcams.carpet.AmsServerSettings; import club.mcams.carpet.api.recipe.AmsRecipeManager; -import club.mcams.carpet.api.recipe.AmsRecipeRegistry; +import club.mcams.carpet.api.recipe.AmsRecipeBuilder; import club.mcams.carpet.settings.RecipeRule; import net.minecraft.recipe.Recipe; @@ -40,6 +40,7 @@ import java.util.Collection; public class RecipeRuleHelper { + @SuppressWarnings("ExtractMethodRecommender") public static void onPlayerLoggedIn(MinecraftServer server, ServerPlayerEntity player) { if (server != null && !server.isStopping() && !server.isStopped() && hasActiveRecipeRule()) { RecipeManager recipeManager = server.getRecipeManager(); @@ -68,10 +69,11 @@ public static void onPlayerLoggedIn(MinecraftServer server, ServerPlayerEntity p } } + @SuppressWarnings("ExtractMethodRecommender") public static void onValueChange(MinecraftServer server) { if (server != null && !server.isStopping() && !server.isStopped()) { - AmsRecipeManager.clearRecipeListMemory(AmsRecipeRegistry.getInstance()); - AmsRecipeRegistry.getInstance().register(); + AmsRecipeManager.clearRecipeListMemory(AmsRecipeBuilder.getInstance()); + AmsRecipeBuilder.getInstance().build(); server.execute(() -> { server.getCommandManager().execute(server.getCommandSource().withSilent(), "/reload"); RecipeManager recipeManager = server.getRecipeManager(); diff --git a/src/main/java/club/mcams/carpet/mixin/hook/RecipeManagerMixin.java b/src/main/java/club/mcams/carpet/mixin/hooks/RecipeRule/RecipeManagerMixin.java similarity index 78% rename from src/main/java/club/mcams/carpet/mixin/hook/RecipeManagerMixin.java rename to src/main/java/club/mcams/carpet/mixin/hooks/RecipeRule/RecipeManagerMixin.java index 1d9ec1f0..eb5de0ca 100644 --- a/src/main/java/club/mcams/carpet/mixin/hook/RecipeManagerMixin.java +++ b/src/main/java/club/mcams/carpet/mixin/hooks/RecipeRule/RecipeManagerMixin.java @@ -18,10 +18,9 @@ * along with Carpet AMS Addition. If not, see . */ -package club.mcams.carpet.mixin.hook; +package club.mcams.carpet.mixin.hooks.RecipeRule; -import club.mcams.carpet.api.recipe.AmsRecipeManager; -import club.mcams.carpet.api.recipe.AmsRecipeRegistry; +import club.mcams.carpet.AmsServer; import com.google.gson.JsonElement; @@ -50,7 +49,9 @@ public abstract class RecipeManagerMixin { //#if MC>=12102 //$$ @Unique //$$ private RegistryWrapper.WrapperLookup wrapperLookup; + //#endif + //#if MC>=12102 //$$ @Inject(method = "", at = @At("TAIL")) //$$ private void init(RegistryWrapper.WrapperLookup registries, CallbackInfo ci) { //$$ this.wrapperLookup = registries; @@ -58,7 +59,7 @@ public abstract class RecipeManagerMixin { //#endif @Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At("HEAD")) - private void addCustomRecipe( + private void registerCustomRecipes( //#if MC>=12102 //$$ Map> map, //#else @@ -66,17 +67,10 @@ private void addCustomRecipe( //#endif ResourceManager resourceManager, Profiler profiler, CallbackInfo ci ) { - AmsRecipeRegistry amsRecipeRegistry = AmsRecipeRegistry.getInstance(); - AmsRecipeManager amsRecipeManager = new AmsRecipeManager( - amsRecipeRegistry.shapelessRecipeList, - amsRecipeRegistry.shapedRecipeList - ); - AmsRecipeManager.clearRecipeListMemory(amsRecipeRegistry); - amsRecipeRegistry.register(); //#if MC>=12102 - //$$ amsRecipeManager.registerRecipes(map, this.wrapperLookup); + //$$ AmsServer.getInstance().registerCustomRecipes(map, this.wrapperLookup); //#else - amsRecipeManager.registerRecipes(map); + AmsServer.getInstance().registerCustomRecipes(map); //#endif } } diff --git a/src/main/java/club/mcams/carpet/mixin/rule/cakeBlockDropOnBreak/BlockMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/cakeBlockDropOnBreak/BlockMixin.java index a395fab5..35cc3267 100644 --- a/src/main/java/club/mcams/carpet/mixin/rule/cakeBlockDropOnBreak/BlockMixin.java +++ b/src/main/java/club/mcams/carpet/mixin/rule/cakeBlockDropOnBreak/BlockMixin.java @@ -47,10 +47,7 @@ public abstract class BlockMixin { @Inject(method = "onBreak", at = @At("HEAD")) private void onBreak( - World world, - BlockPos pos, - BlockState state, - PlayerEntity player, + World world, BlockPos pos, BlockState state, PlayerEntity player, //#if MC>12002 //$$ CallbackInfoReturnable cir //#else From f2f24cb20d21392a98e349c2f1d67f09cb8744c7 Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:47:29 +0800 Subject: [PATCH 7/8] =?UTF-8?q?:white=5Fcheck=5Fmark:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/mcams/carpet/AmsServerSettings.java | 16 ++- .../AreaHelperMixin.java | 47 ++++++++ .../NetherPortalMixin.java | 31 +++++ .../AbstractFurnaceBlockEntityMixin.java | 38 ++++++ .../SheepEntityMixin.java | 114 ++++++++++++++++++ src/main/resources/amscarpet.mixins.json | 6 +- .../assets/carpetamsaddition/lang/en_us.yml | 8 ++ .../assets/carpetamsaddition/lang/zh_cn.yml | 12 ++ 8 files changed, 269 insertions(+), 3 deletions(-) create mode 100644 src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/AreaHelperMixin.java create mode 100644 src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java create mode 100644 src/main/java/club/mcams/carpet/mixin/rule/furnaceSmeltingTimeController/AbstractFurnaceBlockEntityMixin.java create mode 100644 src/main/java/club/mcams/carpet/mixin/rule/jebSheepDropRandomColorWool/SheepEntityMixin.java diff --git a/src/main/java/club/mcams/carpet/AmsServerSettings.java b/src/main/java/club/mcams/carpet/AmsServerSettings.java index 787f7acb..c927ce43 100644 --- a/src/main/java/club/mcams/carpet/AmsServerSettings.java +++ b/src/main/java/club/mcams/carpet/AmsServerSettings.java @@ -20,8 +20,6 @@ package club.mcams.carpet; -import club.mcams.carpet.settings.RecipeRule; - import top.byteeeee.annotationtoolbox.annotation.GameVersion; //#if MC>=12002 @@ -43,6 +41,7 @@ import club.mcams.carpet.validators.rule.renewableNetherScrap.DropRateValidator; import club.mcams.carpet.settings.Rule; +import club.mcams.carpet.settings.RecipeRule; import static carpet.settings.RuleCategory.*; import static club.mcams.carpet.settings.AmsRuleCategory.*; @@ -513,6 +512,15 @@ public class AmsServerSettings { @Rule(categories = {AMS, FEATURE, SURVIVAL}) public static boolean easyRefreshTrades = false; + @Rule(categories = {AMS, FEATURE, SURVIVAL}) + public static boolean jebSheepDropRandomColorWool = false; + + @Rule(categories = {AMS, FEATURE, SURVIVAL}) + public static boolean cryingObsidianNetherPortal = false; + + @Rule(categories = {AMS, FEATURE, SURVIVAL}, strict = false) + public static int furnaceSmeltingTimeController = -1; + /* * 区块加载规则 */ @@ -596,6 +604,10 @@ public class AmsServerSettings { public static boolean betterCraftablePolishedBlackStoneButton = false; //#endif + @RecipeRule + @Rule(categories = {AMS, CRAFTING, SURVIVAL}, validators = RecipeRuleObserver.class) + public static boolean rottenFleshBurnedIntoLeather = false; + public enum blueSkullProbability { VANILLA, SURELY, diff --git a/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/AreaHelperMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/AreaHelperMixin.java new file mode 100644 index 00000000..5ff4370b --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/AreaHelperMixin.java @@ -0,0 +1,47 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.mixin.rule.cryingObsidianNetherPortal; + +import club.mcams.carpet.AmsServerSettings; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.world.dimension.AreaHelper; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import top.byteeeee.annotationtoolbox.annotation.GameVersion; + +@GameVersion(version = "Minecraft < 1.19") +@Mixin(AreaHelper.class) +public abstract class AreaHelperMixin { + @ModifyReturnValue(method = "method_30487", at = @At("RETURN")) + private static boolean acceptCryingObsidianCreateNetherPortal(boolean original, BlockState state) { + if (AmsServerSettings.cryingObsidianNetherPortal) { + return original || state.getBlock().equals(Blocks.CRYING_OBSIDIAN); + } else { + return original; + } + } +} diff --git a/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java new file mode 100644 index 00000000..b584261b --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/cryingObsidianNetherPortal/NetherPortalMixin.java @@ -0,0 +1,31 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.mixin.rule.cryingObsidianNetherPortal; + +import club.mcams.carpet.utils.compat.DummyClass; + +import org.spongepowered.asm.mixin.Mixin; + +import top.byteeeee.annotationtoolbox.annotation.GameVersion; + +@GameVersion(version = "Minecraft >= 1.19") +@Mixin(DummyClass.class) +public abstract class NetherPortalMixin {} diff --git a/src/main/java/club/mcams/carpet/mixin/rule/furnaceSmeltingTimeController/AbstractFurnaceBlockEntityMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/furnaceSmeltingTimeController/AbstractFurnaceBlockEntityMixin.java new file mode 100644 index 00000000..9fc843ad --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/furnaceSmeltingTimeController/AbstractFurnaceBlockEntityMixin.java @@ -0,0 +1,38 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.mixin.rule.furnaceSmeltingTimeController; + +import club.mcams.carpet.AmsServerSettings; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; + +import net.minecraft.block.entity.AbstractFurnaceBlockEntity; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(AbstractFurnaceBlockEntity.class) +public abstract class AbstractFurnaceBlockEntityMixin { + @ModifyReturnValue(method = "getCookTime", at = @At("RETURN")) + private static int setCookTime(int original) { + return AmsServerSettings.furnaceSmeltingTimeController != -1 ? AmsServerSettings.furnaceSmeltingTimeController : original; + } +} diff --git a/src/main/java/club/mcams/carpet/mixin/rule/jebSheepDropRandomColorWool/SheepEntityMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/jebSheepDropRandomColorWool/SheepEntityMixin.java new file mode 100644 index 00000000..d60549e0 --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/jebSheepDropRandomColorWool/SheepEntityMixin.java @@ -0,0 +1,114 @@ +/* + * This file is part of the Carpet AMS Addition project, licensed under the + * GNU Lesser General Public License v3.0 + * + * Copyright (C) 2024 A Minecraft Server and contributors + * + * Carpet AMS Addition is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Carpet AMS Addition is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Carpet AMS Addition. If not, see . + */ + +package club.mcams.carpet.mixin.rule.jebSheepDropRandomColorWool; + +import club.mcams.carpet.AmsServerSettings; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; +import net.minecraft.entity.passive.SheepEntity; +//#if MC>=12102 +//$$ import net.minecraft.item.DyeItem; +//$$ import net.minecraft.item.ItemStack; +//$$ import net.minecraft.loot.LootTable; +//$$ import net.minecraft.registry.RegistryKey; +//$$ import java.util.function.Consumer; +//#endif +import net.minecraft.util.DyeColor; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.Random; + +@Mixin(SheepEntity.class) +public abstract class SheepEntityMixin { + //#if MC>=12102 + //$$ @WrapOperation( + //$$ method = "sheared", + //$$ at = @At( + //$$ value = "INVOKE", + //$$ target = "Lnet/minecraft/entity/passive/SheepEntity;forEachShearedItem(Lnet/minecraft/registry/RegistryKey;Lnet/minecraft/item/ItemStack;Ljava/util/function/Consumer;)V" + //$$ ) + //$$ ) + //$$ private void redirectDropStack(SheepEntity sheepEntity, RegistryKey registryKey, ItemStack itemStack, Consumer consumer, Operation original) { + //$$ if (AmsServerSettings.jebSheepDropRandomColorWool && isJebSheep(sheepEntity)) { + //$$ Random random = new Random(); + //$$ for (int i = 0; i < 1 + random.nextInt(3); ++i) { + //$$ DyeColor randomColor = DyeColor.values()[random.nextInt(DyeColor.values().length)]; + //$$ Block coloredWoolBlock = getWoolBlockFromColor(randomColor); + //$$ consumer.accept(new ItemStack(coloredWoolBlock.asItem())); + //$$ } + //$$ } else { + //$$ original.call(sheepEntity, registryKey, itemStack, consumer); + //$$ } + //$$ } + //#else + @WrapOperation( + method = "sheared", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/passive/SheepEntity;getColor()Lnet/minecraft/util/DyeColor;" + ) + ) + private DyeColor randomColor(SheepEntity sheepEntity, Operation original) { + if (AmsServerSettings.jebSheepDropRandomColorWool && isJebSheep(sheepEntity)) { + Random random = new Random(); + return DyeColor.values()[random.nextInt(DyeColor.values().length)]; + } else { + return original.call(sheepEntity); + } + } + //#endif + + @Unique + private static boolean isJebSheep(SheepEntity sheepEntity) { + return sheepEntity.hasCustomName() && sheepEntity.getCustomName() != null && sheepEntity.getCustomName().getString().equals("jeb_"); + } + + @SuppressWarnings({"EnhancedSwitchMigration", "DuplicateBranchesInSwitch"}) + @Unique + private static Block getWoolBlockFromColor(DyeColor color) { + switch (color) { + case WHITE: return Blocks.WHITE_WOOL; + case ORANGE: return Blocks.ORANGE_WOOL; + case MAGENTA: return Blocks.MAGENTA_WOOL; + case LIGHT_BLUE: return Blocks.LIGHT_BLUE_WOOL; + case YELLOW: return Blocks.YELLOW_WOOL; + case LIME: return Blocks.LIME_WOOL; + case PINK: return Blocks.PINK_WOOL; + case GRAY: return Blocks.GRAY_WOOL; + case LIGHT_GRAY: return Blocks.LIGHT_GRAY_WOOL; + case CYAN: return Blocks.CYAN_WOOL; + case PURPLE: return Blocks.PURPLE_WOOL; + case BLUE: return Blocks.BLUE_WOOL; + case BROWN: return Blocks.BROWN_WOOL; + case GREEN: return Blocks.GREEN_WOOL; + case RED: return Blocks.RED_WOOL; + case BLACK: return Blocks.BLACK_WOOL; + default: return Blocks.WHITE_WOOL; + } + } +} diff --git a/src/main/resources/amscarpet.mixins.json b/src/main/resources/amscarpet.mixins.json index 08ce64a2..36524565 100644 --- a/src/main/resources/amscarpet.mixins.json +++ b/src/main/resources/amscarpet.mixins.json @@ -7,7 +7,7 @@ "carpet.CarpetServerMixin", "carpet.HUDControllerMixin", "carpet.SettingsManagerMixin", - "hook.RecipeManagerMixin", + "hooks.RecipeRule.RecipeManagerMixin", "rule.amsUpdateSuppressionCrashFix.ChainRestrictedNeighborUpdater_SixWayEntryMixin", "rule.amsUpdateSuppressionCrashFix.MinecraftServerMixin", "rule.amsUpdateSuppressionCrashFix.NeighborUpdaterMixin", @@ -34,6 +34,8 @@ "rule.creativeOneHitKill.EntityAccessorMixin", "rule.creativeOneHitKill.PlayerEntityMixin", "rule.creativeShulkerBoxDropsDisabled.ShulkerBoxBlockMixin", + "rule.cryingObsidianNetherPortal.AreaHelperMixin", + "rule.cryingObsidianNetherPortal.NetherPortalMixin", "rule.customBlockUpdateSuppressor.AbstractBlockMixin", "rule.easyCompost.ComposterBlockMixin", "rule.easyGetPitcherPod.BlockMixin", @@ -73,6 +75,7 @@ "rule.infiniteTrades.TradeOfferAccessor", "rule.infiniteTrades.TradeOfferMixin", "rule.ironGolemNoDropFlower.EntityMixin", + "rule.jebSheepDropRandomColorWool.SheepEntityMixin", "rule.keepWorldTickUpdate.ServerWorldMixin", "rule.kirinArm.PlayerEntityMixin", "rule.largeEnderChest.EnderChestBlockMixin", @@ -154,6 +157,7 @@ "rule.superleash.MobEntityMixin", "rule.superZombieDoctor.ZombieVillagerEntityAccessor", "rule.superZombieDoctor.ZombieVillagerEntityMixin", + "rule.furnaceSmeltingTimeController.AbstractFurnaceBlockEntityMixin", "rule.undyingCoral.CoralBlockBlockMixin", "rule.undyingCoral.CoralParentBlockMixin", "rule.useItemCooldownDisabled.ItemCooldownManagerMixin", diff --git a/src/main/resources/assets/carpetamsaddition/lang/en_us.yml b/src/main/resources/assets/carpetamsaddition/lang/en_us.yml index 0d19410d..b393640a 100644 --- a/src/main/resources/assets/carpetamsaddition/lang/en_us.yml +++ b/src/main/resources/assets/carpetamsaddition/lang/en_us.yml @@ -426,6 +426,12 @@ carpetamsaddition: desc: Full moon every day easyRefreshTrades: desc: When a villager has not made a deal with the player before, each time the trade screen is opened, the content sold by the villager will be refreshed + jebSheepDropRandomColorWool: + desc: When a sheep is named jeb_, shearing its wool will drop wool of a random color + cryingObsidianNetherPortal: + desc: Nether portals can be constructed using crying obsidian + furnaceSmeltingTimeController: + desc: 'The time required to control the smelting of items in the furnace (unit: Tick)' # 计划刻催熟规则: scheduledRandomTickCactus: @@ -503,3 +509,5 @@ carpetamsaddition: desc: Better craftable dispenser betterCraftablePolishedBlackStoneButton: desc: Use deepslate to crafted polished_blackstone_button in minecraft + rottenFleshBurnedIntoLeather: + desc: Rotten flesh can be burned into leather in a furnace diff --git a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml index 4736ccf0..d55ef996 100644 --- a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml +++ b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml @@ -529,6 +529,15 @@ carpetamsaddition: easyRefreshTrades: name: 轻松刷新交易 desc: 当村民之前没有与玩家达成过交易时,每次打开交易界面都会刷新村民出售的内容 + jebSheepDropRandomColorWool: + name: jeb羊掉落随机颜色羊毛 + desc: 当羊被命名为jeb_后,修剪羊毛会掉落随机颜色的羊毛 + cryingObsidianNetherPortal: + name: 哭泣的黑曜石下界传送门 + desc: 可以使用哭泣的黑曜石构建下界传送门 + furnaceSmeltingTimeController: + name: 炉膛冶炼时间控制器 + desc: 控制熔炉冶炼物品所需要的时间(单位:Tick) # 计划刻催熟规则: scheduledRandomTickCactus: @@ -627,3 +636,6 @@ carpetamsaddition: betterCraftablePolishedBlackStoneButton: name: 更好的合成磨制黑石按钮 desc: 使用深板岩来合成磨制黑石按钮 + rottenFleshBurnedIntoLeather: + name: 腐肉烧皮革 + desc: 腐肉可以在熔炉中烧成皮革 From 51711219b5dd8b4c45bd18ec52a251572d297cdc Mon Sep 17 00:00:00 2001 From: 1024_byteeeee <2270484921@qq.com> Date: Mon, 30 Sep 2024 17:47:47 +0800 Subject: [PATCH 8/8] :white_check_mark: v2.48.2 -> v2.49.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5ab94dbc..49714cee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ loader_version = 0.16.0 # Mod Properties mod_id = carpet-ams-addition mod_name = Carpet AMS Addition -mod_version = 2.48.2 +mod_version = 2.49.0 maven_group = carpetamsaddition archives_base_name = Carpet-AMS-Addition