Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Send message on item use
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Betterjakers

Send message on item use

By Betterjakers, May 30, 2016 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

Hello! I am trying to send a chat message when someone clicks on the item. Here is my code. I tried to add a message, but it did not work.

[embed=425,349]package mymod.items;

 

import java.awt.Event;

import java.util.Random;

 

import org.lwjgl.input.Keyboard;

 

import com.google.common.eventbus.Subscribe;

 

import mymod.Main;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import cpw.mods.fml.common.network.Player;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

 

public class MyItem extends Item {

 

   

    private String texturePath = "mymod:";

   

    public MyItem(int ItemID, String textureName)

    {

        super(ItemID);

        this.setUnlocalizedName(textureName);

        this.setCreativeTab(CreativeTabs.tabMaterials);

        texturePath += textureName;

    }

   

    public void onItemUse(EntityPlayer entityplayer)

    {

            entityplayer.addChatMessage("Welcome");

               

 

    }

 

@Override 

@SideOnly(Side.CLIENT)

 

    public void registerIcons(IconRegister iconRegister)

    {

        this.itemIcon = iconRegister.registerIcon(texturePath);

    } 

 

 

}[/embed]

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

Hello! I am trying to send a chat message when someone clicks on the item. Here is my code. I tried to add a message, but it did not work.

[embed=425,349]package mymod.items;

 

import java.awt.Event;

import java.util.Random;

 

import org.lwjgl.input.Keyboard;

 

import com.google.common.eventbus.Subscribe;

 

import mymod.Main;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import cpw.mods.fml.common.network.Player;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

 

public class MyItem extends Item {

 

   

    private String texturePath = "mymod:";

   

    public MyItem(int ItemID, String textureName)

    {

        super(ItemID);

        this.setUnlocalizedName(textureName);

        this.setCreativeTab(CreativeTabs.tabMaterials);

        texturePath += textureName;

    }

   

    public void onItemUse(EntityPlayer entityplayer)

    {

            entityplayer.addChatMessage("Welcome");

               

 

    }

 

@Override 

@SideOnly(Side.CLIENT)

 

    public void registerIcons(IconRegister iconRegister)

    {

        this.itemIcon = iconRegister.registerIcon(texturePath);

    } 

 

 

}[/embed]

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted May 30, 2016

1. Version?

2. What are those imports? AWT, really?

3. I don't think there is such method in superclass onItemUse(EntityPlayer entityplayer), you need to actually @Override something. Look into Item class or some Item tutorial.

4. I am almost certain you don't know Java - please learn something, basics at least. :P

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted May 30, 2016

1. Version?

2. What are those imports? AWT, really?

3. I don't think there is such method in superclass onItemUse(EntityPlayer entityplayer), you need to actually @Override something. Look into Item class or some Item tutorial.

4. I am almost certain you don't know Java - please learn something, basics at least. :P

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

I'm on version 1.6.4. Is there anyway to send a message when I click (Left or right) the item? I would really like to use this, so all the help is appreciated.

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

I'm on version 1.6.4. Is there anyway to send a message when I click (Left or right) the item? I would really like to use this, so all the help is appreciated.

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted May 30, 2016

1.6.4 is ancient (years), noone can help you. Update or look on your own. I alredy told you - look into Item.class and find method with name that sounds like it does what you want and @Override it.

  • Quote

Share this post


Link to post
Share on other sites

Ernio    598

Ernio

Ernio    598

  • Reality Controller
  • Ernio
  • Forge Modder
  • 598
  • 2638 posts
Posted May 30, 2016

1.6.4 is ancient (years), noone can help you. Update or look on your own. I alredy told you - look into Item.class and find method with name that sounds like it does what you want and @Override it.

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

Alright, I found out how to add it. Now, is there a way I can say a random message instead of just that one?

Ex: It will run only ONE of these messages: "Hi!", "Wow!", "Cool!", "Nice!", etc.

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

Alright, I found out how to add it. Now, is there a way I can say a random message instead of just that one?

Ex: It will run only ONE of these messages: "Hi!", "Wow!", "Cool!", "Nice!", etc.

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2093

Draco18s

Draco18s    2093

  • Reality Controller
  • Draco18s
  • Members
  • 2093
  • 14028 posts
Posted May 30, 2016

1) generate a random number

2) do something with it

  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2093

Draco18s

Draco18s    2093

  • Reality Controller
  • Draco18s
  • Members
  • 2093
  • 14028 posts
Posted May 30, 2016

1) generate a random number

2) do something with it

  • Quote

Share this post


Link to post
Share on other sites

shadowfacts    100

shadowfacts

