- /hat /sit:规则判断从 requires 移到 executes,命令总是显示(避免客户端读不到服务端规则值导致红字) & - MixinTrialSpawnerState:覆盖 tickAndGetNext 里全部 3 处 getTargetCooldownLength 调用(去掉 ordinal 限制)
This commit is contained in:
1 parent
bc472026f9
commit
d6eb433f65
3 files changed
+16
-8
No files matched your search
@@ -11,11 +11,14 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
public class HatCommand {
|
public class HatCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||||
dispatcher.register(Commands.literal("hat")
|
dispatcher.register(Commands.literal("hat")
|
||||||
.requires(CommandSourceStack::isPlayer)
|
|
||||||
.requires((commandSource) -> SLSCarpetSettings.canUseHatCommand)
|
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
|
if (!SLSCarpetSettings.canUseHatCommand) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ServerPlayer player = context.getSource().getPlayer();
|
ServerPlayer player = context.getSource().getPlayer();
|
||||||
assert player != null;
|
if (player == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ItemStack stack = player.getMainHandItem();
|
ItemStack stack = player.getMainHandItem();
|
||||||
ItemStack head = player.getItemBySlot(EquipmentSlot.HEAD);
|
ItemStack head = player.getItemBySlot(EquipmentSlot.HEAD);
|
||||||
player.setItemSlot(EquipmentSlot.HEAD, stack);
|
player.setItemSlot(EquipmentSlot.HEAD, stack);
|
||||||
|
|||||||
@@ -12,11 +12,14 @@ import net.minecraft.world.entity.decoration.ArmorStand;
|
|||||||
public class SitCommand {
|
public class SitCommand {
|
||||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||||
dispatcher.register(Commands.literal("sit")
|
dispatcher.register(Commands.literal("sit")
|
||||||
.requires(CommandSourceStack::isPlayer)
|
|
||||||
.requires((commandSource) -> SLSCarpetSettings.canUseSitCommand)
|
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
|
if (!SLSCarpetSettings.canUseSitCommand) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
ServerPlayer player = context.getSource().getPlayer();
|
ServerPlayer player = context.getSource().getPlayer();
|
||||||
assert player != null;
|
if (player == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (player.getVehicle() != null || !player.onGround()) { // 防止错误的坐下行为
|
if (player.getVehicle() != null || !player.onGround()) { // 防止错误的坐下行为
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+4
-2
@@ -10,15 +10,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||||||
|
|
||||||
@Mixin(TrialSpawnerState.class)
|
@Mixin(TrialSpawnerState.class)
|
||||||
public class MixinTrialSpawnerState {
|
public class MixinTrialSpawnerState {
|
||||||
|
// trialSpawnerCD:覆盖试炼刷怪笼的冷却长度。
|
||||||
|
// 新版 TrialSpawnerState.tickAndGetNext 里调用 TrialSpawner.getTargetCooldownLength() 三次,
|
||||||
|
// 不指定 ordinal 以覆盖全部调用。
|
||||||
@WrapOperation(
|
@WrapOperation(
|
||||||
method = "tickAndGetNext",
|
method = "tickAndGetNext",
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
ordinal = 0,
|
|
||||||
target = "Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawner;getTargetCooldownLength()I"
|
target = "Lnet/minecraft/world/level/block/entity/trialspawner/TrialSpawner;getTargetCooldownLength()I"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
private int tick(TrialSpawner instance, Operation<Integer> original) {
|
private int tick(TrialSpawner instance, Operation<Integer> original) {
|
||||||
if (SLSCarpetSettings.trialSpawnerCD < 0) {
|
if (SLSCarpetSettings.trialSpawnerCD < 0) {
|
||||||
return original.call(instance);
|
return original.call(instance);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user