Posted February 6, 20178 yr 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, 20178 yr by mattyixiriva Cause I can http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 6, 20178 yr 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. 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/
February 7, 20178 yr Author 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, 20178 yr by mattyixiriva http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr worldIn.isRemote, is the best you can do there. 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.
February 7, 20178 yr 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, 20178 yr by larsgerrits 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/
February 7, 20178 yr Author 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)); } http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr This will still crash the server you need to you use the player given to you in the parameters Did you really need to know?
February 7, 20178 yr 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. 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/
February 7, 20178 yr Author 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? http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Instead of Minecraft.getMinecraft().player, use playerIn. 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/
February 7, 20178 yr Author 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... http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author I'm only posting images with errors, so anyone trying to help knows where the problem persists. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author 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. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author 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. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author @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 http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author 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. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author Please stop posting replies if you're no help. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author 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. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr Author 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 http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr 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, 20178 yr by larsgerrits 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/
February 7, 20178 yr Author 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"; http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr 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, 20178 yr by larsgerrits 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/
February 7, 20178 yr Author This is everything on my server proxy class. package com.matthewrivas.foxtech.proxy; public class ServerProxy implements CommonProxy { @Override public void init() {} } http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
February 7, 20178 yr 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, 20178 yr by larsgerrits 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/
February 7, 20178 yr Author Yes, its in the proxy package and its also in the string. http://i.imgur.com/C2FlJXb.png[/img] Hey! o/
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.