Skip to content

Commit

Permalink
Revert "Allowing injecting in constructor's (FabricMC#30 FabricMC#40)"
Browse files Browse the repository at this point in the history
This reverts commit 536170a.
  • Loading branch information
LlamaLad7 committed May 19, 2024
1 parent 3a090bd commit 9cf325d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,6 @@ public boolean checkPriority(int targetPriority, int mixinPriority) {
* @return restriction level
*/
public RestrictTargetLevel getTargetRestriction(IInjectionPointContext context) {
return RestrictTargetLevel.CONSTRUCTORS_AFTER_DELEGATE; // Fabric change: allow inject in constructors
}

/**
* Returns the target restriction level for this injection point's cancellation for
* {@literal @Inject} annotations. This level defines whether an injection point
* can declare {@code cancellable = true}.
*
* @param context injection-specific context
* @return restriction level
*/
// Fabric addition: prevent cancellation of inject in constructors
public RestrictTargetLevel getCancellationRestriction(IInjectionPointContext context) {
return RestrictTargetLevel.METHODS_ONLY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,6 @@ protected void addTargetNode(Target target, List<InjectionNode> myNodes, Abstrac
throw new InvalidInjectionException(this.info, String.format("%s selector %s", ip, ex.getMessage()));
}

// Fabric start: prevent cancellation in constructor injections
if (this.cancellable) {
try {
this.checkTargetForNode(target, injectionNode, ip.getCancellationRestriction(this.info));
} catch (InvalidInjectionException ex) {
throw new InvalidInjectionException(this.info, String.format("%s selector (cancellable = true) %s", ip, ex.getMessage()));
}
}
// Fabric end

String id = ip.getId();
if (Strings.isNullOrEmpty(id)) {
continue;
Expand Down

0 comments on commit 9cf325d

Please sign in to comment.