Skip to content

Commit

Permalink
✅ 新增规则fasterMovementController
Browse files Browse the repository at this point in the history
  • Loading branch information
1024-byteeeee committed Nov 15, 2023
1 parent 4baa113 commit 65e66e1
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
12 changes: 11 additions & 1 deletion src/main/java/club/mcams/carpet/AmsServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,14 @@ public class AmsServerSettings {
public static boolean enderManTeleportRandomlyDisabled = false;

@Rule(
options = {"VANILLA", "Ⅰ", "Ⅱ", "Ⅲ"},
options = {"VANILLA", "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ"},
categories = {AMS, FEATURE, EXPERIMENTAL}
)
public static String fasterMovement = "VANILLA";

@Rule(categories = {AMS, FEATURE, EXPERIMENTAL})
public static fasterMovementDimension fasterMovementController = fasterMovementDimension.ALL;

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

Expand Down Expand Up @@ -304,4 +307,11 @@ public enum blueSkullProbability {
SURELY,
NEVER
}

public enum fasterMovementDimension {
OVERWORLD,
NETHER,
END,
ALL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import club.mcams.carpet.AmsServerSettings;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -35,12 +36,25 @@
public abstract class PlayerEntityMixin {
@Inject(method = "getMovementSpeed", at = @At("HEAD"), cancellable = true)
public void getMovementSpeed(CallbackInfoReturnable<Float> cir) {
if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅰ")) {
cir.setReturnValue(0.2F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅱ")) {
cir.setReturnValue(0.3F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅲ")) {
cir.setReturnValue(0.4F);
PlayerEntity player = (PlayerEntity)(Object)this;
World world = player.getEntityWorld();
if (
(AmsServerSettings.fasterMovementController == AmsServerSettings.fasterMovementDimension.END && world.getRegistryKey() == World.END) ||
(AmsServerSettings.fasterMovementController == AmsServerSettings.fasterMovementDimension.NETHER && world.getRegistryKey() == World.NETHER) ||
(AmsServerSettings.fasterMovementController == AmsServerSettings.fasterMovementDimension.OVERWORLD && world.getRegistryKey() == World.OVERWORLD) ||
(AmsServerSettings.fasterMovementController == AmsServerSettings.fasterMovementDimension.ALL)
) {
if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅰ")) {
cir.setReturnValue(0.2F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅱ")) {
cir.setReturnValue(0.3F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅲ")) {
cir.setReturnValue(0.4F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅳ")) {
cir.setReturnValue(0.5F);
} else if (Objects.equals(AmsServerSettings.fasterMovement, "Ⅴ")) {
cir.setReturnValue(0.6F);
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/amscarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"rule.largeEnderChest.EnderChestBlockMixin",
"rule.largeEnderChest.PlayerEntityMixin",
"rule.largeEnderChest.SimpleInventoryAccessor",
"rule.largeShulkerBox.ShulkerBoxBlockMixin",
"rule.movableBlocks.PistonBlockMixin",
"rule.netherWaterPlacement.DimensionTypeMixin",
"rule.noCakeEating.CakeBlockMixin",
Expand Down
17 changes: 11 additions & 6 deletions src/main/resources/assets/carpetamsaddition/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ carpetamsaddition:
desc: Random teleportation by EnderMan is prohibited
fasterMovement:
name: fasterMovement
desc: Three gears are provided to allow players to move faster
desc: Five gears are provided to allow players to move faster
extra:
'': '[Ⅰ]'
'': '[Ⅱ]'
'': '[Ⅲ]'
'VANILLA': '[VANILLA]'
'0': You can use fasterMovementController rule to control in which dimensions this rule is effective. By default, it is effective in all dimensions.
fasterMovementController:
name: fasterMovementController
desc: Used to control in which dimensions fasterMovement rule is effective.
extra:
'0': '[overworld] - Only effective in the Overworld'
'1': '[nether] - Only effective in the Nether'
'2': '[end] - Only effective in the End'
'3': '[all] - Effective in all dimensions'
easyWitherSkeletonSkullDrop:
name: easyWitherSkeletonSkullDrop
desc: 100% Wither Skeleton Skull Drop
Expand Down Expand Up @@ -240,7 +245,7 @@ carpetamsaddition:
name: movableAnvil
desc: Makes anvil movable
movableSculkCatalyst:
name: movableAnvil
name: movableSculkCatalyst
desc: Makes sculk_catalyst movable
movableSculkSensor:
name: movableSculkSensor
Expand Down
15 changes: 10 additions & 5 deletions src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ carpetamsaddition:
desc: 禁止末影人随机传送
fasterMovement:
name: 快速移动
desc: 提供了三个挡位让玩家移动速度变快
desc: 提供了五个挡位让玩家移动速度变快
extra:
'': '[Ⅰ]'
'': '[Ⅱ]'
'': '[Ⅲ]'
'VANILLA': '[VANILLA]'
'0': 你可以使用fasterMovementController规则来控制该规则在哪个维度生效,默认所有维度生效
fasterMovementController:
name: 快速移动规则控制器
desc: 用于控制快速移动规则在那个维度生效
extra:
'0': '[overworld] - 只在主世界生效'
'1': '[nether] - 只在地狱生效'
'2': '[end] - 只在末地生效'
'3': '[all] - 所有维度生效'
easyWitherSkeletonSkullDrop:
name: 轻松掉落凋零骷髅头
desc: 击杀凋零骷髅会百分百掉落凋零骷髅头
Expand Down

0 comments on commit 65e66e1

Please sign in to comment.