Posted August 8, 20232 yr This is what my code looks like and it works perfectly fine. package icelock.iceblocks.item.custom; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.debug.GameModeSwitcherScreen; import net.minecraft.client.sounds.SoundEngine; import net.minecraft.client.telemetry.TelemetryProperty; import net.minecraft.commands.*; import net.minecraft.commands.arguments.GameModeArgument; import net.minecraft.server.MinecraftServer; import net.minecraft.server.commands.GameModeCommand; import net.minecraft.server.commands.OpCommand; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.server.*; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.SoundType; import net.minecraft.world.phys.Vec3; import net.minecraftforge.common.ForgeConfig; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.server.console.TerminalHandler; import net.minecraft.commands.CommandSourceStack; public class Creative extends Item { public Creative(Properties pProperties) { super(pProperties); } @Override public InteractionResult useOn(UseOnContext pContext) { if (!pContext.getLevel().isClientSide){ Player player = pContext.getPlayer(); CommandSourceStack stack = pContext.getPlayer().getServer().createCommandSourceStack(); player.getServer().getCommands().performPrefixedCommand(stack,"gamemode creative"); } return InteractionResult.SUCCESS; }} just wondering if theres a way to make the result not output
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.