Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want a command to be accessible by all players on a server as well as in single player. But I only manage to use the command if I'm an OP or allow a local server to use cheats. Could you help me out here?

 

The code in my command class:

	package com.ottoguy.pointsmodmain.command;
	import net.minecraft.block.Block;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.client.IClientCommand;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.server.permission.PermissionAPI;
	public class CommandChooseTeam extends CommandBase{
	    @Override
    public String getName() {
        // TODO Auto-generated method stub
        return "points";
    }
	    @Override
    public String getUsage(ICommandSender sender) {
        // TODO Auto-generated method stub
        return "Used for choosing team in points mod";
    }
    
    @Override
    public int getRequiredPermissionLevel()
    {
        return 0;
    }
    
    @Override
    public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
        World world = sender.getEntityWorld();
        
        if (world.isRemote) {
            System.out.println("Processing on the client side");
        }else {
            System.out.println("Processing on the server side");
            
            EntityPlayerMP player = getCommandSenderAsPlayer(sender);
            
            if(args[0].equals("red")) {
                int count = 1;
                
                while (count < 64) {
                    String itemName = "minecraft:red_flower";
                    ItemStack itemstack = new ItemStack(getItemByText(sender, "minecraft:red_flower"));
                    player.inventory.addItemStackToInventory(itemstack);
                    count++;
                }
                
            }else if(args[0].equals("blue")) {
                int count = 0;
                while (count < 12) {
                    String itemName = "minecraft:lapis_ore";
                    ItemStack itemstack = new ItemStack(getItemByText(sender, "minecraft:lapis_ore"));
                    player.inventory.addItemStackToInventory(itemstack);
                    count++;
                }
            }
        }
    }
}

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.