Kemuri Senpai Posted December 18, 2020 Posted December 18, 2020 (edited) I am catching Message send from Client and want to cancel it if it vontains some special words. This is fine. However, I also want to write text back to the player ( also Client Side ). Normally I use ´´´player.sendStatusMessage( new StringTextComponent("[ §1Place§r ] Set brightness to §4§l", brightness ), (false));´´´ But "entity" is not returned by ClientChatEvent... So, how? (Minecraft 1.15.2) Edited December 20, 2020 by Kemuri Senpai solved my problem Quote
ChampionAsh5357 Posted December 18, 2020 Posted December 18, 2020 If the player is sending it from their client, the client player exists locally within the Minecraft instance using Minecraft#player. Quote
Kemuri Senpai Posted December 18, 2020 Author Posted December 18, 2020 Okaaay,... I am very new to modding and java in complete... How do I access Minecraft#player? If I use "PlayerEntity player = ( PlayerEntity ) Minecraft.player;" it says "non-static variable player cannot be referenced from a static context" Quote
Kemuri Senpai Posted December 18, 2020 Author Posted December 18, 2020 (edited) Okay, I guess I should for now go and study more java Because though it's obvious, I still don't know what you mean (off topic, diesieben07, are you german?) Edited December 18, 2020 by Kemuri Senpai Quote
Kemuri Senpai Posted December 18, 2020 Author Posted December 18, 2020 31 minutes ago, diesieben07 said: You need an instance of the Minecraft class to access non-static methods, this is basic Java knowledge. Now, Minecraft is a singleton. It should be very obvious from that what you need to do to get the instance. So... It will work with Minecraft.getInstance ( ).player ? Sorry for this dumb questions, I was modding for Minecraft about half a year only using Scratch-like programm (MCreator). I know almost nothing about Java and coding, so this all is foreign terrain to me 🤷♂️ Quote
Kemuri Senpai Posted December 18, 2020 Author Posted December 18, 2020 I already read on forums: for 1.12.2 it's Minecraft.getMinecraft().thePlayer But for 1.15.2, "Minecraft" has no function "getMinecraft" Quote
poopoodice Posted December 18, 2020 Posted December 18, 2020 (edited) 42 minutes ago, Kemuri Senpai said: Minecraft.getInstance( ).player You’ve found out already didn't you? Edited December 18, 2020 by poopoodice Quote
Kemuri Senpai Posted December 18, 2020 Author Posted December 18, 2020 3 minutes ago, poopoodice said: You’ve found out already didn't you? Nope 😅 I am now not able to test it, so it was a question Quote
Kemuri Senpai Posted December 19, 2020 Author Posted December 19, 2020 Yes, thank you all, it worked perfectly; in addition, short question: while REACH_DISTANCE is for blocks, how do I change it for entities? Like in the Reach Hack Quote
Kemuri Senpai Posted December 19, 2020 Author Posted December 19, 2020 1 minute ago, diesieben07 said: It is also for entities. okay, thank you! Quote
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.