Skip to content
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

Let vanilla try to handle Container interactions before checking for item handlers #1787

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from

Conversation

Technici4n
Copy link
Member

Move our IItemHandler interaction hooks after vanilla checks for Container interactions. This gives vanilla control over interactions with Containers. Fixes #1750. Fixes #1770. (Did not test the latter but I assume it gets fixed).
As a side effect, this greatly simplifies our hooks since we don't need to handle vanilla edge cases such as hopper - hopper interactions having special interactions when it comes to cooldowns.

Breaking change

Modders need to be careful that their Containers will be interacted with as Containers before an item handler is even attempted to be found. I'd suggest not implementing Container directly on block entities to avoid this problem. Nevertheless, this counts as a breaking change.

Lookup order

Currently, Container entities are preferred over IItemHandler blocks. What do people think about that?

Current order: Container block > Container entity > IItemHandler block > IItemHandler entity.

I think that it would be preferable to check in this order: Container block > IItemHandler block > Container entity > IItemHandler entity.

@neoforged-automation neoforged-automation bot added bug A bug or error 1.21.4 Targeted at Minecraft 1.21.4 labels Dec 18, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Dec 18, 2024

  • Publish PR to GitHub Packages

Last commit published: 09a52dd7a80f89fcb84e7a099d7a120f4e4a107d.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #1787' // https://github.com/neoforged/NeoForge/pull/1787
        url 'https://prmaven.neoforged.net/NeoForge/pr1787'
        content {
            includeModule('net.neoforged', 'testframework')
            includeModule('net.neoforged', 'neoforge')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1787.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr1787
cd NeoForge-pr1787
curl -L https://prmaven.neoforged.net/NeoForge/pr1787/net/neoforged/neoforge/21.4.34-beta-pr-1787-fix-vanilla-inv-hooks/mdk-pr1787.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.

@neoforged-compatibility-checks

@Technici4n, this PR introduces breaking changes.
Fortunately, this project is currently accepting breaking changes, but if they are not intentional, please revert them.
Last checked commit: 09a52dd7a80f89fcb84e7a099d7a120f4e4a107d.

Compatibility checks

neoforge (:neoforge)

  • net/minecraft/client/renderer/entity/layers/EquipmentLayerRenderer
    • getArmorModelHook(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/client/model/Model;)Lnet/minecraft/client/model/Model;: ❗ API method was removed
  • net/neoforged/neoforge/client/ClientHooks
    • getArmorModel(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/client/resources/model/EquipmentClientInfo$LayerType;Lnet/minecraft/client/model/Model;)Lnet/minecraft/client/model/Model;: ❗ API method was removed
  • net/neoforged/neoforge/items/VanillaInventoryCodeHooks
    • dropperInsertHook(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/DispenserBlockEntity;ILnet/minecraft/world/item/ItemStack;)Z: ❗ API method was removed
    • insertCrafterOutput(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/CrafterBlockEntity;Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/item/ItemStack;: ❗ API method was removed
    • extractHook(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/level/block/entity/Hopper;)Ljava/lang/Boolean;: ❗ API method was removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.4 Targeted at Minecraft 1.21.4 bug A bug or error
Projects
None yet
1 participant