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

Nashorn


Damon
 Share

Recommended Posts

Wait!

Before you post "stop using newer java", this thread isn't meant exactly for that - it's more that I'm curious, so this is more an essay than a complaint or anything.

 

The last time I've been heading into the guts of Forge-modded Minecraft was before I started an apprenticeship, however I recently caught the news that Java 15 now saw the light of the day - and that there's a new garbace collector coming with it (sort-ish).

 

The collector I'm talking about is the Z-Garbage Collector, but I won't go into details about it. If you're curious as well, go here (I think it's super intriguing!).

And as all things go, curious me installed the latest openjdk version (can't be bothered to take the Sun JRE - yet), just to be greeted with what had been coming with Java 11 (?): Nashorn is no more! And, well, as was my Minecraft process. 
Forge's Coremod Engine appears to depend on it in some way.

 

In particular, it appears that loading coremods is what causes the coupling, which is surprising for me.
As far as I know, Nashorn is a Javascript Engine and I'd normally expect to see one of those in the vincinity of the Web APIs I build at my workplace, so why should it end up in Minecraft, out of all places?

Well, I did some more research.

 

I started out with looking for the CoreModEngine class on GitHub, only to find it not being located in Forge itself.

Then were does it come from? Here!

 

Core Mods, according to the project description, are supposed to only do replacements of certain hardocded things. Well, that's at least how much has settled in my mind from briefly skimming the introduction, but it also stated that coremod loading is based on Javascript because of exactly this reason: Keep the core-modding clean(er)(ish)(I think?).

 

But what does this mean for Forge? Well, I think it is safe to say that Forge depends on the CoreMod part. This means that if Forge considerd to add support for newer Java versions, the CoreMod part would need to be updatet.

Updating, however, doesn't necessarily mean that Nashorn must be replaced!

 

OpenJDK has a repo up for Nashorn exclusively, you can check it out here.

Whether or not that will be enough for the module stuff introduced in a version after 8 (lost interest in Java around that time) is something I cannot assess, however I think that we might be able to, well, actually do that.

 

Possibly.

 

If this cannot be done for some reason my lacking experience disallows me to comprehend, well, it'd mean that the respective could would need to be replaced, which seems like a PITA, just judging from what I have seen so far.


 

But that sums it up for this post!

 

 

Best Regards.

Edited by Damon
Removed the Header sublink of the zgc Link
Link to comment
Share on other sites

Most of what you have said the Forge team is well aware of :) In fact the CoreMod repository is made by the same people who write Forge, it is only used by Forge.

There have already been plans for replacing Nashorn with Rhino, prior to the announcement of OpenJDK continuing Nashorn as a standalone project.

 

And you can trust that Forge will work on Java 15 and beyond at some point - it is just not the highest of priorities, after all Mojang still targets and ships Java 8.

Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

Most of what you have said the Forge team is well aware of :) In fact the CoreMod repository is made by the same people who write Forge, it is only used by Forge.

There have already been plans for replacing Nashorn with Rhino, prior to the announcement of OpenJDK continuing Nashorn as a standalone project.

 

And you can trust that Forge will work on Java 15 and beyond at some point - it is just not the highest of priorities, after all Mojang still targets and ships Java 8.

Let me apologize first, I didn't mean to make it sound like you guys wouldn't know about this already!

 

I tried to skim the forums for a little but stopped after page 2 of the search results 😅

However, I wanted to write down my process of thought so that any other curious User, who has wondered about the same things, might stumble upon this one day.

That is, by the way, why I really hope that the information I amassed up is correct.

 

But despite the danger of drifting into off-topic here: How many other bigger issues with Java version bumps are out there, still? The module aspect is what I could imagine, but were any other bigger changes introduced since the release of Java 9/10?

 

I never thought about users playing Minecraft on rigs that support Java 8 to their max, however. I remember that Mojang did the Version bump to Java 8 with the knowledge that, iirc, less than 1% of the playerbase was still on Java 7.

 

Assuming this is actually an issue: Would Mojang be willing to share such information with the dev team?

 

 

 

Link to comment
Share on other sites

I don't think there are other fundamental issues like the module system that lie ahead now. How can I say that? Well, during the 1.13 update Forge rewrote much of its internal tools and infrastructure, such as the whole loader (the new "CoreMods" repository is part of that). This new system uses much more standard Java mechanics instead of the "ugly hacks" that were employed previously (which ceased to work on Java 9).

 

11 hours ago, Damon said:

I never thought about users playing Minecraft on rigs that support Java 8 to their max, however.

