-
-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce proxyable and non-proxyable block capabilities #1446
base: 1.21.x
Are you sure you want to change the base?
Conversation
Last commit published: c312629e710d451aa01c34e39518f0af32497541. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #1446' // https://github.com/neoforged/NeoForge/pull/1446
url 'https://prmaven.neoforged.net/NeoForge/pr1446'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr1446
cd NeoForge-pr1446
curl -L https://prmaven.neoforged.net/NeoForge/pr1446/net/neoforged/neoforge/21.1.10-pr-1446-non-proxyable-block-caps/mdk-pr1446.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
I don't agree with this approach. Forwarding any capability you don't know the semantics of is a Very Bad Idea and should not be done. Explicitly allowing other mods to handle unknown capabilities in random ways only opens the door for even more semantics-breaking uses. I see no way I would ever not set A better solution would be to include an original target specifier to getCapability, which would allow proper handling of requests for capabilities that were forwarded (this is how http handles this). That way, the code that knows the semantics of a capability (because it hands it out) can properly handle forwarded requests if it needs to. This also would enable bidirectional requests like they are required for cable connections (although those would be tricky to implement as it breaks the assumption that each block side can have exactly one connection, something that will remain true in rendering the connection). |
Mods have been doing this for some time, for example Capability Proxy or Entangled. It is quite clearly useful for the capabilities where it is safe.
The point here is that a lot of "transfer" capabilities, which are the ones that players generally want to proxy, are completely safe to proxy. This includes for example all of NeoForge's builtin block capabilities, as well as Mekanism gasses for example.
This would make the capability provider interface more complicated for everyone, in order to address what is pretty much a niche feature. There might be other solutions to this problem, but that doesn't feel like one. An alternative is to flip the default: make capabilities non-proxyable by default, and require opt-in for capabilities where it makes sense. |
This approach looks good to me, should be straightforward to implement into Capability Proxy.
I agree this could be beneficial. But given the invasiveness of such changes, it would probably be better to keep it as a future (possible breaking) change, and continue with this PR here in the short-term. |
* | ||
* @see BlockCapability#isProxyable() | ||
*/ | ||
public void setNonProxyable(BlockCapability<?, ?> capability) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible to be made to be chained so that we could call something like
BlockCapability<SomeClass, Void> BLOCK = BlockCapability.createVoid(resource("some_handler"), SomeClass.class).nonProxyable();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan for the reason that it is dependent on classloading, and might be called at any time.
Some capabilities are not safe to forward to another block. For example, AE2 has such a capability (that is used to find ME Network components). This can result in nonsensical connections, and even in crashes in some cases with mods like Capability Proxy.
This PR proposes that block capabilities may be marked as not being proxyable. Mods like Capability Proxy should stop proxying such capabilities. cc @rubensworks