-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1.21: Better condition check 2.0.14
- Loading branch information
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
common/src/main/java/com/faboslav/friendsandfoes/mixin/LivingEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.faboslav.friendsandfoes.mixin; | ||
|
||
import com.faboslav.friendsandfoes.modcompat.ModChecker; | ||
import com.faboslav.friendsandfoes.modcompat.ModCompat; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
import net.minecraft.util.Hand; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(LivingEntity.class) | ||
public class LivingEntityMixin | ||
{ | ||
@WrapOperation( | ||
method = "tryUseTotem", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/LivingEntity;getStackInHand(Lnet/minecraft/util/Hand;)Lnet/minecraft/item/ItemStack;") | ||
) | ||
private ItemStack friendsandfoes_getStackInCustomSlots( | ||
LivingEntity instance, | ||
Hand hand, | ||
Operation<ItemStack> original | ||
) { | ||
var itemStackInHand = original.call(instance, hand); | ||
|
||
if (itemStackInHand.getItem() != Items.TOTEM_OF_UNDYING) { | ||
for (ModCompat compat : ModChecker.CUSTOM_EQUIPMENT_SLOTS_COMPATS) { | ||
ItemStack itemStack = compat.getEquippedItemFromCustomSlots(instance, LivingEntityMixin::friendsandfoes_isTotemOfUndying); | ||
|
||
if (itemStack != null) { | ||
return itemStack; | ||
} | ||
} | ||
} | ||
|
||
return itemStackInHand; | ||
} | ||
|
||
private static boolean friendsandfoes_isTotemOfUndying(ItemStack itemStack) { | ||
return itemStack.getItem() == Items.TOTEM_OF_UNDYING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters