Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Antonii

Members
  • Posts

    36
  • Joined

  • Last visited

Antonii's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Yes finally. I took some suggestions from here The libraries are now embedded and loaded on runtime. I used embed and works perfectly. This is the final configuration: buildscript { repositories { maven { url = 'https://maven.minecraftforge.net' } mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' version = '1.0' group = 'com.lumieresombre.horizonprivatemodid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'modid' java.toolchain.languageVersion = JavaLanguageVersion.of(11) // Mojang ships Java 8 to end users, so your mod should target Java 8. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { // The mappings can be changed at any time, and must be in the following format. // Channel: Version: // snapshot YYYYMMDD Snapshot are built nightly. // stable # Stables are built at the discretion of the MCP team. // official MCVersion Official field/method names from Mojang mapping files // // You must be aware of the Mojang license when using the 'official' mappings. // See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md // // Use non-default mappings at your own risk. they may not always work. // Simply re-run your setup task after changing the mappings to update your workspace. mappings channel: 'official', version: '1.16.5' // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Default run configurations. // These can be tweaked, removed, or duplicated as needed. runs { client { workingDirectory project.file('run') // Recommended logging data for a userdev environment // The markers can be changed as needed. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console // You can set various levels here. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' mods { horizonprivatemodid{ source sourceSets.main } } } server { workingDirectory project.file('run') // Recommended logging data for a userdev environment // The markers can be changed as needed. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console // You can set various levels here. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } data { workingDirectory project.file('run') // Recommended logging data for a userdev environment // The markers can be changed as needed. // "SCAN": For mods scan. // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. property 'forge.logging.markers', 'REGISTRIES' // Recommended logging level for the console // You can set various levels here. // Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels property 'forge.logging.console.level', 'debug' // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { horizonprivatemodid{ source sourceSets.main } } } } } repositories { mavenLocal() mavenCentral() flatDir { dirs 'libs\\' } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } configurations { embed } dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.16.5-36.1.24' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" // compile "some.group:artifact:version" //compile files("libs/automaton.jar","libs/xeger-1.0-SNAPSHOT.jar") compile "com.lumieresombre.lib:xeger:1.0.0" compile "com.lumieresombre.lib:automaton:1.0.0" embed "com.lumieresombre.lib:xeger:1.0.0" embed "com.lumieresombre.lib:automaton:1.0.0" // Real examples // compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env // compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. // provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' // These dependencies get remapped to your current MCP mappings // deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev' // For more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "ContainedDeps":"automaton-1.0.0.jar xeger-1.0.0.jar", "Class-Path":"automaton-1.0.0.jar xeger-1.0.0.jar" ]) } from configurations.embed.collect { it.isDirectory() ? it : zipTree(it) } } // Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing //publish.dependsOn('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } }
  2. I have tried all imaginable configurations in order to load an external jar to my mod. Forge version: 1.16 IDE: IntelliJ Java: 11.0.11 for building and running On 1.12 version I used to simply add the jars to the build.gradle with the `compile files()` command and then add them to the mods folder together with the mod jar. It used to work. But now it seems it cannot find the jars anymore. I'll post the logs at the end. Even more I scanned for IO access from the java (procmon) and I can't see it trying to read any file when the function containing the external reference is called (I suppose it loads the jar on request). I admit I am confused about all the maven and "libraries" vs "libs" features. I noticed that everything in META-INF in src/main/resources is automatically included in the final jar. But if this is supposed to happen what's with all the maven? Isn't maven supposed to automatically download jars from some public repository/local repo when needed? Why bundle it in the jar and then require the special .meta files just to make it work? Here's what I tried for the build.gradle. I tried many different configurations but the uncommented one is aproximatelly what worked in the past. buildscript { repositories { maven { url = 'https://maven.minecraftforge.net' } mavenCentral() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true } } repositories { mavenLocal() mavenCentral() flatDir { dirs 'C:\\MinecraftForge\\Forge1.16\\src\\main\\resources\\META-INF\\libraries' } } configurations { inJar } configurations.compile.extendsFrom(configurations.inJar) dependencies { // Old fashioned way that worked before compile files("libs/automaton.jar","libs/xeger.jar") // Tried the maven public repository - I am afraid that this old library could actually contain malware // implementation group: 'nl.flotsam', name: 'xeger', version: '1.0.0-lorislab-1' // Seen this on another forum - adding the jars to the maven with the .maven file and including for the local repo //inJar 'com.lumieresombre.lib:xeger:1.0.0' //inJar 'com.lumieresombre.lib:automaton:1.0.0' // Something else I tried. Didn't work. Could // compile "com.lumieresombre.lib:xeger:1.0.0" // compile "com.lumieresombre.lib:automaton:1.0.0" } // Example for how to get properties into the manifest for reading by the runtime.. jar { from(configurations.inJar) { into 'META-INF/libraries' } manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "ContainedDeps":"automaton-1.0.0.jar xeger-1.0.0.jar" ]) } } // Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing //publish.dependsOn('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } I read here about inserting all the jars in the libraries folder and that the mod loader will take care of everything. I am not sure if it still exists in the 1.16 The mod jar did get large but gave the same error. Then I read about moving the libs to maven. I tried this variant using a local repo aka flatDir. Here you can see my confusion: I pointed the flatDirs to the libraries folder which already contained the needed .meta files. This gave the same result. Then I read that I can specify the dependencies in the jar classpath/manifest. I am not sure if I should have copied the file to the final jar path or if it was included in the file. What should I do? I just want to drop the jars near the mod file and make it work. The error log: https://pastebin.com/KJF37fZ6 And here's the code around the line of the crash: protected void init() { // Create the options row list // It must be created in this method instead of in the constructor, // or it will not be displayed properly this.optionsRowList = new OptionsRowList( this.minecraft, this.width, this.height, OPTIONS_LIST_TOP_HEIGHT, this.height - OPTIONS_LIST_BOTTOM_OFFSET, OPTIONS_LIST_ITEM_HEIGHT ); // Add the options row list as this screen's child // If this is not done, users cannot click on items in the list this.children.add(this.optionsRowList); IteratableOption usernameChanger=new IteratableOption( "hbwhelper.configGui.dreamMode.title", (unused, newValue) -> { Xeger generator = new Xeger(GeneralConfig.get().username_generator); String result = generator.generate(); Main.ReflectionChangeUsername(result); }, (unused, option) -> new StringTextComponent("Username: "+Minecraft.getInstance().getUser().getName()) ); SliderPercentageOption attackProbability=new SliderPercentageOption( "Attack Probability", // Range: 0 to width of game window 0.0, 100, // Steps 0.5F, // Getter and setter are similar to those in BooleanOption unused -> GeneralConfig.get().constants.hit_probability, (unused, newValue) -> GeneralConfig.get().constants.hit_probability=newValue, // BiFunction that returns a string text component // in format "<name>: <value>" (gs, option) -> new StringTextComponent("Probability: "+GeneralConfig.get().constants.hit_probability) ); this.optionsRowList.addBig(usernameChanger); this.optionsRowList.addBig(attackProbability); // Add the "Done" button this.addButton(new Button( (this.width - BUTTON_WIDTH) / 2, this.height - DONE_BUTTON_TOP_OFFSET, BUTTON_WIDTH, BUTTON_HEIGHT, // Text shown on the button new TranslationTextComponent("gui.done"), // Action performed when the button is pressed button -> this.onClose() )); }
  3. How can I register local commands for a logical client side-only mod? I want to access these commands when for example playing on a server. However it seems the commands are first searched on the server and of course it fails when none is found. i can see a part of the commands logic in CommandSuggestionHelper::updateCommandInfo(). This is called when I input a string in the command and seems to generate the suggestions by making a request to the server. And ChatScreen::keyPressed() calls sendMessage() which contains a comment It looks like it might not be yet implemented. So is this possible? I am using version 1.16.5 - 36.1.0. What I've tried (taken from MinecraftByExample) public class TestCommand { public static void register(CommandDispatcher<CommandSource> dispatcher) { LiteralArgumentBuilder<CommandSource> mbequoteCommand = Commands.literal("mbequote") .then(Commands.literal("python") .executes(commandContext -> sendMessage(commandContext, QuoteSource.MONTY_PYTHON.getQuote()))) .then(Commands.literal("blues") .executes(commandContext -> sendMessage(commandContext, QuoteSource.BLUES_BROTHERS.getQuote()))) .then(Commands.literal("yogi") .then(Commands.literal("bear").executes( commandContext -> sendMessage(commandContext, QuoteSource.YOGI_BEAR.getQuote()))) .then(Commands.literal("miaow").executes( commandContext -> sendMessage(commandContext, QuoteSource.YOGI_BERRA.getQuote()))) .executes(commandContext -> sendMessage(commandContext, "Which Yogi do you mean?")) ); dispatcher.register(mbequoteCommand); } static int sendMessage(CommandContext<CommandSource> commandContext, String message) throws CommandSyntaxException { TranslationTextComponent finalText = new TranslationTextComponent("chat.type.announcement", commandContext.getSource().getDisplayName(), new StringTextComponent(message)); Entity entity = commandContext.getSource().getEntity(); if (entity != null) { commandContext.getSource().getServer().getPlayerList().broadcastMessage(finalText, ChatType.CHAT, entity.getUUID()); // func_232641_a_ is sendMessage() } else { commandContext.getSource().getServer().getPlayerList().broadcastMessage(finalText, ChatType.SYSTEM, Util.NIL_UUID); } return 1; } enum QuoteSource { MONTY_PYTHON(new String[] { "Nobody expects the Spanish Inquisition!", "What sad times are these when passing ruffians can say 'Ni' at will to old ladies.", "That's the machine that goes 'ping'.", "Have you got anything without spam?", "We interrupt this program to annoy you and make things generally more irritating.", "My brain hurts!" }), YOGI_BERRA(new String[] { "When you come to a fork in the road... take it.", "It ain't over till it's over.", "The future ain't what it used to be.", "If the world was perfect, it wouldn't be." }), YOGI_BEAR(new String[] { "I'm smarter than the average bear." }), BLUES_BROTHERS(new String[] { "Four fried chickens and a Coke, please.", "It's 106 miles to Chicago, we've got a full tank, half pack of cigarettes, it's dark out, and we're wearing sunglasses. Hit it.", "Are you the police? No ma'am, we're musicians." }); public String getQuote() { return quotes[new Random().nextInt(quotes.length)]; } QuoteSource(String[] quotes) { this.quotes = quotes; } private String[] quotes; } } This command works on local multiplayer environment but not when connected to a dedicated/external server (meaning the server gets the request and replies with command not found)
  4. This is exactly what I thought! Thanks. This is why I said So the issue at hand is to differentiate between the two...when? On events? I recall that some events where called on both sides. You must put this in the docs perhaps on the Sided page
  5. I admit I left one thing out: I will want to play a normal game locally. When I will do that won't my mod be loaded also on the logical server? It's true that in normal conditions the check is somewhat useless but just sometimes I don't want to load it when playing a singleplayer game. Also I will test my mod locally on a singleplayer world and that will have the same issues. I used to have some sort of check in my mod in 1.12 version that did this.
  6. Now now there is no need for irony or insults. I am just asking for help. Redirecting me to a page I already read doesn't help, does it? Now here is what I understood: So I must "protect" my code from all forms of server. Taking into consideration that this mod will only run on my PC and not on a physical server that leaves me with the following problem: how to differentiate between the logical server and logical client. The method isClientSide() seems appropriate but it is not available where I need it (perhaps at a later stage?) Let's say I do what you keep insisting I should do; I use DistExecutor for Dist.CLIENT and....I don't know if the mod is loaded on logical server or logical client. And this is because
  7. public Main() { DistExecutor.safeRunWhenOn(Dist.CLIENT,()->SomeClass::Init); } //SomeClass::Init contains register code This bad/not needed - my mod will never run on physical server public Main() { if (Minecraft.getInstance() == null || !Minecraft.getInstance().level.isClientSide()) return; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::Init); } This good but doesn't work because `level` is null
  8. Yes indeed logical side is better and exactly what I want to do! Now how do I do that? isClientSide() doesn't work....because `level` is null
  9. Well you see DistExecutor is for the physical side. My mod will never run on a server but only on the client side. I only need to set apart the logical server and the logical client.
  10. I want my mod to only load when running on the logical client side. The problem is that on initial setup `Minecraft.getInstance().level` is null and so I cannot tell the sides apart. Is there any other clean way of doing this or should I use the `Thread.currentThread()` method?
  11. The docs say to use "isRemote()" to get the logical side but I can't find it in the `Minecraft.getInstance().level` world object. However I found `isClientSide()`. Is this method the counterpart of `isRemote`? Or was this functionality stripped away in favor of Dist?
  12. Never mind, I found it. Seems Eclipse is buggy again.
  13. Thanks. Do you also know the current way of taking a player's direction (north, south etc)? I used to call EnumFacing efc = player.getHorizontalFacing().getOpposite(); but the enum does not exist anymore and so the methods. I found what seems to be the replacement Directions but I could not find how it is used in the Entity class (a quick reference-search didn't return much)
  14. My mod will be client-side only and running on the 1.16 version of Forge. I want to know what's the difference between getPosition(), xo, xBob, xo, xOld? I think xOld stores the last position of the player before being updated by the server (or perhaps before taking a step?) but what about the others? I used to take the position of the player directly by accessing posX, posY and posZ. This was on the 1.12 version. Now I am not sure if I can simply replace all those with xo, yo and zo. That would make my job much easier.
  15. I managed to create a functional button for my gui in forge 1.12. Using annotations I created my config and then in my Gui I called the super(....,MyModConfig.class). I see that many things changed in 1.15. Is this still possible? I know I can manually create the text fields in the Gui and manually updating the config but I really want to use the annotations system. In the same time, this method already generates the Gui and I need a button to be created. I don't have any code to show because I am working on other parts of my code in this 'exporting-to-15' project. I will try to do some tests myself but first I want to know if it's worth it. Question #2 In the current version, in the button event, I access the textfileds generated by the config by reflection. This is nasty. Is there any other way to access the edited text without first clicking 'Done'? Question #3 Where did posY, posX and posZ disappear? The only available candidates that remotely resemble what used to be the current location of the player are the lastTickX fields. Note: this is a fully client-sided mod. I use forge 1.15.2
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.