Jump to content

Recommended Posts

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

Posted

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"

Posted

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

Posted

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?

Posted

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

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