File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/forge_cap_retrieval Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .embeddedt .modernfix .forge .mixin .perf .forge_cap_retrieval ;
2+
3+ import net .minecraft .core .Direction ;
4+ import net .minecraft .world .entity .LivingEntity ;
5+ import net .minecraftforge .common .capabilities .Capability ;
6+ import net .minecraftforge .items .CapabilityItemHandler ;
7+ import org .spongepowered .asm .mixin .Mixin ;
8+ import org .spongepowered .asm .mixin .injection .At ;
9+ import org .spongepowered .asm .mixin .injection .Redirect ;
10+
11+ import javax .annotation .Nullable ;
12+
13+ @ Mixin (LivingEntity .class )
14+ public class LivingEntityMixin {
15+ /**
16+ * @author embeddedt (issue noted by XFactHD)
17+ * @reason check capability equality before checking that entity is alive, the latter requires a lot more
18+ * indirection
19+ */
20+ @ Redirect (method = "getCapability" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/world/entity/LivingEntity;isAlive()Z" ))
21+ private <T > boolean checkAliveAfterCap (LivingEntity entity , Capability <T > capability , @ Nullable Direction facing ) {
22+ return capability == CapabilityItemHandler .ITEM_HANDLER_CAPABILITY && entity .isAlive ();
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments