Applied Energistics 2

Applied Energistics 2

137M Downloads

[Forge] Wrench compatibility with other mods

Technici4n opened this issue ยท 4 comments

commented

How should this be handled? We are currently using the following tool actions:

    /**
     * An action that is triggered by right-clicking a supported block or part, which will disassemble that block or
     * part into its item form.
     */
    public static final ToolAction WRENCH_DISASSEMBLE = ToolAction.get("wrench_disassemble");

    /**
     * An action that is triggered by shift-right-clicking a supported block or part, which will rotate that part.
     */
    public static final ToolAction WRENCH_ROTATE = ToolAction.get("wrench_rotate");

Implementing a wrench is as simple as:

public class QuartzWrenchItem extends AEBaseItem {
    public QuartzWrenchItem(Item.Properties props) {
        super(props);
    }

    @Override
    public boolean canPerformAction(ItemStack stack, ToolAction toolAction) {
        if (toolAction == AEToolActions.WRENCH_DISASSEMBLE || toolAction == AEToolActions.WRENCH_ROTATE) {
            return true;
        }
        return super.canPerformAction(stack, toolAction);
    }
}

And checking if a block can be wrenched is handled in an event: https://github.com/AppliedEnergistics/Applied-Energistics-2/blob/forge/master/src/main/java/appeng/hooks/WrenchHook.java.

Is this approach ok for other modders, or would you prefer tags? So just supporting any item tagged with #forge:wrenches.

Going to ask a few people, don't hesitate to leave a comment on your preferred approach.

commented

(I personally think tags would be easier, I don't think the tool action system is really useful here since most wrenches should just be simple items that unlock wrenching functionality... with tags they could just be direct Item instances).

commented

As a non mod author i like tags, it allows me to add support for any item with just a datapack, and not relying on the mod author to do it.

commented

As discussed a long time ago between a few modders (KingLemming and me) we're already using the tag 'forge:wrench' for this

commented

Had some discussion with @McJty on the Forge discord, and we've agreed to use forge:tools/wrench. This happens to be what Thermal is already using.