Skip to content

Commit

Permalink
Add Netherite Wolf Armor
Browse files Browse the repository at this point in the history
  • Loading branch information
SLH335 committed Apr 25, 2024
1 parent 0f652cb commit f77ae4d
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main/java/xyz/hafemann/netheriteextras/item/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<RegistryEntry<WolfVariant>> {
protected NetheriteWolfArmorEquipMixin(EntityType<? extends TameableEntity> entityType, World world) {
super(entityType, world);
}

@Inject(
method = "interactMob",
at = @At("HEAD"),
cancellable = true
)
private void onInteractMob(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> 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);
}
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/netheriteextras/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions src/main/resources/assets/netheriteextras/lang/en_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions src/main/resources/assets/netheriteextras/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "netheriteextras:item/netherite_wolf_armor"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/main/resources/netheriteextras.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"NetheriteHorseArmorHorseEntityMixin",
"NetheriteNuggetArmorMixin",
"NetheriteNuggetToolMixin",
"NetheriteWolfArmorEquipMixin",
"TotemEnchantableMixin"
],
"client": [
Expand Down

0 comments on commit f77ae4d

Please sign in to comment.