zedblade Posted November 1, 2014 Posted November 1, 2014 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 Quote
zedblade Posted November 1, 2014 Author Posted November 1, 2014 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" Quote
zedblade Posted November 1, 2014 Author Posted November 1, 2014 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 Quote
zedblade Posted November 1, 2014 Author Posted November 1, 2014 Trying this works only with WOLF but LightingBolt wont works not even manually: Reveal hidden contents 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? Quote
superninjaman45 Posted November 1, 2014 Posted November 1, 2014 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. Quote 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!
Recommended Posts
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.