Skip to content

Commit 8c38e32

Browse files
committed
re-add armor slot mixin
close #214
1 parent 53c641b commit 8c38e32

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package de.teamlapen.werewolves.mixin;
2+
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import de.teamlapen.werewolves.api.entities.player.IWerewolfPlayer;
6+
import de.teamlapen.werewolves.api.items.IWerewolfArmor;
7+
import de.teamlapen.werewolves.entities.player.werewolf.WerewolfPlayer;
8+
import net.minecraft.world.entity.EquipmentSlot;
9+
import net.minecraft.world.entity.LivingEntity;
10+
import net.minecraft.world.entity.player.Player;
11+
import net.minecraft.world.inventory.ArmorSlot;
12+
import net.minecraft.world.item.ItemStack;
13+
import org.spongepowered.asm.mixin.Mixin;
14+
import org.spongepowered.asm.mixin.injection.At;
15+
16+
@Mixin(ArmorSlot.class)
17+
public class ArmorSlotMixin {
18+
19+
@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"))
20+
private boolean test(ItemStack instance, EquipmentSlot equipmentSlot, LivingEntity entity, Operation<Boolean> original) {
21+
if (entity instanceof Player player && !(instance.getItem() instanceof IWerewolfArmor) && !WerewolfPlayer.get(player).canWearArmor(instance)) {
22+
return false;
23+
}
24+
return original.call(instance, equipmentSlot, entity);
25+
}
26+
}

src/main/resources/META-INF/accesstransformer.cfg

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ public net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer m_17451
1010
public net.minecraft.client.renderer.entity.layers.PlayerItemInHandLayer f_234864_ # itemInHandRenderer
1111
public net.minecraft.world.level.biome.MultiNoiseBiomeSourceParameterList$Preset$SourceProvider
1212

13-
protected net.minecraft.data.recipes.RecipeProvider m_236371_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # chestBoat
13+
protected net.minecraft.data.recipes.RecipeProvider m_236371_(Ljava/util/function/Consumer;Lnet/minecraft/world/level/ItemLike;Lnet/minecraft/world/level/ItemLike;)V # chestBoat
14+
public net.minecraft.world.inventory.ArmorSlot

src/main/resources/werewolves.mixins.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"compatibilityLevel": "JAVA_21",
55
"plugin": "de.teamlapen.werewolves.WerewolvesMixinConfigPlugin",
66
"mixins": [
7+
"ArmorSlotMixin",
78
"BlockFamiliesAccessor",
89
"FoodStatsAccessor",
910
"GoalSelectorAccessor",

0 commit comments

Comments
 (0)