Ace Rattles Tenno's Bones

This commit is contained in:
Vos
2025-11-13 15:59:36 -06:00
parent 07bf8428de
commit d0a3fdc95a
5 changed files with 53 additions and 4 deletions
@@ -13,12 +13,10 @@ import com.acethewildfire.acesbs.util.UpdateRecipies;
import com.acethewildfire.acesbs.util.YouMonsterEvent;
import com.acethewildfire.acesbs.world.gen.ModWorldGeneration;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FabricBrewingRecipeRegistryBuilder;
import net.fabricmc.fabric.api.renderer.v1.Renderer;
import net.minecraft.item.Items;
import net.minecraft.potion.Potions;
import org.slf4j.Logger;
@@ -122,7 +122,8 @@ public class ModItems {
public static final Item BERSERKERS_PAULDRON = registerItem("berserkers_pauldron",
new ModArmorItem(ModArmorMaterials.BERSERKERS, ArmorItem.Type.CHESTPLATE, new Item.Settings()
.maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(15)).attributeModifiers(AttributeModifiersComponent.builder()
.maxDamage(ArmorItem.Type.CHESTPLATE.getMaxDamage(15))
.attributeModifiers(AttributeModifiersComponent.builder()
.add(EntityAttributes.GENERIC_MAX_HEALTH,
new EntityAttributeModifier(Identifier.of(AcesBS.MOD_ID, "generic.max_health"), 20, EntityAttributeModifier.Operation.ADD_VALUE), AttributeModifierSlot.CHEST)
.add(EntityAttributes.GENERIC_ARMOR,
@@ -1,9 +1,11 @@
package com.acethewildfire.acesbs.mixin;
import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.item.ModItems;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -0,0 +1,47 @@
package com.acethewildfire.acesbs.mixin;
import com.acethewildfire.acesbs.AcesBS;
import com.acethewildfire.acesbs.item.ModItems;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.damage.DamageSource;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.Item;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import java.util.Objects;
@Mixin(PlayerEntity.class)
public abstract class PlayerEntityMixin {
@Shadow @Final
PlayerInventory inventory;
@Shadow public abstract Text getName();
@Inject(method = "damage", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILSOFT, cancellable = true)
private void damageMixin(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
Item chestplate = this.inventory.getArmorStack(2).getItem();
if (chestplate == ModItems.BERSERKERS_PAULDRON && !Objects.equals(this.getName().getLiteralString(), "Tennocraft12")){
PlayerEntity player = (PlayerEntity) (Object) this;
World world = player.getWorld();
if (!world.isClient()) {
world.playSound(null, player.getX(),player.getY(), player.getZ(), SoundEvents.ENTITY_SKELETON_HURT, SoundCategory.PLAYERS, 2f, 1f);
}
cir.setReturnValue(true);
}
}
}
+2 -1
View File
@@ -9,6 +9,7 @@
"defaultRequire": 1
},
"client": [
"AbstractClientPlayerEntityMixin"
"AbstractClientPlayerEntityMixin",
"PlayerEntityMixin"
]
}