From f77ae4d1869e702c17dbfe75161ed20975353fc2 Mon Sep 17 00:00:00 2001 From: SLH335 <114884726+SLH335@users.noreply.github.com> Date: Thu, 25 Apr 2024 04:42:35 +0200 Subject: [PATCH] Add Netherite Wolf Armor --- .../netheriteextras/item/ModItems.java | 5 ++ .../item/NetheriteWolfArmorItem.java | 18 +++++ .../mixin/NetheriteWolfArmorEquipMixin.java | 63 ++++++++++++++++++ .../assets/netheriteextras/lang/de_de.json | 1 + .../assets/netheriteextras/lang/en_pt.json | 1 + .../assets/netheriteextras/lang/en_us.json | 1 + .../models/item/netherite_wolf_armor.json | 6 ++ .../entity/wolf/wolf_armor_netherite.png | Bin 0 -> 1466 bytes .../textures/item/netherite_wolf_armor.png | Bin 0 -> 836 bytes .../resources/netheriteextras.mixins.json | 1 + 10 files changed, 96 insertions(+) create mode 100644 src/main/java/xyz/hafemann/netheriteextras/item/NetheriteWolfArmorItem.java create mode 100644 src/main/java/xyz/hafemann/netheriteextras/mixin/NetheriteWolfArmorEquipMixin.java create mode 100644 src/main/resources/assets/netheriteextras/models/item/netherite_wolf_armor.json create mode 100644 src/main/resources/assets/netheriteextras/textures/entity/wolf/wolf_armor_netherite.png create mode 100644 src/main/resources/assets/netheriteextras/textures/item/netherite_wolf_armor.png diff --git a/src/main/java/xyz/hafemann/netheriteextras/item/ModItems.java b/src/main/java/xyz/hafemann/netheriteextras/item/ModItems.java index 070a767..c3b82b8 100644 --- a/src/main/java/xyz/hafemann/netheriteextras/item/ModItems.java +++ b/src/main/java/xyz/hafemann/netheriteextras/item/ModItems.java @@ -18,6 +18,9 @@ public class ModItems { new Item(new Item.Settings().fireproof())); public static final Item NETHERITE_HORSE_ARMOR = registerItem("netherite_horse_armor", new NetheriteHorseArmorItem(new AnimalArmorItem.Settings().maxCount(1).fireproof())); + public static final Item NETHERITE_WOLF_ARMOR = registerItem("netherite_wolf_armor", + new NetheriteWolfArmorItem(new AnimalArmorItem.Settings().maxCount(1).fireproof() + .maxDamage(ArmorItem.Type.BODY.getMaxDamage(8)))); public static final Item NETHERITE_APPLE = registerItem("netherite_apple", new Item(new Item.Settings().food((new FoodComponent.Builder()).nutrition(6).saturationModifier(1.2F) .statusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 200, 1), 1.0F) @@ -47,6 +50,8 @@ public static void registerModItems() { .register(content -> content.addAfter(Items.GOLD_NUGGET, NETHERITE_NUGGET)); ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT) .register(content -> content.addAfter(Items.DIAMOND_HORSE_ARMOR, NETHERITE_HORSE_ARMOR)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.COMBAT) + .register(content -> content.addAfter(Items.WOLF_ARMOR, NETHERITE_WOLF_ARMOR)); ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK) .register(content -> content.addAfter(Items.ENCHANTED_GOLDEN_APPLE, NETHERITE_APPLE)); ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK) diff --git a/src/main/java/xyz/hafemann/netheriteextras/item/NetheriteWolfArmorItem.java b/src/main/java/xyz/hafemann/netheriteextras/item/NetheriteWolfArmorItem.java new file mode 100644 index 0000000..d7c5553 --- /dev/null +++ b/src/main/java/xyz/hafemann/netheriteextras/item/NetheriteWolfArmorItem.java @@ -0,0 +1,18 @@ +package xyz.hafemann.netheriteextras.item; + +import net.minecraft.item.AnimalArmorItem; +import net.minecraft.item.ArmorMaterials; +import net.minecraft.util.Identifier; +import xyz.hafemann.netheriteextras.NetheriteExtras; + +public class NetheriteWolfArmorItem extends AnimalArmorItem { + public NetheriteWolfArmorItem(Settings settings) { + super(ArmorMaterials.NETHERITE, Type.CANINE, true, settings); + } + + @Override + public Identifier getEntityTexture() { + String entityTexture = "textures/entity/wolf/wolf_armor_netherite.png"; + return new Identifier(NetheriteExtras.MOD_ID, entityTexture); + } +} diff --git a/src/main/java/xyz/hafemann/netheriteextras/mixin/NetheriteWolfArmorEquipMixin.java b/src/main/java/xyz/hafemann/netheriteextras/mixin/NetheriteWolfArmorEquipMixin.java new file mode 100644 index 0000000..3adb706 --- /dev/null +++ b/src/main/java/xyz/hafemann/netheriteextras/mixin/NetheriteWolfArmorEquipMixin.java @@ -0,0 +1,63 @@ +package xyz.hafemann.netheriteextras.mixin; + +import net.minecraft.entity.EntityType; +import net.minecraft.entity.VariantHolder; +import net.minecraft.entity.mob.Angerable; +import net.minecraft.entity.passive.TameableEntity; +import net.minecraft.entity.passive.WolfEntity; +import net.minecraft.entity.passive.WolfVariant; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ArmorMaterials; +import net.minecraft.item.ItemStack; +import net.minecraft.recipe.Ingredient; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.sound.SoundEvents; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Hand; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import xyz.hafemann.netheriteextras.item.ModItems; + +@Mixin(WolfEntity.class) +public abstract class NetheriteWolfArmorEquipMixin + extends TameableEntity + implements Angerable, + VariantHolder> { + protected NetheriteWolfArmorEquipMixin(EntityType entityType, World world) { + super(entityType, world); + } + + @Inject( + method = "interactMob", + at = @At("HEAD"), + cancellable = true + ) + private void onInteractMob(PlayerEntity player, Hand hand, CallbackInfoReturnable cir) { + ItemStack itemStack = player.getStackInHand(hand); + + if (this.isTamed()) { + if (itemStack.isOf(ModItems.NETHERITE_WOLF_ARMOR) && this.isOwner(player) && this.getBodyArmor().isEmpty() && !this.isBaby()) { + this.equipBodyArmor(itemStack.copyWithCount(1)); + itemStack.decrementUnlessCreative(1, player); + cir.setReturnValue(ActionResult.SUCCESS); + } + if (Ingredient.ofItems(ModItems.NETHERITE_NUGGET).test(itemStack) && this.isInSittingPose() + && !this.getBodyArmor().isEmpty() && this.isOwner(player) && this.getBodyArmor().isDamaged() + && this.getBodyArmor().getItem().equals(ModItems.NETHERITE_WOLF_ARMOR)) { + itemStack.decrement(1); + this.playSoundIfNotSilent(SoundEvents.ITEM_WOLF_ARMOR_REPAIR); + ItemStack bodyArmor = this.getBodyArmor(); + int amountRepaired = (int)((float)bodyArmor.getMaxDamage() * 0.25); + bodyArmor.setDamage(Math.max(0, bodyArmor.getDamage() - amountRepaired)); + cir.setReturnValue(ActionResult.SUCCESS); + } + if (ArmorMaterials.ARMADILLO.value().repairIngredient().get().test(itemStack) + && this.getBodyArmor().getItem().equals(ModItems.NETHERITE_WOLF_ARMOR)) { + cir.setReturnValue(ActionResult.PASS); + } + } + } +} diff --git a/src/main/resources/assets/netheriteextras/lang/de_de.json b/src/main/resources/assets/netheriteextras/lang/de_de.json index 24e1fca..ff3c7ce 100644 --- a/src/main/resources/assets/netheriteextras/lang/de_de.json +++ b/src/main/resources/assets/netheriteextras/lang/de_de.json @@ -3,5 +3,6 @@ "item.netheriteextras.netherite_apple": "Netheritapfel", "item.netheriteextras.netherite_nugget": "Netheritklumpen", "item.netheriteextras.netherite_horse_armor": "Netherit-Pferdeharnisch", + "item.netheriteextras.netherite_wolf_armor": "Netherit-Wolfspanzer", "item.netheriteextras.totem_of_neverdying": "Totem des Niemalssterbens" } \ No newline at end of file diff --git a/src/main/resources/assets/netheriteextras/lang/en_pt.json b/src/main/resources/assets/netheriteextras/lang/en_pt.json index bc2fb41..99b50fc 100644 --- a/src/main/resources/assets/netheriteextras/lang/en_pt.json +++ b/src/main/resources/assets/netheriteextras/lang/en_pt.json @@ -3,5 +3,6 @@ "item.netheriteextras.netherite_apple": "Blackbeard's apple", "item.netheriteextras.netherite_nugget": "Doubloon o' Blackbeard's alloy", "item.netheriteextras.netherite_horse_armor": "Blackbeard's brumby armor", + "item.netheriteextras.netherite_wolf_armor": "Blackbeard's hound's clothin'", "item.netheriteextras.totem_of_neverdying": "Jewel o' neverendin' life" } \ No newline at end of file diff --git a/src/main/resources/assets/netheriteextras/lang/en_us.json b/src/main/resources/assets/netheriteextras/lang/en_us.json index 3d69b76..86d33d6 100644 --- a/src/main/resources/assets/netheriteextras/lang/en_us.json +++ b/src/main/resources/assets/netheriteextras/lang/en_us.json @@ -3,5 +3,6 @@ "item.netheriteextras.netherite_apple": "Netherite Apple", "item.netheriteextras.netherite_nugget": "Netherite Nugget", "item.netheriteextras.netherite_horse_armor": "Netherite Horse Armor", + "item.netheriteextras.netherite_wolf_armor": "Netherite Wolf Armor", "item.netheriteextras.totem_of_neverdying": "Totem of Neverdying" } \ No newline at end of file diff --git a/src/main/resources/assets/netheriteextras/models/item/netherite_wolf_armor.json b/src/main/resources/assets/netheriteextras/models/item/netherite_wolf_armor.json new file mode 100644 index 0000000..541821e --- /dev/null +++ b/src/main/resources/assets/netheriteextras/models/item/netherite_wolf_armor.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "netheriteextras:item/netherite_wolf_armor" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/netheriteextras/textures/entity/wolf/wolf_armor_netherite.png b/src/main/resources/assets/netheriteextras/textures/entity/wolf/wolf_armor_netherite.png new file mode 100644 index 0000000000000000000000000000000000000000..98fd9836ed092bef67fc73db8e1e31a858875c2a GIT binary patch literal 1466 zcmV;r1x5OaP)EX>4Tx04R}tkxwWDQ5?rVc8Np|_JADbfD;!aN0yRWwJmBF2Q#yFshzRS?B?RA zT$O`A7yk|}&RiW_l~VqcoE@Bqi!^?3c562ouU_xd_r348_r4E8hdI-7Ye&Gc3r=Dp zswGo%TKx;Pv;+O1n{IwI9*+??KJTbe>usOP3O@JeXihJ=Ce&!cBWB(y2rmi`trhZ$ zcZDP7vYr+`6Yh27g2E3`@y{D4^000SaNLh0L04^f{ z04^f|c%?sf00007bV*G`2j~PD0Rbaa?5Cap000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_C zX>@2HM@dakSAh-}000A(NklQGpvg~cZF zoM3lnn0e>f_kErh2`yNOL>M~Yb2=?y42Z497y#HDwx;W~>ly%H@5A0m*J1B;@&2?I zlG6uN*fcEo>&HP$6h6NX08q#m zM8f85HI)Px9{PGd+|M%rKnQ6nTbwoh<_9Ay0YITD!-6w_E4X|vk8-7o zR3gealYHuI)0hIeK=!Nv0Qh)xhI}sHHWz0=Yl+r0%`^)v3BV1dkeqI?s*dv?1#x|I zd%rIREiW#yT((Z}z?@IaRiadEluKnUk8^t zz@x`cz{{FZ{q?2$8*0zyu(frhhLO2r4S=yrG)QA)%H^z&yDH-Tv{%Soqtvyc7dY|& z1j1q18^+~l?mJS6DC73oXnYFfLVV7i74Yfn1!jWtO)j#N*}>s~H33K^qU_tR2cpry z8z0=Y^=p9%A;OrHE7gIFkGC<75F+$GcY(wD{hk5X+}@Xrjf=W#8$98JLLqTlMRGpS zE8q|M+fKbxW7e`)U=;thXqqNiFi7{dT&W_T%fsfdH8nr@sVf${ynCaXNS0-&s@kOQ z`?bEgYzC^TLY8H5+KNXJw%2k7i~_tzXQnki<#K`$(v$-fk0MH-l{sL73GO)l07l)r UA!)C-vj6}907*qoM6N<$f;Qu>9{>OV literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/netheriteextras/textures/item/netherite_wolf_armor.png b/src/main/resources/assets/netheriteextras/textures/item/netherite_wolf_armor.png new file mode 100644 index 0000000000000000000000000000000000000000..6dd6af6f469ac0d73d0b0eb520fba7ea006a78b7 GIT binary patch literal 836 zcmV-K1H1f*P)EX>4Tx04R}tkxwWDQ5?rVc8Np|_JADbfD;!aN0yRWwJmBF2Q#yFshzRS?B?RA zT$O`A7yk|}&RiW_l~VqcoE@Bqi!^?3c562ouU_xd_r348_r4E8hdI-7Ye&Gc3r=Dp zswGo%TKx;Pv;+O1n{IwI9*+??KJTbe>usOP3O@JeXihJ=Ce&!cBWB(y2rmi`trhZ$ zcZDP7vYr+`6Yh27g2E3`@y{D4^000SaNLh0L04^f{ z04^f|c%?sf00007bV*G`2j~PD0Sz#G=c!Bp000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_C zX>@2HM@dakSAh-}0003WNklY|Nf)sIZ@iT~D zp=1jBMT&dD-Bm{MUBtov^6tHN|KEFX2Y)T`Ice4# z_VnUh_$}Y6RN=S|QcChXr+v^CWq=s~zvbIJ&yiB1jkYRP=xl`JI=q8cmzJ&TxKwL3 zj5c_lN3b7=3V=!#Qc8MJRFKVh41mr?7;OM}eR;-cgU&|9y$V3*up@d=G-1+47sfL6 z@B1GBfTNRRu~wa(m<}))s^UC;eB$BmmcdYQb9Ffh09ag@Cro0YjRqjOj*1v2u?Uk` ztgp-wCb2l{cE!{u3U;>a*IIjT*Z%Iu*xuN*Ws`r}r&(`&yW+I|f7Bb3E{5`8rOtH# O0000