Everything posted by kauan99
-
[1.7.10] [SOLVED] How to properly extend Potion?
I see. Well if it's for the sake of optimization then I agree with java dev team. I thought it was just, you know, lack of imagination. one last thing: is there away to find out whether im running my mod in a deobfuscated environment, maybe some forge or fml method. This way I could set that string to the SRG name or the deobfuscated name depending on that, instead of manually changing it before release.
-
[1.7.10] [SOLVED] How to properly extend Potion?
thanks! but why do I need SRG name? the mod won't work after release if I use the deobfuscated name? also, Field modField = Field.class.getDeclaredField("modifiers"); modField.setAccessible(true); the need of those lines seems to me like a flaw in the reflection framework. I'm reflecting on a class of the java.lang.reflect package itself. this shouldn't be necessary IMO. the framework should allow something like this: Field potionTypesField = Potion.class.getDeclaredField("potionTypes"); int modifiers = potionTypesField.getModifiers(); potionTypesField.setModifiers(modifiers & ~Modifier.FINAL);
-
[1.7.10] [Solved] How do I use config file correctly
hey I just know that because someone taught me too. nobody's stupid just notice the category can be any string you want, and if you want sub categories all you have to do is to name them them like this: "parentCategory.childCategory". You can use config.addCustomCategoryComment(categoryName, "categoryComment") it's a lot easier than it seems at first.
-
[1.7.10] [Solved] How do I use config file correctly
it creates the file or reads it if it already exists. boolean shouldRegisterItem; @EventHandler public static void preInit(FMLPreInitializationEvent event) { //this line either creates the file if it doesn't exist or opens it if it already exists. Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load();//reads the contents of the file into the Configuration object. boolean defaultValue = true; shouldRegisterItem = config.get(Configuration.CATEGORY_GENERAL, "should_register_item", defaultValue); //after you're done: config.save();//saves the Configuration content into the file. } @EventHandler public static void init(FMLInitializationEvent event) { if(shouldRegisterItem) { //invoke GameRegistry.registerItem() for your item. } }
-
[1.7.10] [Solved] How do I use config file correctly
when you add things to the config file you are actually reading it. you add the default or get the value set in the file. in other words, if that thing you're adding is already there and if it has another value, then it reads that value from the file. if what you're adding is not in the file, then it adds it: @EventHandler public static void preInit(FMLPreInitializationEvent event) { //this line either creates the file if it doesn't exist or opens it if it already exists. Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load();//reads the contents of the file into the Configuration object. //use the config.get* methods to add/get values from the config as I explained above. //after you're done: config.save();//saves the Configuration content into the file. }
-
[1.7.10] [SOLVED] How to properly extend Potion?
Do I need my Potion to be registered? My potion ID must really be within the range of the Potion.potionTypes array or does Forge comes to the rescue somehow to avoid mods overwriting each other's potions? How the method setIconIndex works?
-
[1.7.10] build error: "No such version exists!"
oh I see. now it makes more sense. I didn't know I needed the website for building.
-
[1.7.10] build error: "No such version exists!"
fixed. very strange thing... all I did was to change my dependency to it's deobfuscated jar. Maybe that wasn't what fixed it and something just started working again for no reason. All I know is the problem is gone...
-
[1.7.10] build error: "No such version exists!"
I run my mod fine, but when trying to build I get this weird error: FAILURE: Build failed with an exception. * Where: Build file 'C:\Forge\build.gradle' line: 28 * What went wrong: A problem occurred evaluating root project 'Forge'. > No such version exists! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 3.04 secs my build.gradle: buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } apply plugin: 'forge' version = "1.7.10-0.1a" group= "mod.gumballweapons.main.GumballWeapons" archivesBaseName = "GumballWeapons" sourceCompatibility = 1.8 targetCompatibility = 1.8 minecraft { version = "1.7.10-10.13.4.1448-1.7.10" runDir = "eclipse" } dependencies { compile files("C:/Forge/src/libs/Baubles-princess-1.7.2-1.0.0.18p.jar") } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } }
-
[1.7.10] Gradle Error "No such version exists"
I have this same problem, but my error is slightly different: FAILURE: Build failed with an exception. * Where: Build file 'C:\Forge\build.gradle' line: 28 * What went wrong: A problem occurred evaluating root project 'Forge'. > No such version exists! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 4.9 secs build.gradle: buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } apply plugin: 'forge' version = "1.7.10-0.1a" group= "mod.gumballweapons.main.GumballWeapons" archivesBaseName = "GumballWeapons" sourceCompatibility = 1.8 targetCompatibility = 1.8 minecraft { version = "1.7.10-10.13.4.1448-1.7.10" runDir = "eclipse" } dependencies { compile files("C:/Forge/src/libs/Baubles-princess-1.7.2-1.0.0.18p.jar") } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } }
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
awesome! thanks again. I put 1.8 because I have Java 8 and I think this way both gradle and eclipse will use the same compiler. It works perfectly now.
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
I press the green button and minecraft loads and so does my mod and everything works fine, but then, when trying to build, I get compilation errors. this is gradle.log: **************************** Powered By MCP: http://modcoderpack.com/ Searge, ProfMobius, Fesh0r, R4wk, ZeuX, IngisKahn, bspkrs MCP Data version : unknown **************************** :compileApiJava UP-TO-DATE :processApiResources UP-TO-DATE :apiClasses UP-TO-DATE :sourceMainJava UP-TO-DATE :compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6 C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterQuarryTileEntity.java:94: error: incompatible types: Object cannot be converted to int int targetX = (int) targetXGetter.invokeExact((TileQuarry)this); ^ C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterQuarryTileEntity.java:95: error: incompatible types: Object cannot be converted to int int targetY = (int) targetYGetter.invokeExact((TileQuarry)this); ^ C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterQuarryTileEntity.java:96: error: incompatible types: Object cannot be converted to int int targetZ = (int) targetZGetter.invokeExact((TileQuarry)this); ^ Note: C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterBlockMiner.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterBlockMiner.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors 1 warning FAILED this is build.gradle: buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' } } apply plugin: 'forge' version = "1.7.10-0.1a" group= "mod.betterquarry.main.BetterQuarry" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "BetterQuarry" minecraft { version = "1.7.10-10.13.4.1448-1.7.10" runDir = "eclipse" } dependencies { compile files("C:/Forge/src/libs/buildcraft-7.0.20-dev.jar") } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } } I changed the method to invoke and then I got another error. C:\Forge\build\sources\java\mod\betterquarry\tileentities\BetterQuarryTileEntity.java:100: error: method invoked with incorrect number of arguments; expected 2, found 1 minerSetter.invokeExact((TileQuarry)this, (BlockMiner)(new BetterBlockMiner(worldObj, this, targetX, targetY - 1, targetZ))); Which I fixed changing invokeExact to invokeWithArguments. Problem is, when I test the compiled .jar putting it into my mods folder, it throws an exception when I place my block on the world: java.lang.VerifyError: Bad type on operand stack Exception Details: Location: mod/betterquarry/tileentities/BetterQuarryTileEntity.positionReached()V @15: invokevirtual Reason: Type 'mod/betterquarry/tileentities/BetterQuarryTileEntity' (current frame, stack[1]) is not assignable to '[Ljava/lang/Object;' Current Frame: bci: @15 flags: { } locals: { 'mod/betterquarry/tileentities/BetterQuarryTileEntity' } stack: { 'java/lang/invoke/MethodHandle', 'mod/betterquarry/tileentities/BetterQuarryTileEntity' } I don't know how to fix this! If I change back to invokeExact it won't compile. If I use invoke it won't run. also how do I make those exceptions get thrown when I use eclipse's Minecraft client? I wanted to know when my code is broken before trying to build it.
-
How to use config files?
Thank you, that's useful information. The tutorial is just a bit outdated, not wrong really.
-
How to use config files?
Ok thanks. wow, eclipse is a bit buggy and sometimes I forget that. It wouldn't give me the option to import that Property class. Anyway, I don't need it, because thanks to the method @diesieben07 showed me, I can add comments without it, contrary to what the tutorial said (I'm guessing the Configuration class was different in the past).
-
How to use config files?
(I still have a doubt concerning this topic. read new doubt section bellow) that's the one. But there's no method called Confuguration.getOrCreateProperty and no Property class. So I got confused if whether I still needed to do exactly as the tutorial said but using different methods and classes or if things were done in an entirely different way now. new doubt: If my mod is loaded on a multiplayer server, will it automatically use the server's config instead of the client's or do I have to do something extra for that to happen? this is my code. It's working. I'm just not sure about the multiplayer server thing. I increased readability by removing everything that is irrelevant to my question. //this, off course, is the proxy class that both ClientProxy and ServerProxy inherit from. Is this where I want my code to be //to make it work in both Singleplayer and Multiplayer, but ignoring the client's config when in Multiplayer? public class CommonProxy { static String[] configStrings; //this is invoked by my mod class, from inside its preInit method. public static void preInit(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); config.load(); String comment = "my comment"; String[] defaultStrings = new String[3]; defaultStrings[0] = "parsable string 0"; defaultStrings[1] = "parsable string 1"; defaultStrings[2] = "parsable string 2"; configStrings = config.getStringList("ConfigItemName", "ConfigCategoryName", defaultStrings, comment); config.save(); } }
-
How to use config files?
I'll try the method you said. it seems config is a lot simpler now than it was back when the tutorial was wrote. the code is not ready for test yet, but I'm confident it will work.
-
How to use config files?
ok thanks. some of methods mentioned in the tutorials don`t exist anymore.
-
How to use config files?
I wanted to store a list of user defined strings (each of which will be parsed into a block/item name and a few numbers). I read the tutorials for using Configuration class but they are very outdated. I need something that works specifically on version 1.7.10. Where should I look? Thank you.
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
wow, I think I'm actually starting to like java. this magic is awesome
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
nice! so this line fieldGet = MethodHandles.publicLookup().unreflectGetter(field); creates a public getter for the field, and I don't need reflection to read it anymore? It will work just as if SomeClass had a public getter for field?
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
I know how to do it using reflection, I'm just afraid it may hurt performance. it is not only one field, I simplified it for the sake of the example. it's actually 5 fields. And this method will be called often when the machine is on.
-
[1.7.10] [Solved] How to modify accessibility of fields (the advanced way)
Hi. I'm trying to make an addon for buildcraft. I need to extend the TileEntity for the Quarry. My problem is, I need access to some private fields on that class. I would use reflection if it was a one time thing, but I need to access those fields pretty often. I was trying to read the tutorial for access transformers, but I couldn't understand it. So i decided to ask here for clarification. Here's what I want to do: public class ABuildCraftClass { private int aField; public void aMethod() { //does stuff that requires reading aField. } } public class MyClass extends ABuildCraftClass { @Override public void aMethod() { //I need to override this one but I will still need the value of aField. } } how can I do this without using reflection for every access?
-
[1.7.10] Do I have to save and read my TileEntities fields from NBTTags?
So how do I know if my client needs those packets? My tile entity has 2 slots for Item Stacks, one for input and one for output; it has a fluid tank (not implemented yet, because I still don't know how) and an RF buffer (also still no idea how to do this). Do I have to implement those packet methods? My block is basically some sort of anvil-machine.
-
[1.7.10] Do I have to save and read my TileEntities fields from NBTTags?
I see, thank you. I thought this was automated somehow, but that wouldn't work very well, unless there was an annotation you could add to each field and it would probably be more complicated. Oh I have an idea, maybe TileEntity could be declared as abstract and have 2 abstract methods named maybe "readUserNBT" and "writeUserNBT" or whatever. and then both readFromNBT and writeToNBT base implementations would invoke their respective abstract peers? Or, if that would break some part of Forge's code, then maybe instead of extending TileEntity we modders would have to extend AbstractTileEntity, and that one would be just like TileEntity (in fact, a subclass of TileEntity), but the implementations of readFromNBT and writeToNBT overriden to the way I mentioned before and with the 2 abstract methods I also mentioned being declared in it. Thus, preventing us begginers from forgetting to implement the necessary persistence methods.
-
[1.7.10] Do I have to save and read my TileEntities fields from NBTTags?
Hello I have this doubt. If I have a TileEntity with a bunch of fields, and invoke markDirty() every time those fields are changed, do I still have to save those fields as NBTTags or is that data saved in some other way that doesn't need my code to explicitly do it?
IPS spam blocked by CleanTalk.