-
Posts
70 -
Joined
-
Last visited
Everything posted by JoelGodOfWar
-
Thank you. I was expecting something similar to the biome name thing. Anyways, if anyone wants the code for chunk information, here it is. int chunkX = GetXCoordinate() / 16; int chunkY = GetYCoordinate() / 16; int chunkZ = GetZCoordinate() / 16; int inChunkX = GetXCoordinate() % 16; int inChunkY = GetYCoordinate() % 16; int inChunkZ = GetZCoordinate() % 16; String daChunk = ("" + Integer.toString(inChunkX) + " " + Integer.toString(inChunkY) + " " + Integer.toString(inChunkZ) + " in " + Integer.toString(chunkX) + " " + Integer.toString(chunkY) + " " + Integer.toString(chunkZ)); mc.fontRendererObj.drawString("C: " + daChunk + "", 2, 32, 0xffffff); protected static Minecraft mc = Minecraft.getMinecraft(); /** Get Player Coordinates */ public static int GetXCoordinate() { return (int) Math.floor(mc.thePlayer.posX); } public static int GetYCoordinate() { return (int) Math.floor(mc.thePlayer.posY); } public static int GetZCoordinate() { return (int) Math.floor(mc.thePlayer.posZ); }
-
So that get's me the chunk numbers 9 and 13, but what about the 0-15 inside of them?
-
Where in net.minecraft, or net.minecraftforge, would i look to gather the Chunk coordinates? Like the F3 screen shows. "Chunk: 14 4 11 in 9 4 13"
-
Just in case someone else runs into this issue, here's the code i used to solve it with a little help from diesieben07. This goes in your Mod loader code. The preInit, Init, postInit section. private File configFile; @EventHandler public void preInit(FMLPreInitializationEvent event){ FMLCommonHandler.instance().bus().register(new KeyInputHandler()); KeyBindings.init(); configFile = event.getSuggestedConfigurationFile(); Configs.LoadConfigSettings(configFile); Next create a new class and paste this code in. package com.datacraftcoords; import java.io.File; import com.datacraftcoords.event.EventManager; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; public class Configs { public static final String CATEGORY_GENERAL = "general"; public static Configuration config = null; public static void LoadConfigSettings(File configFile) { ReadConfigSettings(configFile, true); } public static void SaveConfigSettings() { ReadConfigSettings(null, false); } /** * Creates the config file if it doesn't already exist. * It loads/saves config values from/to the config file. * @param configFile Standard Forge configuration file * @param loadSettings set to true to load the settings from the config file, * or false to save the settings to the config file */ private static void ReadConfigSettings(File configFile, boolean loadSettings) { //NOTE: doing config.save() multiple times will bug out and add additional quotes to //categories with more than 1 word //Configuration config = null; if(loadSettings) { config = new Configuration(configFile); config.load(); } Property p; config.addCustomCategoryComment(CATEGORY_GENERAL, "Allows you to Enable or Disable the display of Coordinates."); p = config.get(CATEGORY_GENERAL, "Enabled", true); p.comment = "Enable/Disable display of coordinates"; p.set(EventManager.Enabled); config.save(); } } Next add this where you want to save your configs. Configs.SaveConfigSettings();
-
Well this is my preInit @EventHandler public void preInit(FMLPreInitializationEvent event){ FMLCommonHandler.instance().bus().register(new com.datacraftcoords.KeyInputHandler()); com.datacraftcoords.KeyBindings.init(); Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); EventManager.Enabled = config.get(Configuration.CATEGORY_GENERAL, "Enabled", false).getBoolean(true); config.save(); } How would i save the config after the state of EventManager.Enabled has changed?
-
I managed to load configs from a config file. But i can't seem to find where to add the save part to. If i add it to the keypress, it crashes the game. If i add it to the toggleenabled function called by the keypress it crashes the game. I have no gui, other than the keybindings added to Controls. Here is the code i've been trying to use to save the configs. Configuration config = new Configuration(); config.load(); Property p; config.addCustomCategoryComment(Configuration.CATEGORY_GENERAL, "Allows you to Enable or Disable the display of Coordinates."); p = config.get(Configuration.CATEGORY_GENERAL, "Enable/Disable", true); p.comment = "Enable/Disable display of coordinates"; p.set(EventManager.Enabled); config.save();
-
Thank you. I'll have to get a github later.
-
I am looking for tutorials on making a version checker function for my mod. So that when i do start to distribute my mod, and update it, that the people that have it will be notified. I tried finding how to register with the mod named Version Checker, but could not find information on how to implement it into the mod. Google searches have proven fruitless, as so many mods have the words version and checker in their name, that it's flooded with them instead of the code i need to see.
-
So far all the tutorials i've found are for 1.7.10, and i can get the keybind to show up in the controls area of settings. But when i press the associated key nothing happens, until i quit the game, then a flood of msgs show up. Also the drawString doesn't seem to happen at all. import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; public class KeyInputHandler { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if(KeyBindings.openGUI.isPressed()){ mc.fontRendererObj.drawString("Z Pressed", 2, 20, 0xffffff); System.out.println("KEY Z"); //OPEN GUI } } protected static Minecraft mc = Minecraft.getMinecraft(); } I must be missing something. Also how do i enable/disable a class when the key is pressed?
-
Yes that works. Thank you.
-
Well so far this is what i have. public static String getBiome(){ BlockPos blockpos = new BlockPos(mc.func_175606_aa().posX, mc.func_175606_aa().getEntityBoundingBox().minY, mc.func_175606_aa().posZ); Chunk chunk = mc.theWorld.getChunkFromBlockCoords(blockpos); return (String) "Biome: " + chunk.getBiome(blockpos, mc.theWorld.getWorldChunkManager()).biomeName; } But func_175606_aa comes up with "The method func_175606_aa() is undefined for the type Minecraft". A google search has shown some code involving particles, but nothing about biomes, or that explain what func_175606_aa is or does. Am i missing a dependency?
-
I can't seem to find anything under Minecraft.thePlayer, or Minecraft.theWorld that displays the biome the player is in. Would someone mind pointing me in the right direction?
-
[1.8] How to get Player Postition? [SOLVED]
JoelGodOfWar replied to JoelGodOfWar's topic in Modder Support
Well i'm not as familur with Java as i am with vb, html, or javascript. I think i've solved this part. Here's the code i have now, that has no errors. import net.minecraft.client.Minecraft; protected static Minecraft mc = Minecraft.getMinecraft(); public static int GetXCoordinate() { return (int) Math.floor(mc.thePlayer.posX); } public static int GetYCoordinate() { return (int) Math.floor(mc.thePlayer.posY); } public static int GetZCoordinate() { return (int) Math.floor(mc.thePlayer.posZ); } Now to figure out how to show that on the game screen. Thank you for your replies. -
[1.8] How to get Player Postition? [SOLVED]
JoelGodOfWar replied to JoelGodOfWar's topic in Modder Support
The code i'm looking at, from Zyin, shows this, public static int GetXCoordinate() { return (int) Math.floor(mc.thePlayer.posX); } But when i try to use that i get errors. With imports of import net.minecraft.client.Minecraft; import net.minecraft.util.BlockPos; The error says "mc cannot be resolved to a variable". -
I'm pretty new to modding, due to a need on the server i play on, i want to make a mod. So i am trying to learn. I have eclipse, and forge setup. I just can't seem to find the right dependency to get the information i want. I want to get the XYZ of the player, and display it in the bottom right of the screen. Later i will want to detect when the player makes a nether portal, and then display the coords of where the other portal should go, based on where they are when they make the first portal. code is helpful, but just pointing me to the right dependency will be good.