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 need to run a command type "/summon ..." from right click item event.

 

I had a look to net.minecraft.command.CommandBase and net.minecraft.tileentity.TileEntityCommandBlock library but nothing to do...

 

Can someone help me?

 

thx

  • Author

thanks for the quick reply,

 

but it says "You do not have permission to use this command". I'm in creative mode with option "allow cheats" ON ... What's up?

 

PS

The command is: "/summon LightningBolt ~1 ~1 ~1"

  • Author

package com.sapphire.items;

 

import com.sapphire.main.mainRegistry;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.server.MinecraftServer;

import net.minecraft.world.World;

import net.minecraft.entity.player.EntityPlayer;

 

public class sapphireIngot extends Item{

 

public sapphireIngot(){

super();

this.setCreativeTab(SapphireItems.sapphireTab);

this.setMaxStackSize(1);

}

 

@SideOnly(Side.CLIENT)

public void registerIcons(IIconRegister reg){

this.itemIcon = reg.registerIcon("sapphire:sapphire");

}

 

  @Override

  public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)

  {

  //String var1 = "/summon LightningBolt ~1 ~1 ~1";

  String var1 = "/summon Wolf ~1 ~1 ~1";

  MinecraftServer.getServer().getCommandManager().executeCommand(player, var1);

  player.playSound("mob.wolf.death", 1.0F, 1.0F);

 

  return itemStack;

  }

 

}

 

Instead trying summon the wolf it works but says however "not permission" ... o_O

  • Author

Trying this works only with WOLF but LightingBolt wont works not even manually:

 

 

 

      if (!world.isRemote)

      {

          int var55 = (int)(player.posX) + 1;

          int var66 = (int)(player.posY) + 1;

          int var77 = (int)(player.posZ);

         

      String var1 = "/summon LightningBolt ~0 ~1 ~0";

      MinecraftServer.getServer().getCommandManager().executeCommand(player, var1);

  String var2 = "/summon Wolf ~0 ~1 ~0";

  MinecraftServer.getServer().getCommandManager().executeCommand(player, var2);

 

      }

 

 

 

Any ideas?

if (!world.isRemote)
{
world.spawnEntityInWorld(new YourEntity(world));
}

 

One way to spawn entities. You will of course have to change YourEntity and its parameters to what you need. If you need to spawn it a specific coords you can do that as well.

if (!world.isRemote)
{
YourEntity entity = new YourEntity(world);
entity.setLocationAndAngles(x, y, z, 0, 0.0F);
world.spawnEntityInWorld(entity)
}

 

Note that EntityLightning can be a bit finicky. It has three extra parameters, all doubles. Can't say I remember what they mean.

An average guy who mods Minecraft. If you need help and are willing to use your brain, don't be afraid to ask.

 

Also, check out the Unofficial Minecraft Coder Pack (MCP) Prerelease Center for the latest from the MCP Team!

 

Was I helpful? Leave some karma/thanks! :)

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.