shadowfacts    100

  • Dragon Slayer
  • shadowfacts
  • Forge Modder
  • 100
  • 588 posts
Posted May 30, 2016

1. As Ernio said, 1.6.4 is no longer supported.

2. Go learn Java. If you knew the basics of Java you would be able to answer your own question.

  • Quote

Share this post


Link to post
Share on other sites

shadowfacts    100

shadowfacts

shadowfacts    100

  • Dragon Slayer
  • shadowfacts
  • Forge Modder
  • 100
  • 588 posts
Posted May 30, 2016

1. As Ernio said, 1.6.4 is no longer supported.

2. Go learn Java. If you knew the basics of Java you would be able to answer your own question.

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

I found out how to add the message and send a random one. Thanks for your help.

  • Quote

Share this post


Link to post
Share on other sites

Betterjakers    0

Betterjakers

Betterjakers    0

  • Tree Puncher
  • Betterjakers
  • Members
  • 0
  • 39 posts
Posted May 30, 2016

I found out how to add the message and send a random one. Thanks for your help.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Jaffaaaaa
      ScreenGui does nothing

      By Jaffaaaaa · Posted 10 minutes ago

      bump. anyone help?
    • JMAS
      net.minecraftforge.oredict.OreDictionary missing from 1.14.4 MDK

      By JMAS · Posted 13 minutes ago

      Regarding the Oredict question above: NonNullList<ItemStack> seed = OreDictionary.getOres("seed");
    • Carbonx_09
      Minearchy | 1.14.4 Towny | Releasing Mid December | Balanced player economies | Join discord: discord.gg/vUEAanV

      By Carbonx_09 · Posted 24 minutes ago

      Hey guys, you should definitely join our discord server! We're going to be releasing in one week! https://discord.gg/vUEAanV
    • solitone
      Distinguish singleplayer vs. multiplayer

      By solitone · Posted 44 minutes ago

      @Override public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { // [...] String separator = getSeparator(); String scriptName = nbtTagCompound.getString("scriptName"); String scriptPath = "pythontool" + separator + scriptName; proxy.runPython(world, player, scriptPath); // [...] }   ^^^ This is how I refactored onItemRightClick(). The runPython() method does nothing on the dedicated server, while on the client:   public class ClientOnlyProxy extends CommonProxy { // [...] @Override public void runPython(World world, EntityPlayer player, String scriptPath) { super.runPython(world, player, scriptPath); if (world.isRemote) { // client side if (!Minecraft.getMinecraft().isSingleplayer()) { // client talks to dedicated server (multiplayer game) ClientCommandHandler.instance.executeCommand(player, "/lpython " + scriptPath); } } else { // server side if (player.isSneaking()) { // shift pressed. Run new parallel script Minecraft.getMinecraft().thePlayer.getServer().getCommandManager().executeCommand(player, "/apy " + scriptPath); } else { // shift not pressed. Cancel previous scripts and run new script world.getMinecraftServer().getCommandManager().executeCommand(player, "/python " + scriptPath); } } } }   I still need to figure out why they used two different approaches to execute commands on the integrated server--Minecraft.getMinecraft().thePlayer.getServer().getCommandManager().executeCommand() vs. world.getMinecraftServer().getCommandManager().executeCommand().   public abstract class CommonProxy { // [...] public void runPython(World world, EntityPlayer player, String scriptPath) {} }   public class PythonTool { // [...] @SidedProxy(clientSide="pythontool.ClientOnlyProxy", serverSide="pythontool.DedicatedServerProxy") public static CommonProxy proxy; // [...] }   Are still there significant mistakes? Thanks again!
    • salvestrom
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By salvestrom · Posted 47 minutes ago

      Please show your render class. And please use the <> function in the reply box to copy and paste your class. Don't just use screenshots.
  • Topics

    • Jaffaaaaa
      1
      ScreenGui does nothing

      By Jaffaaaaa
      Started Yesterday at 07:03 PM

    • JMAS
      5
      net.minecraftforge.oredict.OreDictionary missing from 1.14.4 MDK

      By JMAS
      Started 4 hours ago

    • Carbonx_09
      1
      Minearchy | 1.14.4 Towny | Releasing Mid December | Balanced player economies | Join discord: discord.gg/vUEAanV

      By Carbonx_09
      Started Yesterday at 08:30 PM

    • solitone
      18
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • DragonITA
      34
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

  • Who's Online (See full list)

    • Sivonja
    • JMAS
    • Jaffaaaaa
    • dylandmrl
    • deerangle
    • loordgek
    • Pyre540
    • bluemetalsword
    • Carbonx_09
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • Send message on item use
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community