Jump to content

SirWindfield

Members
  • Posts

    10
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

SirWindfield's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ye but the only way to do the syncing is by making the fields non static so each instance has actually other values, am I right? But that would conflict with the configuration annotation api. Because that api actually expects values to be static. Quite upset that those two APIs can't work together. But creating a GUI for a simple Configuration is not hard at all. So I will probably just make the fields non static and use instances then. Thanks.
  2. So there is no way to actually have placeholders within lang files and replace them duriing runtime?
  3. That's what I did. I have written key=Some string and some value {} and then I created a new instance as shown above. I expected that the {} gets replaced by the argumentOfTypeString but that wasn't the case. I always get this output: "You need the following item to enter {}: {}!" I can show you the lang file and the code if you want to. new TextComponentTranslation("chat.message.missing_key", dimensionName, itemName) chat.message.missing_key=You need the following item to enter {}: {}! The second one being the lang file and the first one the Java file that sends the player a message using EntityPlayer#sendMessage. Any idea why this is happening?
  4. I have ported a clientside mod to be server side only. The last thing that does not work is the chat messages that get sent to the client. After googling some time I found out that I18N only works on the client side. Is there some way to load the lang files server side, get the matching locale from the player and then load the key from the matching lang file? Another question that is similar to this one. I tried formatting the text and making it dynamic by including placeholders: "Some string needs {} argument". But that doesn't work. I couldn't find any information on placeholders within the localization framework. Would someone tell me the right placeholder syntax to make the following call possible? new TextComponentTranslation("key", argumentOfTypeString); Thanks for the help, Wf
  5. Making a new instance of RPConfiguration is not possible if you use the @Config annotations since your fields have to be static. At least for me, the annotation system has no way to actually set the fields manually since you have not access to the underlying Configuration instance. @diesieben07 did post solutions, but those did not involve the new annotation system introduced in 1.12.
  6. I craeted a configuration file using the new 1.12 annotations offered by forge (@Config). Now I wanted to implement config syncing between client and server. Searching for some time lead to to the following posts here on this forum: 1) 2) As /u/diesieben07 (@diesieben07) mentioned in the second link, the best way is to store the configs both on client side and use the server side config if it is available. But since I am using the forge annotations I do not even have two separate classes with those values (since the fields are static). Do I just set the static fields to the new values received from the server? And if so, how can I tell forge to write my new values to the client config file? It know how to achieve this using the "old" way with configuration files but I have no idea how to do it with the annotations. Any help is appreciated. Here is the config file if it is needed: package morethanhidden.restrictedportals.config; import net.minecraftforge.common.config.Config; @Config(modid = "restrictedportals") public class RPConfiguration { @Config.Comment("The list of dimension ids.") @Config.LangKey("config.name.dimension_ids") public static int[] dimensionIds = {-1, 1}; @Config.Comment("The list of item ids that need to be in the player's inventory while entering a dimension.") @Config.LangKey("config.name.item_ids") public static String[] itemIds = {"minecraft:flint_and_steel", "minecraft:ender_eye"}; @Config.Comment({"Specifies the dimensions that require a new key each time a player visits them.", "The used key " + "will get removed from the inventory after entering the dimension."}) @Config.LangKey("config.name.teleport_player_on_fail") public static int[] oneTimeUseOnlyKeyDimensionIds = {}; @Config.Comment({"If set to true, the player will get teleported to his spawn if he fails to enter a dimension", "Useful when trying to visit the end, as you would fall into the lava otherwise."}) @Config.LangKey("config.name.onetimeuse") public static boolean teleportPlayerOnFail = true; @Config.Comment("The message displayed when a player has not the required items on him") @Config.LangKey("config.name.missing_item_message") public static String itemMissingMessage = "Please craft the following item to enter %dim%: %item%"; @Config.Comment("The message displayed when unlocking a new dimension.") @Config.LangKey("config.name.dimension_unlocked_message") public static String dimensionUnlockedMessage = "You unlocked %dim%!"; } Edit: It seems that ConfigManager#sync only lets you sync to the fields when you modify the content through the GUI. Is there some way to do it the other way, writing the static fields to the file?
  7. buildscript { repositories { jcenter() maven { url = "http://files.minecraftforge.net/maven" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT' } } repositories { maven { // JEI, McJtyLib and TOP url "http://modmaven.k-4u.nl/" } } apply plugin: 'net.minecraftforge.gradle.forge' //Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup. version = "1.0.1" group= "de.zerotask.minecraft.vanillatools" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "vanillatools" sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly. compileJava { sourceCompatibility = targetCompatibility = "1.8" } minecraft { version = "1.10.2-12.18.3.2281" runDir = "run" // the mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD snapshot are built nightly. // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. mappings = "snapshot_20161111" // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. } dependencies { // 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" // 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' // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided, // except that these dependencies get remapped to your current MCP mappings //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev' //deobfProvided '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 deobfCompile "com.github.mcjty:compatlayer:1.10-0.2.8" } 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' } } And here is my log file: https://pastebin.com/TJg8vhcj
  8. I am pretty new to modding so please keep that in mind I want to disable all vanilla swords and tried it with the following code (basically just registering a custom event handler using MinecraftForge#EVENT_BUS): @SubscribeEvent(priority = EventPriority.HIGHEST) public void onDamageTaken(LivingHurtEvent event) { // only consider any calculations if the source is the player itself Entity entity = event.getSource().getEntity(); if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; // only look for the main hand ItemStack stack = player.getHeldItemMainhand(); if (!ItemStackTools.isEmpty(stack)) { if (stack.getItem() instanceof ItemSword) { event.setCanceled(true); } } } } But for some odd reasons, as soon as I load into a world, I get a `java.lang.NoSuchMethodError: net.minecraft.util.DamageSource.getEntity()Lnet/minecraft/entity/Entity;`. To be honest, I have no idea what is going wrong here D: If I run the code within eclipse by using the gradle runClient command all works fine. But if I build the jar using `gradle build` and add it to the mods folder, the game crashes on world load. Here is the full stack trace: https://pastebin.com/3TrnL5NS I have a general idea what is happening though. Not every entitiy has a damage source I guess. And it looks like the Bat is one of them. But how would I check for that too? I tried it early on with `event.getSource().getDamageType()` but that through the same exception on mobs added by oder mods. Any help is appreciated, Sir
  9. Looks like I had some older docs open. Is there any other practically disable vanilla bows without removing the recipe?
  10. I am fairly new to Minecraft Modding (I have around 5 years Java experience). I want to prevent vanilla bows from firing. Looking into the docs for Forge I came across the ArrowNockEvent which should allow me to cancel any bow actions. But even thought the event is marked as @Cancelable, Forge still throws an IllegalArgumentException when I try to cancel the event. Here is the code if I am doing something wrong: @SubscribeEvent(priority = EventPriority.HIGHEST) public void onHit(ArrowNockEvent event) { // not sure if machines can trigger this event if (event.getEntityPlayer() != null) { ItemStack bow = event.getBow(); System.out.println(bow); System.out.println("Empty? " + ItemStackTools.isEmpty(bow)); if (!ItemStackTools.isEmpty(bow)) { if(bow.getItem() instanceof ItemBow) { event.setCanceled(true); } } } }
×
×
  • Create New...

Important Information

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