Remove canClickRunClientCommand

This was added in 4675583e1c to handle
Forge on longer supporting RUN_COMMAND for client-side commands.
However, the mixins are still present on NF/1.20.4, so we don't need
this!
This commit is contained in:
Jonathan Coates 2024-03-23 15:36:13 +00:00
parent 7b9a156abc
commit c50d56d9fa
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
3 changed files with 1 additions and 19 deletions

View File

@ -5,7 +5,6 @@
package dan200.computercraft.shared.command.text; package dan200.computercraft.shared.command.text;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.platform.PlatformHelper;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.ClickEvent; import net.minecraft.network.chat.ClickEvent;
@ -56,10 +55,7 @@ public static Component link(MutableComponent component, String command, Compone
} }
public static Component clientLink(MutableComponent component, String command, Component toolTip) { public static Component clientLink(MutableComponent component, String command, Component toolTip) {
var event = PlatformHelper.get().canClickRunClientCommand() return link(component, new ClickEvent(ClickEvent.Action.RUN_COMMAND, command), toolTip);
? new ClickEvent(ClickEvent.Action.RUN_COMMAND, command)
: new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command);
return link(component, event, toolTip);
} }
public static Component link(Component component, ClickEvent click, Component toolTip) { public static Component link(Component component, ClickEvent click, Component toolTip) {

View File

@ -375,13 +375,4 @@ default double getReachDistance(Player player) {
* @see ServerPlayerGameMode#useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult) * @see ServerPlayerGameMode#useItemOn(ServerPlayer, Level, ItemStack, InteractionHand, BlockHitResult)
*/ */
InteractionResult useOn(ServerPlayer player, ItemStack stack, BlockHitResult hit, Predicate<BlockState> canUseBlock); InteractionResult useOn(ServerPlayer player, ItemStack stack, BlockHitResult hit, Predicate<BlockState> canUseBlock);
/**
* Whether {@link net.minecraft.network.chat.ClickEvent.Action#RUN_COMMAND} can be used to run client commands.
*
* @return Whether client commands can be triggered from chat components.
*/
default boolean canClickRunClientCommand() {
return true;
}
} }

View File

@ -312,11 +312,6 @@ public InteractionResult useOn(ServerPlayer player, ItemStack stack, BlockHitRes
return event.getUseItem() == Event.Result.DENY ? InteractionResult.PASS : stack.useOn(context); return event.getUseItem() == Event.Result.DENY ? InteractionResult.PASS : stack.useOn(context);
} }
@Override
public boolean canClickRunClientCommand() {
return false;
}
private record RegistrationHelperImpl<R>(DeferredRegister<R> registry) implements RegistrationHelper<R> { private record RegistrationHelperImpl<R>(DeferredRegister<R> registry) implements RegistrationHelper<R> {
@Override @Override
public <T extends R> RegistryEntry<T> register(String name, Supplier<T> create) { public <T extends R> RegistryEntry<T> register(String name, Supplier<T> create) {