mattyixiriva Posted February 6, 2017 Posted February 6, 2017 (edited) I'm just trying to make a single object post text in chat on the client side only. So basically I want to have my mod "Item" to post "Hello World!" in the players chat window when I right click. I've tried a ton of tutorials for using "EvenHandlers" or "onItemRightClick" and I've no clue how to get them to work. public class ItemFoxTail extends Item { public ItemFoxTail() { setCreativeTab(CreativeTabs.MISC); setUnlocalizedName(Reference.FoxTech_Items.FOX_TAIL.getUnlocalizedName()); setRegistryName(Reference.FoxTech_Items.FOX_TAIL.getRegistryName()); setMaxStackSize(1); } } That's the basics of my item I have at the moment.public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) ^ is what I was trying to use but kept getting errors in Eclipse. Edited February 7, 2017 by mattyixiriva Cause I can Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
larsgerrits Posted February 6, 2017 Posted February 6, 2017 It looks like you are trying to override a method outside of the correct scope (correct word?). It should be inside the class, but outside of the constructor. Also, use your IDE to override methods. It will automatically use the correct method signature. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 (edited) I figured it out by doing some more research! Only thing I need to figure out now is out to get it to execute on Client Side only. So it doesn't pop up twice in chat. Edited February 7, 2017 by mattyixiriva Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
Animefan8888 Posted February 7, 2017 Posted February 7, 2017 worldIn.isRemote, is the best you can do there. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
larsgerrits Posted February 7, 2017 Posted February 7, 2017 (edited) You can't use the Minecraft class inside common code, use the EntityPlayer parameter or else your mod will crash the server. Edited February 7, 2017 by larsgerrits Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 10 minutes ago, larsgerrits said: You can't use the Minecraft class inside common code, use the EntityPlayer parameter or else your mod will crash the server. I figured it out what I ended up doing is using this code. @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (worldIn.isRemote) { Minecraft.getMinecraft().player.sendChatMessage("Hello fellow Foxes!!"); } //Minecraft.getMinecraft().player.sendChatMessage("Hello fellow Foxes!!"); return new ActionResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); } Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
CoderAtParadise Posted February 7, 2017 Posted February 7, 2017 This will still crash the server you need to you use the player given to you in the parameters 1 Quote Did you really need to know?
larsgerrits Posted February 7, 2017 Posted February 7, 2017 This will make the code run on the client only. But that will still crash the server as it still tries to load the Minecraft class on the server side. Using the EntityPlayer parameter will fix this. 1 Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 5 minutes ago, larsgerrits said: This will make the code run on the client only. But that will still crash the server as it still tries to load the Minecraft class on the server side. Using the EntityPlayer parameter will fix this. So what specific part would I need to change? Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
larsgerrits Posted February 7, 2017 Posted February 7, 2017 Instead of Minecraft.getMinecraft().player, use playerIn. 1 Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 24 minutes ago, larsgerrits said: Instead of Minecraft.getMinecraft().player, use playerIn. Ok I see how that works but I receive another error. I feel like there's something I need to add in... Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 I'm only posting images with errors, so anyone trying to help knows where the problem persists. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 ok.......anyways... So when I change playerIn.sendMessage("Hello fellow Foxes!!") into playerIn.sendMessage(ITextComponent); the error on sendMessage goes away but now ITextComponent has a error. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 Well I'm taking a break for now, not being able to figure this out is annoying me and I got work tomorrow, night for now. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 @Override public ActionResult onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) { if (worldIn.isRemote) { playerIn.sendMessage(new ITextComponent("HELLO!")); } return new ActionResult(EnumActionResult.PASS, playerIn.getHeldItem(handIn)); } "Cannot instantiate the type ITextComponent" Why is this a topic I seem to not be able to find online anywhere Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 I found another topic with chat messages I implemented this playerIn.sendMessage(new TextComponentTranslation("Hello", new Object[0])); Which works perfectly for what I want it to do but I can't run a server still. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 Please stop posting replies if you're no help. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 I'm using that because for some reason I can't get ITextComponent to work, probably cause I'm not well informed on the subject. I can't find any explanation or examples. For the server part. When I run a server from Eclipse it won't launch. I can run a Client fine and have the mod work just how I need it. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 4 minutes ago, diesieben07 said: What exactly happens? Nothing? Does it crash? If so, post the log. It starts the server window, I see it running like a normal server for a few seconds, then it crashes. CrashLog Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
larsgerrits Posted February 7, 2017 Posted February 7, 2017 (edited) Caused by: java.lang.ClassNotFoundException: com.matthewrivas.foxtech.ServerProxy Sounds obvious to me. It can't find your ServerProxy, did you check your spelling in @SidedProxy? Edited February 7, 2017 by larsgerrits Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 Yup it's spelled correctly. @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS) public static CommonProxy proxy; public static final String CLIENT_PROXY_CLASS = "com.matthewrivas.foxtech.proxy.ClientProxy"; public static final String SERVER_PROXY_CLASS = "com.matthewrivas.foxtech.ServerProxy"; Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
larsgerrits Posted February 7, 2017 Posted February 7, 2017 (edited) public static final String CLIENT_PROXY_CLASS = "com.matthewrivas.foxtech.proxy.ClientProxy"; public static final String SERVER_PROXY_CLASS = "com.matthewrivas.foxtech.ServerProxy"; Your ClientProxy is inside the proxy package and ServerProxy not? Your variable should be the same as the package declaration of the ServerrProxy. Edited February 7, 2017 by larsgerrits Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 This is everything on my server proxy class. package com.matthewrivas.foxtech.proxy; public class ServerProxy implements CommonProxy { @Override public void init() {} } Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
larsgerrits Posted February 7, 2017 Posted February 7, 2017 (edited) package com.matthewrivas.foxtech.proxy; So your ServerProxy does exist in the proxy package? That also put it inside the String you pass into the @SidedProxy. Edited February 7, 2017 by larsgerrits Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
mattyixiriva Posted February 7, 2017 Author Posted February 7, 2017 Yes, its in the proxy package and its also in the string. Quote http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
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.