Skip to content

Commit

Permalink
✅ 添加strongLeash规则 #120
Browse files Browse the repository at this point in the history
  • Loading branch information
1024-byteeeee committed Aug 22, 2024
1 parent dba1182 commit 90fbf2d
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/club/mcams/carpet/AmsServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ public class AmsServerSettings {
@Rule(categories = {AMS, FEATURE, BUGFIX})
public static boolean fakePlayerInteractLikeClient = false;

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

/*
* 区块加载规则
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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

import club.mcams.carpet.utils.compat.DummyInterface;

import org.spongepowered.asm.mixin.Mixin;

import top.byteeeee.annotationtoolbox.annotation.GameVersion;

@GameVersion(version = "Minecraft >= 1.21.1")
@Mixin(DummyInterface.class)
public interface LeashableMixin {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.strongLeash;

import club.mcams.carpet.AmsServerSettings;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import net.minecraft.entity.mob.PathAwareEntity;

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

import top.byteeeee.annotationtoolbox.annotation.GameVersion;

@GameVersion(version = "Minecraft < 1.21.1")
@Mixin(PathAwareEntity.class)
public abstract class PathAwareEntityMixin {
@ModifyExpressionValue(
method = "updateLeash",
at = @At(
value = "CONSTANT",
args = "floatValue=10.0F"
),
require = 1
)
private float modifyMaxLeashDetachDistance(float original) {
return AmsServerSettings.strongLeash ? Math.max(original, Float.MAX_VALUE) : original;
}
}
2 changes: 2 additions & 0 deletions src/main/resources/amscarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
"rule.softBlock.AbstractBlockMixin",
"rule.softBlock.AbstractBlockStateInvoker",
"rule.stackableDiscount.VillageGossipTypeAccessor",
"rule.strongLeash.LeashableMixin",
"rule.strongLeash.PathAwareEntityMixin",
"rule.superBow.EnchantmentMixin",
"rule.superBow.InfinityEnchantmentMixin",
"rule.undyingCoral.CoralBlockBlockMixin",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/carpetamsaddition/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ carpetamsaddition:
'0': 'Requires client support'
fakePlayerInteractLikeClient:
desc: Fix some cases that fake player interact differently from the client
strongLeash:
desc: The leash will not break due to excessive distance

# 计划刻催熟规则:
scheduledRandomTickCactus:
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,9 @@ carpetamsaddition:
fakePlayerInteractLikeClient:
name: 假人交互同步客户端行为
desc: 修复几个假人和盔甲架、矿车、船在特定情况下与客户端相应行为结果不一样的问题
strongLeash:
name: 强力拴绳
desc: 使拴绳不会因为距离过远而断裂

# 计划刻催熟规则:
scheduledRandomTickCactus:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.strongLeash;

import club.mcams.carpet.AmsServerSettings;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;

import net.minecraft.entity.Leashable;

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

import top.byteeeee.annotationtoolbox.annotation.GameVersion;

@GameVersion(version = "Minecraft >= 1.21.1")
@Mixin(Leashable.class)
public interface LeashableMixin {
@ModifyExpressionValue(
method = "tickLeash",
at = @At(
value = "CONSTANT",
args = "doubleValue=10.0F"
),
require = 1
)
private static double modifyMaxLeashDetachDistance(double original) {
return AmsServerSettings.strongLeash ? Math.max(original, Double.MAX_VALUE) : original;
}
}
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
*/

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

import club.mcams.carpet.utils.compat.DummyClass;

import org.spongepowered.asm.mixin.Mixin;

import top.byteeeee.annotationtoolbox.annotation.GameVersion;

@GameVersion(version = "Minecraft < 1.21.1")
@Mixin(DummyClass.class)
public abstract class PathAwareEntityMixin {}

0 comments on commit 90fbf2d

Please sign in to comment.