generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/xyz/hafemann/netheriteextras/item/NetheriteWolfArmorItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/xyz/hafemann/netheriteextras/mixin/NetheriteWolfArmorEquipMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/netheriteextras/models/item/netherite_wolf_armor.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "netheriteextras:item/netherite_wolf_armor" | ||
} | ||
} |
Binary file added
BIN
+1.43 KB
.../resources/assets/netheriteextras/textures/entity/wolf/wolf_armor_netherite.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+836 Bytes
src/main/resources/assets/netheriteextras/textures/item/netherite_wolf_armor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters