Skip to content

Commit

Permalink
re-add armor slot mixin
Browse files Browse the repository at this point in the history
close #214
  • Loading branch information
Cheaterpaul committed Oct 18, 2024
1 parent 53c641b commit 8c38e32
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/main/java/de/teamlapen/werewolves/mixin/ArmorSlotMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.teamlapen.werewolves.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import de.teamlapen.werewolves.api.entities.player.IWerewolfPlayer;
import de.teamlapen.werewolves.api.items.IWerewolfArmor;
import de.teamlapen.werewolves.entities.player.werewolf.WerewolfPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.ArmorSlot;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(ArmorSlot.class)
public class ArmorSlotMixin {

@WrapOperation(method = "mayPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;canEquip(Lnet/minecraft/world/entity/EquipmentSlot;Lnet/minecraft/world/entity/LivingEntity;)Z"))
private boolean test(ItemStack instance, EquipmentSlot equipmentSlot, LivingEntity entity, Operation<Boolean> original) {
if (entity instanceof Player player && !(instance.getItem() instanceof IWerewolfArmor) && !WerewolfPlayer.get(player).canWearArmor(instance)) {
return false;
}
return original.call(instance, equipmentSlot, entity);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ public net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer m_17451
public net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer f_234864_ # itemInHandRenderer
public net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList$Preset$SourceProvider

protected net.minecraft.data.recipes.RecipeProvider m_236371_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # chestBoat
protected net.minecraft.data.recipes.RecipeProvider m_236371_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # chestBoat
public net.minecraft.world.inventory.ArmorSlot
1 change: 1 addition & 0 deletions src/main/resources/werewolves.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"compatibilityLevel": "JAVA_21",
"plugin": "de.teamlapen.werewolves.WerewolvesMixinConfigPlugin",
"mixins": [
"ArmorSlotMixin",
"BlockFamiliesAccessor",
"FoodStatsAccessor",
"GoalSelectorAccessor",
Expand Down

0 comments on commit 8c38e32

Please sign in to comment.