Jump to content

SHsuperCM

Members
  • Posts

    264
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by SHsuperCM

  1. Sure it can. What have you tried so far? so i tried this on a chat event: the event also has throws Exception cuz i had to GuiIngame newgui = new GuiIngame(Minecraft.getMinecraft()); Field field = Reference.getField(newgui.getClass(), "displayedTitle"); Reference.makeAccessible(field); System.out.println(field.get(newgui)); and my reference class has: public static Field getField(Class clazz, String fieldName) throws NoSuchFieldException { try { return clazz.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { Class superClass = clazz.getSuperclass(); if (superClass == null) { throw e; } else { return getField(superClass, fieldName); } } } public static void makeAccessible(Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true); } } and it just outputs to log empty lines(well not empty, they have the [15:55:35] [Client thread/INFO]: [com.SHsuperCM.ElytraMCMod.MapInfo.MapChatHandler:getChatEvent:69]: )
  2. now i understand what i need to get.. but again i have no idea about Reflection because i never used it and online really cant explain it... i would really love to know how do i use it to extract these protected Strings: /** The current title displayed */ protected String displayedTitle = ""; /** The current sub-title displayed */ protected String displayedSubTitle = ""; i understand that i am calling for "Minecraft.getMinecraft().ingameGui.[protected unaccessable] but still i cant figure it out...
  3. listen, i am an idiot... im starting to learn java now and im too stupid to understand the way i just look at code.... from what i understood, i cannot take protected arguments and plain ol' nonstatic arguments from the GuiIngame class.... so please for the love of god just explain to me how im supposed to take this out of there into a class of mine.
  4. i tried that the second i saw it and it didnt work...
  5. someone? i really have no clue how to look up things inside existing code... i looked at the SPacketTitle and i looked at GuiIngame.. i dont seem to find a way to extract the 2 strings... please someone help i cant do anything until i get this working...
  6. that does not help me... i looked and i think im not qualafied to search stuff because i got nowhere could someone give me the piece of code that get the title and another that gets the subtitle please?
  7. title that was made by the vanilla title command
  8. im making a client mod and i just need to get the string of the vanilla current title and the subtitle EDIT: hey guys i solved it with the help of diesieben07 diesieben again thank you so much for all the help! for people from the future that want to know what i did, this for Title: String title = (String) ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").get(Minecraft.getMinecraft().ingameGUI); and this for subtitle: String title = (String) ReflectionHelper.findField(GuiIngame.class, "displayedSubTitle", "field_175200_y").get(Minecraft.getMinecraft().ingameGUI); also if anyone wants a super easy method to get them i just made this: public static String getCurrentTitle(){ try { return (String) ReflectionHelper.findField(GuiIngame.class, "displayedTitle", "field_175201_x").get(Minecraft.getMinecraft().ingameGUI); } catch (IllegalAccessException e) {} return ""; } public static String getCurrentSubTitle(){ try { return (String) ReflectionHelper.findField(GuiIngame.class, "displayedSubTitle", "field_175200_y").get(Minecraft.getMinecraft().ingameGUI); } catch (IllegalAccessException e) {} return ""; } it should actually be safe to copypaste, i'v put it in my reference class and i can just call it whenever..
  9. thanks so much...
  10. im still working on my firstish mod and now i ran again into a problem i cant solve with google nor the forum's search so again i come to make a new topic about it.. i made a GUI on keybind and it works fine and i made a button output to log and it worked.. the only problem i have now is setting the config option within code.. i tried to do: Config.config.get("Modules","CheckpointHUD",true).set(false); like i saw online but it didnt change that to false, if you were wondering about how the config itself is built then: # Configuration file modules { # Whether to show the CheckpointHUD. [default: true] B:CheckpointHUD=true # Whether to disable the checkpoint reached message in chat. [default: true] B:DisableCPChat=true } please help is a wierd thing to say but ill say it anyways...
  11. i do not know even how to start using UTF-8 i never used it.... do i just need to add some \ with some code? i do not know.. please tellme how do i use it to do § signs
  12. well what if i dont at all use color checks? what if before ill just do: for(int j=1; j<originalMessage.length(); j++){ if(originalMessage.charAt(j) != '§'){ chars1.add(originalMessage.charAt(j)); }else{ j++; } } String message = ""; for (int z = 0; z < chars1.size(); z++) { message = message + chars1.get(z); } and use the messages without the § sign? then when i check, ill check for "clean chat"? if(message.contains("Elytra Racing | Objective: Get to the end of the course before everyone else!")){ //race starting i think this actually might work... im testing it now.. thanks for the information about the builder not understanding §
  13. i still dont understand this, do you say the .contains are not passing because im using the § signs? also all im getting is a chat message and all i want is to display its data.. i dont want anything to do with the server's code... its an early stages server not made by me..
  14. id look more into the mod annotation now.. i think it may actually be the thing that messes it.. again i dont own the server and i have no clue why i need to mess with just saying UTF-8 Thank you so much! finnally someone who gets what im doing
  15. OMG there is a server that is spigot not owned by me and its sending a message to the client a message whenever it passes a checkpoint! im rendering the checkpoint on screen! and it does not communicate with me in any way other than chat! no packets! no forge on the server! only a simple client mod that i get angry for no reason!
  16. THE SERVER SENDS A CHAT TO THE CLIENT!
  17. ITS A MOD THAT WORKS ONLY ON A CLIENT AND JOINS A SERVER!@!!!$!@$#@@#$#!@! UGGGGGHHH!@#!!!!@#$@!
  18. im not using a server! this is a client mod! there are no proxies at all..
  19. i dont know anything about packets.... im not using a server at all so no proxys and no anything... i just want some code to fire when the client gets a chat message and supply that with the full message itself....
  20. i do not understand that much about updating but setup a new workspace for me takes around 1 minute so i would just grab the source code file and make a new place for it...
  21. im really new to forge but i know the game alot and any blockmodel that needs to show the sides of other blocks such as glass, slabs, stairs, torches and such need to be transperent blocks a block that is not transperent will not render the sides of the blocks beside it to help performence i think your first step should be looking how to make a block transperent...
  22. im using a chat event to render some information on screen for some reason in my IDE(intelj idea) it works perfectly but after i build for some reason when i put it on my minecraft it doesnt work [move]CODE FOR MAIN CLASS[/move] package com.SHsuperCM.ElytraMCMod; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION, acceptedMinecraftVersions = Reference.ACCEPTED_MC_VERS) public class ElytraMCMod { @Instance public static ElytraMCMod instance; com.SHsuperCM.ElytraMCMod.Rings.RingsChatEventHandler ringsChatHandler = new com.SHsuperCM.ElytraMCMod.Rings.RingsChatEventHandler(); com.SHsuperCM.ElytraMCMod.Rings.RingsUIEventHandler ringsUIHandler = new com.SHsuperCM.ElytraMCMod.Rings.RingsUIEventHandler(); @EventHandler public void preInit(FMLPreInitializationEvent event){ ///-Rings-/// MinecraftForge.EVENT_BUS.register(ringsChatHandler); MinecraftForge.EVENT_BUS.register(ringsUIHandler); } @EventHandler public void init(FMLInitializationEvent event){ } @EventHandler public void postInit(FMLPostInitializationEvent event){ } } [move]CODE FOR CHAT CLASS(ringsChatHandler.class)[/move] package com.SHsuperCM.ElytraMCMod.Rings; import com.SHsuperCM.ElytraMCMod.Common.Delay; import com.SHsuperCM.ElytraMCMod.Reference; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import java.util.ArrayList; import java.util.List; public class RingsChatEventHandler { public static Delay RaceRingTimeout = new Delay(200); public static Delay UnknownTimeout = new Delay(20); @SubscribeEvent public void getChatEvent(ClientChatReceivedEvent event){ String originalMessage = event.getMessage().getFormattedText(); EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§eObjective: §r§aGet to the end of the course before everyone else!")){ //race starting Reference.ActualCheckPointString = "§l§6Getting race info!"; Reference.RaceStarted = true; RaceRingTimeout.Reset(); return; } if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§cFailed to reach next ring!")){ // failed RaceRingTimeout.Reset(); Reference.ActualCheckPointString = "§4§lFailed"; UnknownTimeout.Reset(); return; } if(originalMessage.contains("§r§9Elytra Racing §r§8|§r§e §r§eYou have passed ring ")){ //ring passed RaceRingTimeout.Reset(); //Reference.ActualCheckPointString = "§6§lCheckpoint reached!"; ///-Get Ring Cur/Max ///-- i know i did it horrible but it works.. List<Character> chars = new ArrayList<Character>(); for(int i=1; i<originalMessage.length(); i++){ if(originalMessage.charAt(i) == '('){ // ( chars.add(originalMessage.charAt(i+1)); /// ( i if(Character.isDigit(originalMessage.charAt(i+2))){ // ( i d chars.add(originalMessage.charAt(i+2)); /// ( i i if(originalMessage.charAt(i+3) == '/'){ // ( i i / chars.add(originalMessage.charAt(i+3)); /// ( i i / chars.add(originalMessage.charAt(i+4)); /// ( i i / i if(Character.isDigit(originalMessage.charAt(i+5))){ // ( i i / i i chars.add(originalMessage.charAt(i+5)); /// ( i i / i i } } }else { // i / chars.add(originalMessage.charAt(i+2)); /// ( i / chars.add(originalMessage.charAt(i+3)); /// ( i / i if(Character.isDigit(originalMessage.charAt(i+4))) { // ( i / i ? chars.add(originalMessage.charAt(i + 4)); /// ( i / i i } } String out = ""; for (int k = 0; k < chars.size(); k++) { out = out + chars.get(k); } Reference.ActualCheckPointString = "§6§l" + out; return; } } } if(originalMessage.contains("§9Elytra Racing §r§8|§r§e §r§aYou have completed the map")){ /// finished the map Reference.ActualCheckPointString = "§a§lFinished!"; UnknownTimeout.Reset(); } } } from there i have the gui handler and everything which in the ide works but again after build not..... i also tested to output stuff to console and to chat but it seems that the chat event is not working at all after build.... any help is much appriciated
  23. ill show you the whole main class package com.shaharcoolmen.randcommands; import com.shaharcoolmen.randcommands.commands.RandHelp; import com.shaharcoolmen.randcommands.proxy.CommonProxy.CommonProxy; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLServerStartingEvent; import net.minecraftforge.fml.relauncher.SideOnly; @Mod(modid="randcommands", name="RandomCommands", version="1.8-1.0") public class randcommands { //instance @Mod.Instance("randcommands") public static randcommands instance; //proxies @SidedProxy(clientSide="com.shaharcoolmen.randcommands.proxy.ClientProxy.ClientProxy", serverSide="com.shaharcoolmen.randcommands.proxy.CommonProxy.CommonProxy") public static CommonProxy proxy; //load @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { } @Mod.EventHandler public void init(FMLInitializationEvent event) { proxy.serverRegister(); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { } @Mod.EventHandler public void serverLoad(FMLServerStartingEvent event) { event.registerServerCommand(new RandHelp()); } } //icommandsender.addChatMessage(new ChatComponentText("§d§k||§r§cRandom Commands Help§d§k||§r")); and i still cant get to git hub can someone check this url for me and tell me if its working for him plz https://github.com/ this is the url im using and on my old pc it worked but now it wont for some reason
  24. for some weird reason icant get in github's web 404 page not found i got in through google and still ill try again later sorry im doing my best
  25. i found that the com.shaharcoolmen.randcommands.proxy.CommonProxy should be com.shaharcoolmen.randcommands.proxy.CommonProxy.CommonProxy aswell as the client but still i get a crash and i was wandering if acutualy my code to load a command was wrong inside of the main class i have under the @Mod(modid="randcommands", name="RandomCommands", version="1.8-1.0") public class randcommands { some other loading codes... and the thing to load the command is @Mod.EventHandler public void serverLoad(FMLServerStartingEvent event) { event.registerServerCommand(new RandHelp()); } } im uploading now to github
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.