Comments (32)
Excellent work!
Now, let's hope for a soon resolution of Duke Nukem Fabric Configs Forever.
from fabric-loader.
While this is a personal statement and not an opinion necessarily shared by the devteam, I have to ask: How is it fair for us to be modifying Mojang's game but not allowing us to modify one another?
from fabric-loader.
"Should" doesn't mean "we should formally block it", though. There are many things you shouldn't do but we don't ban them outright. I don't think we're in a position to be judges.
If it causes additional implementation hurdles (and ATs on mods would), that's another story.
from fabric-loader.
@RedstoneParadox We're talking about Mojang, who doesn't really design the engine with modding in mind.
from fabric-loader.
@Darkhax It has potential value in terms of putting slightly stronger thread safety guarantees without injecting ThreadLocals and thus breaking existing code. I'm not sure if it's practically useful, though.
Notice that all of those weaken available assumptions. This is the common motive. public weakens the assumption that, say, a method can only be accessed in one package; mutable weakens the assumptions that a field will never be written to twice; likewise, volatile weakens the assumption that the field may be stored in one core's CPU cache only without pushing it off to RAM (Without volatile, it may be pushed off to RAM at any time; with volatile, it must be after the write has been done).
I was, in essence, digging through the access flags available to classes, fields and methods. I found that synchronized/native could have had some value to methods, but those are best added with a mixin IMO.
from fabric-loader.
FabricBlockSettings probably isn't the best example, since we depend on it for a few other things like breakByTool
, drops
, and dynamicBounds
.
from fabric-loader.
I know, but you get the gist. Maybe gamerules migt be a better example, if I recall correctly.
from fabric-loader.
Another thing to keep in mind: constructor visibility, and extend
ing classes with non-public
constructors.
from fabric-loader.
I'm a firm believer that if someone sets their class to private or package-private, then we shouldn't mess with that choice; if they want to allow other people to use Mixins on their class, then they will set it to public, so I'm voting for number 2.
from fabric-loader.
Well, yeah, but modders should have some way to protect their stuff from outside modification.
from fabric-loader.
Good point.
from fabric-loader.
-
Its not working as is and something extra needs to be done.
-
I think just adding them is honestly going to sort out all of the issues, one idea would be for fabric to contain the most commonly used AT's, this way you have a good chance of mods just working when you drop their source code into your IDE.
This does slow up loading a little bit but im not sure it will be that bad?
PomfYarn could also include some AT's to allow more freedom when mapping things out -
Doesn't cover all the cases, more would still be needed
-
Having a helper class would be nice but does have some issues. I can see it getting messy quite quickly if you need to use it a lot, and what is the performance like? Slower loading is a lot better to have than lower in game performance.
from fabric-loader.
There's one more option. Not allow everyone to use ATs, but have a communal repo--similar to Yarn--with ATs that people who present decent cases can add their ATs to. This repo would have to be very strict about accepting PRs after a lot of reviews and input. Ideally, someone can suggest a better way to do what the person needs to do without ATs, but if not, then they get added.
I'm not saying I necessarily like this solution but it's another idea.
from fabric-loader.
We considered this, but one of our cornerstones was "everyone has fair access to the same tools". Allowing only us to define ATs would go against this principle, even if it solves some of the logistics.
from fabric-loader.
Based on my limited knowledge, Approach 4 seemed the most logical to me.
from fabric-loader.
I think this kind of tooling should only be used on vanilla classes because we're available to change APIs, unlike Mojang. It is nothing more than a scapegoat and should be treated as such.
Just add transformers.
from fabric-loader.
Access transformer rough spec:
- Can only be used on Minecraft JAR classes. Period.
net/minecraft/block/Block.field_1234: public mutable
net/minecraft/block/Block$Builder.method_2600: protected # I'm a comment!
net/minecraft/block/Block$Builder.<init>(Lnet/minecraft/block/Material;): protected
# I'm a comment too!
(Well, in practice, you'd have class_... there, but just for the sake of example)
- Allowed keywords:
- public - upgrades the access visibility to public,
- protected - upgrades the access visibility to protected,
- mutable - removes finality, if present,
- volatile - adds the volatile access flag, if not present.
- Operations which can break other existing code (downgrading access visibility, adding finality, removing volatility...) are forbidden by Fabric, though additional keywords could be added by other implementations.
from fabric-loader.
That AT spec looks good to me. I am curious about the inclusion of volatile in this list though. Do you have any examples of why it would be needed, or is it there because it could have some potential value and wouldn't be able to mess things up too badly?
from fabric-loader.
This can be worked around, though: simply copy the prepared .JAR, only edit the classes which have changed, then only decompile those classes!
This might not always work. If a class contains the two methods:
public void someMethod(Object o) { ... }
private void someMethod(String o) { ... }
then making someMethod(String)
public would mean that that calls to something.someMethod("abc")
in other classes would now refer to someMethod(String)
rather than someMethod(Object)
. All classes invoking the method transformed would have to be redecompiled such that a cast is added by the decompiler: something.someMethod((Object) "abc")
.
from fabric-loader.
No, because the actual bytecode in all the classes still calls someMethod(Ljava/lang/Object;)V
from fabric-loader.
But not the source code. The source code for all classes that call the method with a string argument will now be wrong.
from fabric-loader.
Ah, I see what you mean now. Yeah, that's a problem. I thought you meant that the game's behavior will change because now the wrong methods get called, which as far as I know, won't happen (of course, it will happen if anything in the mod's source code calls one of those methods, but that's going to happen either way)
from fabric-loader.
@Runemoro The source code is only for viewing in the IDE; I think this cost can be paid, so to say, especially as such cases are fairly uncommon regardless.
from fabric-loader.
The colon is extra noise, owner should be optional and discouraged for uid named members to avoid missing overridden methods, propagation should be disallowed per spec, classes have no owner, everything has to use uids, volatile is imo unreasonable at this point/out of scope.
Volatile is generally not sufficient to make something thread safe, it remains as racy as swapping an underlying collection with a thread safe one. All accesses need to treat the value as "unstable", which generally requires a larger edit. The above description about "weakening" is debatable, volatile incurs strong access ordering and doesn't make anything more extensible contrary to the other options.
The AT documentation should have a precise BNF grammar and specifically warn about the following:
- Removing final or private from classes or methods can lead to significantly reduced performance and memory overhead from virtual calls and vtables
- Removing final from fields can lead to thread safety problems. Final instance fields are guaranteed to be initialized and visibly set to other threads when construction finished, normal fields are not. This matters when exposing a new object to another thread without further synchronization.
- Removing final from static fields may also miss any compile time constant folding and incur a performance penalty from preventing runtime constant folding by the JIT compiler. JavaC turns accesses to primitive or String field accesses to inline or constant pool values, merges them with other values or elides them completely as appropriate. For the JIT compiler static final fields are the only constants, everything else is being treated as mutable at this time.
- Any change increases the incompatibility risk by exposing internals that may have been modified by other mods or may have been expected to work in a certain limited way
- Increasing the visibility of a method may change the resolution result with overloads or conflicting signatures
from fabric-loader.
What about (optionally, depending on a setting in build.gradle) making everything public and having loom infer the minimum necessary access transformers? This would avoid having to recompile the code after every access transformer change, and it would also be very easy to use.
To make sure people are aware when they use private things, an annotation could be added to the things that are not actually public and warnings (or errors?) can be generated unless the method/class using them has an @AllowPrivateAccess
annotation.
from fabric-loader.
Imo we should not touch private stuff, but handling/transforming package-private content to be protected/public with extra mixin hook or some sort of access transformer should be allowed.
from fabric-loader.
yeah, classes are the primary issue here. There are juuust enough private classes in key areas to be a major hassle, so either A) transforming all private/package-private classes to be public or B) adding ATs to do that would be wonderful.
from fabric-loader.
Is there any performance/possible issues with making them all public?
At runtime it could be baked into the intermediary jar.
from fabric-loader.
I think at-s would be a good choice. Let me tell the game "this needs to be public" instead of trying to figure out what we need to make public, or just making everything public (bad idea).
It could also replace some of the existing apis, like the fabric block settings, as we can use the original (those should reduce maintainance effort on the side of fabric, even if just by a bit).
from fabric-loader.
blowing all classes to be public instead of package private should be relatively safe compared to making private methods protected. there is no potential conflict.
from fabric-loader.
package private fields/methods should not be transformed; mixin already has a good take on them.
from fabric-loader.
This has now been handled with 5093f50
Only took 15 months.
from fabric-loader.
Related Issues (20)
- "jar in jar" is not being loaded correctly HOT 3
- I'm having a crash issues with 1.21 HOT 1
- Uncaught exception in thread "main"
- Droplets measurement making datapack incompatible HOT 3
- Backend library: LWJGL version does not always match vanilla output HOT 5
- Depedency overrides do not override existing depedency constratains.
- FabricLoader#getGameDir can return invalid path when using dedicated server HOT 2
- FABRIC CRASH
- Uncaught exception in thread "main" HOT 1
- Crash problem: Ticking player
- fabric crashes when opening with error code: 1 HOT 1
- Errors in Minecraft Fabric 1.21
- Debugging option to list mods with an access widener for items
- No-launcher: JOptSimple: Found multiple arguments HOT 1
- [Feature] FMJ Spec API
- Fabric Loader V 0.16.0 does not appear to accept `name=` for `@ModifyVariable` nor `@Local` HOT 2
- Fabric Loader tries to read a .pom file as a zip file HOT 2
- I play server on version 1.21 but after playing for a while I left the text network protocol errorserver with text HOT 2
- server mixin loaded on physical client HOT 1
- Help my game looks like this and my mods not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fabric-loader.