That's not what I am saying. What I am saying is that Mojang ships Java 8 in their launcher, so that is what they target and what Forge must target as well, at least as the main target.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • 1.17 uses Mojang class names. The class is now called MobEffect. You can use forge-bot on the Forge Discord to convert.
    • Hi i have a problem since 1.17.1 is "new" i'm not able to find the class net.minecraft.potion.Effect. And if i can't extend that class then i can't make my potion effect. So does anyone know where that class is ? and do you guys have a tutorial on how to make a potion effect in 1.16.5 or 1.17.1 because i can't find any tutorial about it. Thank you for helping!!!
    • Why the fak are you to-stringing that? if(source instanceof ImpactDamage) works just fine. You could also create single static instances of your new damage type and use things like ModDamageTypes.SLASHING and the == operator, like vanilla does. Your damage type instances have NO custom data in them at all, so you should just do that (yes I realize my own, very old, code is not following that). This is not how localization works. ItemStacks are never null. The player could be, though. Use ifPresent() instead. You should use the logger Forge provides you instead.
    • When an entity is attacked it has a few ticks of damage resistance during which time no further damage can be applied. You have to set Entity#invulnerableTime to 0 after applying the damage if you want further damage to apply on the same tick.
    • Thanks for the advice, I'm now able to get the events working to a degree. The issue I'm having now is this: I have a capability for both damage type and damage resistance. There are 3 new damage types that each have a corresponding resistance. Damage type capabilities are attached to weapons, while resistance capabilities are applied to entities. I use the following methods to apply extra damage types as well as calculate resistances. The problem is that when attacking an entity, only 1 instance of the new damage types is applied. As for the debugging messages, the 3 sendMessages are being sent in the extraDamage method. In the damageResistance method, only 1 System.out.println statement is being sent. Is there something to do with the way LivingHurtEvent works that only allowed 1 to be applied? package com.cwjn.hardstuckintegration.Events; import com.cwjn.hardstuckintegration.Capabilities.DamageTypes.CapabilityDamageTypes; import com.cwjn.hardstuckintegration.Capabilities.DamageTypes.IDamageTypes; import com.cwjn.hardstuckintegration.Capabilities.Resistances.CapabilityDamageResistance; import com.cwjn.hardstuckintegration.Capabilities.Resistances.IDamageResistance; import com.cwjn.hardstuckintegration.DamageTypes.ImpactDamage; import com.cwjn.hardstuckintegration.DamageTypes.NewType; import com.cwjn.hardstuckintegration.DamageTypes.PunctureDamage; import com.cwjn.hardstuckintegration.DamageTypes.SlashDamage; import com.cwjn.hardstuckintegration.HardstuckIntegration; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.Hand; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.AttackEntityEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(modid = HardstuckIntegration.modID) public class DamageEvents { @SubscribeEvent public static void extraDamage(AttackEntityEvent event) { PlayerEntity player = event.getPlayer(); //player that is attacking Entity target = event.getTarget(); //target being attacked ItemStack item = player.getItemInHand(Hand.MAIN_HAND); //item used to attack if (item != null) { IDamageTypes damage = item.getCapability(CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY).orElse(null); //get the extra damage types if (damage != null) { float impactDamage = damage.getImpactDamage(); float slashDamage = damage.getSlashDamage(); //store the extra damage types float punctureDamage = damage.getPunctureDamage(); if (impactDamage > 0) { player.sendMessage(new TranslationTextComponent("TARGET ENTITY DEALT: " + impactDamage + " POINTS OF IMPACT DAMAGE"), player.getUUID()); target.hurt(new ImpactDamage(), impactDamage); //if the item has extra impact damage, hurt the target with an instance of impact damage } if (slashDamage > 0) { player.sendMessage(new TranslationTextComponent("TARGET ENTITY DEALT: " + slashDamage + " POINTS OF SLASH DAMAGE"), player.getUUID()); target.hurt(new SlashDamage(), slashDamage); //if the item has extra slash damage, hurt the target with an instance of slash damage } if (punctureDamage > 0) { player.sendMessage(new TranslationTextComponent("TARGET ENTITY DEALT: " + punctureDamage + " POINTS OF PUNCTURE DAMAGE"), player.getUUID()); target.hurt(new PunctureDamage(), punctureDamage); //if the item has extra puncture damage, hurt the target with an instance of puncture damage } } } } @SubscribeEvent public static void damageResistance(LivingHurtEvent event) { DamageSource source = event.getSource(); //source of damage if (source instanceof NewType) { //check if the source is a subclass of the new damage types added with this mod float amount = event.getAmount(); //get initial amount of new damage, before resistances LivingEntity target = event.getEntityLiving(); //target of damage float newDamage = amount; //variable to hold post-resistance calculation damage IDamageResistance res = target.getCapability(CapabilityDamageResistance.DAMAGE_RESISTANCE_CAPABILITY).orElse(null); //get target's resistances if (res != null) { float impactRes = res.getImpactResistance(); float slashRes = res.getSlashResistance(); //store the resistances float punctureRes = res.getPunctureResistance(); switch (((NewType) source).getSourceAsString()) { //get the the source of damage as a string case "slash": if (slashRes > 0) newDamage = (amount * (100 / (100 + slashRes))); //if the target has resistances, apply math to reduce damage. else if (slashRes < 0) newDamage = (amount * (2 - (100 / (100 - slashRes)))); //if the target has negative resistances, apply math to boost damage. else newDamage = amount; //if the target has no resistances, apply initial damage unchanged System.out.println("TARGET ENTITY TOOK: " + newDamage + " SLASH DAMAGE"); //used for debugging break; case "puncture": //same as case slash, but for puncture damage if (punctureRes > 0) newDamage = (amount * (100 / (100 + punctureRes))); else if (punctureRes < 0) newDamage = (amount * (2 - (100 / (100 - punctureRes)))); else newDamage = amount; System.out.println("TARGET ENTITY TOOK: " + newDamage + " PUNCTURE DAMAGE"); break; case "impact": //same as case slash, but for impact damage if (impactRes > 0) newDamage = (amount * (100 / (100 + impactRes))); else if (impactRes < 0) newDamage = (amount * (2 - (100 / (100 - impactRes)))); else newDamage = amount; System.out.println("TARGET ENTITY TOOK: " + newDamage + " IMPACT DAMAGE"); break; } } event.setAmount(newDamage); //apply post-resistance calculation damage to the event } } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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