Skip to content

Commit

Permalink
Merge branch '1.21'
Browse files Browse the repository at this point in the history
* 1.21:
  Better condition check
  2.0.14
  • Loading branch information
Faboslav committed Jul 15, 2024
2 parents bb41d09 + 8c010ea commit db0fcad
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.14

- Totem of Undying is now properly supported in the modded slots
- Fixed stronghold generation freeze on 1.21

## 2.0.13

- Rascal spawn condition improvements
Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"LightningRodBlockMixin",
"LightningRodBlockOxidizableMixin",
"LimbAnimatorAccessor",
"LivingEntityMixin",
"PatrolSpawnerAccessor",
"PatrolSpawnerMixin",
"PlayerEntityMixin",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.caching=true
# Mod
mod_name=Friends&Foes
mod_id=friendsandfoes
mod_version=2.0.13
mod_version=2.0.14
mod_author=Faboslav
mod_description=Adds outvoted and forgotten mobs from the mob votes in a believable vanilla plus style.
maven_group=com.faboslav.friendsandfoes
Expand Down

0 comments on commit db0fcad

Please sign in to comment.