Skip to content

Commit

Permalink
✅ 新增规则
Browse files Browse the repository at this point in the history
  • Loading branch information
1024-byteeeee committed Jan 7, 2025
1 parent 7cff996 commit 5732e4e
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 3 deletions.
28 changes: 28 additions & 0 deletions src/main/java/club/mcams/carpet/AmsServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,30 @@ public class AmsServerSettings {
//$$ public static boolean stringDupeReintroduced = false;
//#endif

@Rule(
options = "-1",
categories = {AMS, FEATURE, SURVIVAL},
strict = false
)
public static int witchRedstoneDustDropController = -1;

@Rule(
options = "-1",
categories = {AMS, FEATURE, SURVIVAL},
strict = false
)
public static int witchGlowstoneDustDropController = -1;

@Rule(
options = "-1.0",
categories = {AMS, FEATURE, SURVIVAL, TNT},
strict = false
)
public static double tntPowerController = -1.0D;

@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean meekEnderman = false;


/*
* 区块加载规则
Expand Down Expand Up @@ -639,4 +663,8 @@ public enum fasterMovementDimension {
END,
ALL
}

@SuppressWarnings("unused")
@Rule(categories = AMS)
public static boolean testRule = false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2025 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 <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.meekEnderman;

import club.mcams.carpet.AmsServerSettings;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;

import net.minecraft.entity.mob.EndermanEntity;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@SuppressWarnings("SimplifiableConditionalExpression")
@Mixin(EndermanEntity.class)
public abstract class EndermanEntityMixin {
@ModifyReturnValue(method = "isPlayerStaring", at = @At("RETURN"))
private boolean goodBaby(boolean original) {
return AmsServerSettings.meekEnderman ? false : original;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2025 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 <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.tntPowerController;

import club.mcams.carpet.AmsServerSettings;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import net.minecraft.entity.TntEntity;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(TntEntity.class)
public abstract class TntEntityMixin {
//#if MC>=12102
//$$ @ModifyExpressionValue(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At(value = "CONSTANT", args = "floatValue=4.0F"))
//#else
@ModifyExpressionValue(method = "explode", at = @At(value = "CONSTANT", args = "floatValue=4.0F"))
//#endif
private float modifyTntPower(float original) {
return AmsServerSettings.tntPowerController != -1.0D ? (float) AmsServerSettings.tntPowerController : original;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.witchRedstoneDustDropController_witchGlowstoneDustDropController;

import club.mcams.carpet.AmsServerSettings;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.WitchEntity;
//#if MC>=12102
//$$ import net.minecraft.server.world.ServerWorld;
//#endif
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
@Inject(method = "dropLoot", at = @At("TAIL"))
private void customRedstoneDustDrop(CallbackInfo ci) {
if (AmsServerSettings.witchRedstoneDustDropController != -1) {
LivingEntity livingEntity = (LivingEntity) (Object) this;
//#if MC>=12102
//$$ ServerWorld world = (ServerWorld) livingEntity.getEntityWorld();
//#endif
int redstoneCount = AmsServerSettings.witchRedstoneDustDropController;
compatWitchDropStack(
Items.REDSTONE, redstoneCount,
//#if MC>=12102
//$$ world,
//#endif
livingEntity
);
}
}

@Inject(method = "dropLoot", at = @At("TAIL"))
private void customGlowstoneDustDrop(CallbackInfo ci) {
if (AmsServerSettings.witchGlowstoneDustDropController != -1) {
LivingEntity livingEntity = (LivingEntity) (Object) this;
//#if MC>=12102
//$$ ServerWorld world = (ServerWorld) livingEntity.getEntityWorld();
//#endif
int glowstoneCount = AmsServerSettings.witchGlowstoneDustDropController;
compatWitchDropStack(
Items.GLOWSTONE_DUST, glowstoneCount,
//#if MC>=12102
//$$ world,
//#endif
livingEntity
);
}
}

@Unique
private static void compatWitchDropStack(
Item item, int count,
//#if MC>=12102
//$$ ServerWorld world,
//#endif
LivingEntity livingEntity
) {
if (livingEntity instanceof WitchEntity) {
livingEntity.dropStack(
//#if MC>=12102
//$$ world,
//#endif
new ItemStack(item, count)
);
}
}
}
11 changes: 8 additions & 3 deletions src/main/resources/amscarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
"rule.amsUpdateSuppressionCrashFix.MinecraftServerMixin",
"rule.amsUpdateSuppressionCrashFix.NeighborUpdaterMixin",
"rule.amsUpdateSuppressionCrashFix.WorldMixin",
"rule.antiFireTotem_itemAntiExplosion.ItemEntityInvoker",
"rule.antiFireTotem_itemAntiExplosion.ItemEntityMixin",
"rule.bambooCollisionBoxDisabled.BambooBlockMixin",
"rule.bambooModelNoOffset.AbstractBlockStateInvoker",
"rule.bambooModelNoOffset.BambooBlockMixin",
"rule.blockChunkLoader.BellBlockMixin",
"rule.blockChunkLoader.NoteBlockMixin",
Expand Down Expand Up @@ -94,6 +96,7 @@
"rule.maxPlayerInteractionRange.PlayerEntityMixin",
"rule.maxPlayerInteractionRange.ServerPlayerInteractionManagerMixin",
"rule.maxPlayerInteractionRange.ServerPlayNetworkHandlerMixin",
"rule.meekEnderman.EndermanEntityMixin",
"rule.mitePearl.EnderPearlEntityMixin",
"rule.netherWaterPlacement.DimensionTypeMixin",
"rule.noCakeEating.CakeBlockMixin",
Expand Down Expand Up @@ -152,18 +155,20 @@
"rule.softBlock.AbstractBlockMixin",
"rule.softBlock.AbstractBlockStateInvoker",
"rule.stackableDiscount.VillageGossipTypeAccessor",
"rule.stringDupeReintroduced.TripwireHookBlockMixin",
"rule.strongLeash.LeashableMixin",
"rule.strongLeash.PathAwareEntityMixin",
"rule.superBow.EnchantmentMixin",
"rule.superBow.InfinityEnchantmentMixin",
"rule.superleash.MerchantEntityMixin",
"rule.superleash.MobEntityMixin",
"rule.superLeash.MerchantEntityMixin",
"rule.superLeash.MobEntityMixin",
"rule.superZombieDoctor.ZombieVillagerEntityAccessor",
"rule.superZombieDoctor.ZombieVillagerEntityMixin",
"rule.stringDupeReintroduced.TripwireHookBlockMixin",
"rule.tntPowerController.TntEntityMixin",
"rule.undyingCoral.CoralBlockBlockMixin",
"rule.undyingCoral.CoralParentBlockMixin",
"rule.useItemCooldownDisabled.ItemCooldownManagerMixin",
"rule.witchRedstoneDustDropController_witchGlowstoneDustDropController.LivingEntityMixin",
"setting.ParsedRuleAccessor",
"setting.SettingsManagerAccessor",
"translations.ClientSettingsC2SPacketAccessor",
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/assets/carpetamsaddition/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ carpetamsaddition:
desc: Use "/getHeldItemID" command to get item ID of the player main hand item
stringDupeReintroduced:
desc: Reintroduced the string dupe feature, you can use this rule to continue using the string farm
witchRedstoneDustDropController:
desc: Set the guaranteed minimum amount of Redstone Dust dropped by witches
witchGlowstoneDustDropController:
desc: Set the guaranteed minimum amount of Glowstone Dust dropped by witches
tntPowerController:
desc: Controls the explosive power of TNT, setting it to "-1" to disable the rule
meekEnderman:
desc: You can casually glance at endermen

# 计划刻催熟规则:
scheduledRandomTickCactus:
Expand Down Expand Up @@ -525,3 +533,7 @@ carpetamsaddition:
desc: Use deepslate to crafted polished_blackstone_button in minecraft
rottenFleshBurnedIntoLeather:
desc: Rotten flesh can be burned into leather in a furnace

# 测试用规则
testRule:
desc: Just for test
17 changes: 17 additions & 0 deletions src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,18 @@ carpetamsaddition:
stringDupeReintroduced:
name: 重新引入拌线骗特性
desc: 重新引入拌线骗特性,可以通过此规则来继续使用刷线机
witchRedstoneDustDropController:
name: 女巫红石粉掉落控制器
desc: 设置女巫掉落红石粉的保底数量
witchGlowstoneDustDropController:
name: 女巫萤石粉掉落控制器
desc: 设置女巫掉落萤石粉的保底数量
tntPowerController:
name: TNT威力控制器
desc: 控制TNT的爆炸威力,设置为"-1"禁用规则
meekEnderman:
name: 温顺的末影人
desc: 你可以随便瞅末影人

# 计划刻催熟规则:
scheduledRandomTickCactus:
Expand Down Expand Up @@ -657,3 +669,8 @@ carpetamsaddition:
rottenFleshBurnedIntoLeather:
name: 腐肉烧皮革
desc: 腐肉可以在熔炉中烧成皮革

# 测试用规则
testRule:
name: 测试用规则
desc: 仅用于测试,没有什么作用

0 comments on commit 5732e4e

Please sign in to comment.