Jump to content

[1.7.10]How to run Minecraft IG Single player Commands in Forge


TarasTech

Recommended Posts

So I want to make a block that does a couple random things like drops an item, or changes the weather to rain, or kills the player, but i have no idea how to run the /weather command in forge, or the /kill. I really need help. Searched around the web for a while now... :-\

Link to comment
Share on other sites

Use

MinecraftServer.getServer

to get the

MinecraftServer

instance,

MinecraftServer#getCommandManager

to get the server's

ICommandManager

and

ICommandManager#executeCommand

to execute a command.

 

You'll need an

ICommandSender

that has permission to execute the command, either use the player or create your own implementation.

 

Only do this on the server.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Im Still kind of new to java. Heres the code that i want to modify. I cant figure out how to set up the code correctly for that. Plaus after i set up the code how do i run the command?

 

package com.TarasTech.mod;

 

import java.util.Random;

 

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import net.minecraft.server.MinecraftServer;

 

public class BlockRain extends Block {

 

protected BlockRain(Material material) {

super(material);

 

}

@Override

public boolean isOpaqueCube() {

return false;

}

public Item getItemDropped(int metadata, Random random, int fortune) {

int w = random.nextInt(6);

        if (w == 0)

        {

            return Testing.itemRaindrop;

        }

        if (w == 1)

        {

            return MinecraftServer.getServer().MinecraftServer#getCommandManager ;

        }

        if (w == 2)

        {

            return Testing.itemRaindrop;

        }

        if (w == 3)

        {

            return Testing.itemRaindrop;

        }

        if (w == 4)

        {

            return Testing.itemRaindrop;

        }

        else

        {

        return Testing.itemRaindrop;

        }

    }

}

 

 

Link to comment
Share on other sites

From the description of the Modder Support section:

This is the support section for those modding with Forge. Help with modding goes in here, however, please keep in mind that this is not a Java school. You are expected to have basic knowledge of Java before posting here.

 

Class.member

refers to a static method/field of

Class

called

member

,

Class#member

refers to an instance method/field.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Im really sorry I wasted your time. I guess I should go learn some more java before i try doing this.

 

Yes, yes you should.

 

This is the support section for those modding with Forge. Help with modding goes in here, however, please keep in mind that this is not a Java school. You are expected to have basic knowledge of Java before posting here.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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