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

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

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.

  • Author

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;

        }

    }

}

 

 

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.

  • Author

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

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.

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.