diff --git a/src/main/java/club/mcams/carpet/AmsServerSettings.java b/src/main/java/club/mcams/carpet/AmsServerSettings.java index c84a9ab6..e52ae5c2 100644 --- a/src/main/java/club/mcams/carpet/AmsServerSettings.java +++ b/src/main/java/club/mcams/carpet/AmsServerSettings.java @@ -2,7 +2,7 @@ * This file is part of the Carpet AMS Addition project, licensed under the * GNU Lesser General Public License v3.0 * - * Copyright (C) 2023 A Minecraft Server and contributors + * 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 @@ -11,11 +11,11 @@ * * 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 + * 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 . + * along with Carpet AMS Addition. If not, see . */ package club.mcams.carpet; @@ -28,6 +28,9 @@ import club.mcams.carpet.validators.rule.commandPlayerChunkLoadController.MaxRangeValidator; import club.mcams.carpet.validators.rule.enhancedWorldEater.BlastResistanceValidator; import club.mcams.carpet.validators.rule.maxClientInteractionReachDistance.MaxClientInteractionReachDistanceValidator; +//#if MC>=12000 +//$$ import club.mcams.carpet.validators.rule.easyGetPitcherPod.CountValidator; +//#endif import club.mcams.carpet.settings.CraftingRule; import club.mcams.carpet.settings.Rule; @@ -80,9 +83,9 @@ public class AmsServerSettings { public static boolean safeFlight = false; @Rule( - options = {"none", "minecraft:bone_block", "minecraft:diamond_ore", "minecraft:magma_block"}, - categories = {AMS, FEATURE}, - strict = false + options = {"none", "minecraft:bone_block", "minecraft:diamond_ore", "minecraft:magma_block"}, + categories = {AMS, FEATURE}, + strict = false ) public static String customBlockUpdateSuppressor = "none"; @@ -132,8 +135,8 @@ public class AmsServerSettings { public static boolean endermanTeleportRandomlyDisabled = false; @Rule( - options = {"VANILLA", "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ"}, - categories = {AMS, FEATURE, EXPERIMENTAL} + options = {"VANILLA", "�?", "�?", "�?", "�?", "�?"}, + categories = {AMS, FEATURE, EXPERIMENTAL} ) public static String fasterMovement = "VANILLA"; @@ -144,8 +147,8 @@ public class AmsServerSettings { public static boolean easyWitherSkeletonSkullDrop = false; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, FEATURE, SURVIVAL, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, FEATURE, SURVIVAL, COMMAND} ) public static String commandAnvilInteractionDisabled = "false"; @@ -174,36 +177,36 @@ public class AmsServerSettings { public static boolean largeShulkerBox = false; @Rule( - options = {"-1"}, - categories = {AMS, FEATURE, SURVIVAL}, - validators = MaxPlayerBlockInteractionRangeValidator.class, - strict = false + options = {"-1"}, + categories = {AMS, FEATURE, SURVIVAL}, + validators = MaxPlayerBlockInteractionRangeValidator.class, + strict = false ) public static double maxPlayerBlockInteractionRange = -1.0D; @Rule( - options = {"-1"}, - categories = {AMS, FEATURE, SURVIVAL}, - validators = MaxPlayerEntityInteractionRangeValidator.class, - strict = false + options = {"-1"}, + categories = {AMS, FEATURE, SURVIVAL}, + validators = MaxPlayerEntityInteractionRangeValidator.class, + strict = false ) public static double maxPlayerEntityInteractionRange = -1.0D; //#if MC<12005 @GameVersion(version = "Minecraft < 1.20.5", desc = "1.20.5后或许不再需要这个功能?") @Rule( - options = {"-1"}, - categories = {AMS, FEATURE, SURVIVAL}, - validators = MaxClientInteractionReachDistanceValidator.class, - strict = false + options = {"-1"}, + categories = {AMS, FEATURE, SURVIVAL}, + validators = MaxClientInteractionReachDistanceValidator.class, + strict = false ) public static double maxClientInteractionReachDistance = -1.0D; //#endif @Rule( - options = {"VANILLA", "minecraft:bedrock", "minecraft:bedrock,minecraft:obsidian"}, - categories = {AMS, FEATURE}, - strict = false + options = {"VANILLA", "minecraft:bedrock", "minecraft:bedrock,minecraft:obsidian"}, + categories = {AMS, FEATURE}, + strict = false ) public static String customMovableBlock = "VANILLA"; @@ -211,8 +214,8 @@ public class AmsServerSettings { public static boolean easyMaxLevelBeacon = false; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, FEATURE, SURVIVAL, TNT, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, FEATURE, SURVIVAL, TNT, COMMAND} ) public static String commandCustomBlockBlastResistance = "false"; @@ -220,10 +223,10 @@ public class AmsServerSettings { public static boolean regeneratingDragonEgg = false; @Rule( - options = {"-1"}, - categories = {AMS, SURVIVAL, FEATURE, TNT}, - validators = BlastResistanceValidator.class, - strict = false + options = {"-1"}, + categories = {AMS, SURVIVAL, FEATURE, TNT}, + validators = BlastResistanceValidator.class, + strict = false ) public static double enhancedWorldEater = -1.0D; @@ -249,8 +252,8 @@ public class AmsServerSettings { public static boolean useItemCooldownDisabled = false; @Rule( - options = {"0", "1", "2", "3", "4", "5"}, - categories = {AMS, FEATURE, SURVIVAL} + options = {"0", "1", "2", "3", "4", "5"}, + categories = {AMS, FEATURE, SURVIVAL} ) public static int flippinCactusSoundEffect = 0; @@ -267,9 +270,9 @@ public class AmsServerSettings { public static boolean easyMineDragonEgg = false; @Rule( - options = {"none", "apple", "stone"}, - categories = {AMS, FEATURE}, - strict = false + options = {"none", "apple", "stone"}, + categories = {AMS, FEATURE}, + strict = false ) public static String breedableParrots = "none"; @@ -291,20 +294,20 @@ public class AmsServerSettings { //#endif @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandHere = "false"; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandWhere = "false"; @Rule( - options = {"MainHandOnly", "NoPickUp", "false"}, - categories = {AMS, FEATURE, SURVIVAL} + options = {"MainHandOnly", "NoPickUp", "false"}, + categories = {AMS, FEATURE, SURVIVAL} ) public static String fakePlayerPickUpController = "false"; @@ -312,14 +315,14 @@ public class AmsServerSettings { public static boolean sneakToEatCake = false; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandPlayerLeader = "false"; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandPacketInternetGroper = "false"; @@ -333,8 +336,8 @@ public class AmsServerSettings { public static boolean welcomeMessage = false; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandGetSaveSize = "false"; @@ -359,23 +362,36 @@ public class AmsServerSettings { public static boolean foliageGenerateDisabled = false; @Rule( - options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, - categories = {AMS, COMMAND} + options = {"0", "1", "2", "3", "4", "ops", "true", "false"}, + categories = {AMS, COMMAND} ) public static String commandGetSystemInfo = "false"; + @Rule(categories = {AMS, FEATURE, SURVIVAL}) + public static boolean ironGolemNoDropFlower = false; + + //#if MC>=12000 + //$$ @Rule( + //$$ options = {"0"}, + //$$ categories = {AMS, FEATURE, SURVIVAL}, + //$$ validators = CountValidator.class, + //$$ strict = false + //$$ ) + //$$ public static int easyGetPitcherPod = 0; + //#endif + /* * 区块加载规则 */ @Rule( - options = {"bone_block", "wither_skeleton_skull", "note_block", "false"}, - categories = {AMS, FEATURE, AMS_CHUNKLOADER} + options = {"bone_block", "wither_skeleton_skull", "note_block", "false"}, + categories = {AMS, FEATURE, AMS_CHUNKLOADER} ) public static String noteBlockChunkLoader = "false"; @Rule( - options = {"bone_block", "bedrock", "all", "false"}, - categories = {AMS, FEATURE, AMS_CHUNKLOADER} + options = {"bone_block", "bedrock", "all", "false"}, + categories = {AMS, FEATURE, AMS_CHUNKLOADER} ) public static String pistonBlockChunkLoader = "false"; @@ -389,18 +405,18 @@ public class AmsServerSettings { public static boolean keepWorldTickUpdate = false; @Rule( - options = {"300"}, - categories = {AMS, FEATURE, AMS_CHUNKLOADER}, - validators = MaxTimeValidator.class, - strict = false + options = {"300"}, + categories = {AMS, FEATURE, AMS_CHUNKLOADER}, + validators = MaxTimeValidator.class, + strict = false ) public static int blockChunkLoaderTimeController = 300; @Rule( - options = {"3"}, - categories = {AMS, FEATURE, AMS_CHUNKLOADER}, - validators = MaxRangeValidator.class, - strict = false + options = {"3"}, + categories = {AMS, FEATURE, AMS_CHUNKLOADER}, + validators = MaxRangeValidator.class, + strict = false ) public static int blockChunkLoaderRangeController = 3; @@ -408,7 +424,7 @@ public class AmsServerSettings { public static boolean commandPlayerChunkLoadController = false; /* - * 合成表规则 + * 合成表规�? */ @SuppressWarnings("unused") @CraftingRule(recipes = "enchanted_golden_apples.json") diff --git a/src/main/java/club/mcams/carpet/mixin/rule/easyGetPitcherPod/BlockMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/easyGetPitcherPod/BlockMixin.java new file mode 100644 index 00000000..40f731e1 --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/easyGetPitcherPod/BlockMixin.java @@ -0,0 +1,69 @@ +/* + * 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.easyGetPitcherPod; + +import top.byteeeee.annotationtoolbox.annotation.GameVersion; + +//#if MC>=12000 +//$$ import club.mcams.carpet.AmsServerSettings; +//$$ import net.minecraft.block.Block; +//$$ import net.minecraft.block.BlockState; +//$$ import net.minecraft.block.Blocks; +//$$ import net.minecraft.entity.player.PlayerEntity; +//$$ import net.minecraft.item.ItemStack; +//$$ import net.minecraft.item.Items; +//$$ import net.minecraft.util.math.BlockPos; +//$$ import net.minecraft.world.World; +//$$ import org.spongepowered.asm.mixin.injection.At; +//$$ import org.spongepowered.asm.mixin.injection.Inject; +//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//$$ import java.util.Random; +//$$ import static net.minecraft.block.Block.dropStack; +//#else +import club.mcams.carpet.utils.compat.DummyClass; +//#endif + +import org.spongepowered.asm.mixin.Mixin; + +@GameVersion(version = "Minecraft >= 1.20") +//#if MC>=12000 +//$$ @Mixin(Block.class) +//$$ public abstract class BlockMixin { +//$$ @Inject(method = "onBreak", at = @At("HEAD")) +//$$ private void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable cir) { +//$$ if (AmsServerSettings.easyGetPitcherPod != 0 && state.getBlock().equals(Blocks.PITCHER_CROP)) { +//$$ if (!player.isCreative()) { +//$$ Random random = new Random(); +//$$ int minDrops = 2; +//$$ int maxDrops = AmsServerSettings.easyGetPitcherPod; +//$$ int dropCount = minDrops + random.nextInt(maxDrops - minDrops + 1); +//$$ for (int i = 0; i < dropCount; i++) { +//$$ ItemStack cakeStack = new ItemStack(Items.PITCHER_POD); +//$$ dropStack(world, pos, cakeStack); +//$$ } +//$$ } +//$$ } +//$$ } +//$$ } +//#else +@Mixin(DummyClass.class) +public abstract class BlockMixin {} +//#endif diff --git a/src/main/java/club/mcams/carpet/mixin/rule/ironGolemNoDropFlower/EntityMixin.java b/src/main/java/club/mcams/carpet/mixin/rule/ironGolemNoDropFlower/EntityMixin.java new file mode 100644 index 00000000..22df06c4 --- /dev/null +++ b/src/main/java/club/mcams/carpet/mixin/rule/ironGolemNoDropFlower/EntityMixin.java @@ -0,0 +1,55 @@ +/* + * 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.ironGolemNoDropFlower; + +import club.mcams.carpet.AmsServerSettings; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.ItemEntity; +import net.minecraft.entity.passive.IronGolemEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; + +import org.jetbrains.annotations.Nullable; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Entity.class) +public abstract class EntityMixin { + + @Shadow + @Nullable + public abstract ItemEntity dropStack(ItemStack stack); + + @Inject(method = "dropStack(Lnet/minecraft/item/ItemStack;)Lnet/minecraft/entity/ItemEntity;", at = @At("HEAD"), cancellable = true) + private void onDeath(ItemStack stack, CallbackInfoReturnable cir) { + if (AmsServerSettings.ironGolemNoDropFlower) { + Entity entity = (Entity)(Object)this; + if (entity instanceof IronGolemEntity && stack.getItem().equals(Items.POPPY)) { + cir.setReturnValue(dropStack(ItemStack.EMPTY)); + } + } + } +} diff --git a/src/main/java/club/mcams/carpet/validators/rule/easyGetPitcherPod/CountValidator.java b/src/main/java/club/mcams/carpet/validators/rule/easyGetPitcherPod/CountValidator.java new file mode 100644 index 00000000..29060c1d --- /dev/null +++ b/src/main/java/club/mcams/carpet/validators/rule/easyGetPitcherPod/CountValidator.java @@ -0,0 +1,46 @@ +/* + * 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.validators.rule.easyGetPitcherPod; + +import carpet.settings.ParsedRule; +import carpet.settings.Validator; + +import club.mcams.carpet.translations.Translator; + +import net.minecraft.server.command.ServerCommandSource; + +import top.byteeeee.annotationtoolbox.annotation.GameVersion; + +@SuppressWarnings("unused") +@GameVersion(version = "Minecraft >= 1.20") +public class CountValidator extends Validator { + private static final Translator translator = new Translator("validator.easyGetPitcherPod"); + + @Override + public Integer validate(ServerCommandSource serverCommandSource, ParsedRule parsedRule, Integer integer, String s) { + return ((integer >= 2 && integer <= 100) || integer == 0) ? integer : null; + } + + @Override + public String description() { + return translator.tr("value_range").getString(); + } +} diff --git a/src/main/resources/amscarpet.mixins.json b/src/main/resources/amscarpet.mixins.json index 95070e17..5fb43ba6 100644 --- a/src/main/resources/amscarpet.mixins.json +++ b/src/main/resources/amscarpet.mixins.json @@ -57,6 +57,7 @@ "rule.hopperSuctionDisabled.HopperBlockEntityMixin", "rule.infiniteDurability.ItemStackMixin", "rule.infiniteTrades.TradeOfferMixin", + "rule.ironGolemNoDropFlower.EntityMixin", "rule.keepWorldTickUpdate.ServerWorldMixin", "rule.kirinArm.PlayerEntityMixin", "rule.largeEnderChest.EnderChestBlockMixin", @@ -113,6 +114,7 @@ "rule.sneakToEditSign.AbstractSignBlockMixin", "rule.sneakToEditSign.SignBlockEntityMixin", "rule.superBow.InfinityEnchantmentMixin", + "rule.easyGetPitcherPod.BlockMixin", "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 8a3ef22c..9b1dc02f 100644 --- a/src/main/resources/assets/carpetamsaddition/lang/en_us.yml +++ b/src/main/resources/assets/carpetamsaddition/lang/en_us.yml @@ -81,6 +81,8 @@ carpetamsaddition: value_range: 'The value must be 1 - 300' blockChunkLoaderRangeController: value_range: 'The value must be 1 - 32' + easyGetPitcherPod: + value_range: 'The value must be 2 - 100 or 0' carpet_translations: category: @@ -312,6 +314,12 @@ carpetamsaddition: desc: The foliage will not generate in any way commandGetSystemInfo: desc: Use the "/getSystemInfo" command to get the system information of the server + ironGolemNoDropFlower: + desc: Iron golems will not drop flowers + easyGetPitcherPod: + desc: Players can harvest a random amount of pitcher pods by planting pitcher (The maximum quantity is customizable, while the minimum quantity is fixed at 2) + extra: + '0': 'The range of values: 2 - 100 or 0' # 计划刻催熟规则: scheduledRandomTickCactus: diff --git a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml index a358c732..34aa9895 100644 --- a/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml +++ b/src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml @@ -81,6 +81,8 @@ carpetamsaddition: value_range: '设定的值必须为 1 - 300' blockChunkLoaderRangeController: value_range: '设定的值必须为 1 - 32' + easyGetPitcherPod: + value_range: '设定的值必须为 1 - 100 或 0' carpet_translations: category: @@ -390,6 +392,14 @@ carpetamsaddition: commandGetSystemInfo: name: 获取系统信息 desc: 使用“/getSystemInfo”命令获取服务器的系统信息 + ironGolemNoDropFlower: + name: 铁傀儡不掉落花 + desc: 铁傀儡不会掉落花 + easyGetPitcherPod: + name: 轻松获取瓶子草荚果 + desc: 玩家可以通过种植瓶子草来收获随机数量的瓶子草荚果(其最大数量是自定义的,最小数量为固定2个) + extra: + '0': '允许设定的范围:2 - 100 或 0' # 计划刻催熟规则: scheduledRandomTickCactus: