Skip to content

Cancelling a constructor [CandleCakeBlock] #1525

Discussion options

You must be logged in to vote

The solution in this particular instance was to use a redirect at the invocation of the .put call. From there we can cancel the call on the condition that it's one of the cake blocks that I'm adding in. Which is exactly what I wanted.

@Redirect(method = "<init>", at = @At(value = "INVOKE", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
private <K, V> V put(Map<K, V> map, K key, V value) {
    return value instanceof BasicCandleCakeBlock ? null : map.put(key, value);
}

Credit to deirn on discord for this solution

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hugeblank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants