Jhonny Lopez

crear un mod de armaduras con sus armas con efectos especiales empezando por estos 3

[Viewing 3 images]

Kodari AI
KodariNov 10 at 1:35 pm 16
MythicArmory
MythicArmory adds three unique armor sets with matching weapons to Minecraft Fabric. Each set provides special effects when worn: the Ember Set grants fire resistance and sets attackers ablaze, the Frost Set slows enemies and provides freeze immunity, and the Storm Set increases movement speed and deals lightning damage on hits. Craftable through custom recipes, each armor piece and weapon features unique textures and enchantment-like passive abilities. The mod integrates with Fabric API, offering configurable effect durations and damage values for balanced gameplay.
  1. Crearé tres conjuntos de armadura inspirados en las referencias —umbral violeta, glaciar azul y berserker carmesí— con sus armas.

  2. Añadiré habilidades especiales y progresión obtenible en supervivencia.

  3. Prepararé registros, texturas, modelos y recetas para Fabric 26.3.

Las tres armaduras y mandobles ya tienen registros, habilidades y recetas de supervivencia. Ahora enlazo las capas de las dos texturas generadas con las rutas que espera el equipo de Minecraft.

Creé Arcane Arsenal para Fabric 26.3: tres armaduras completas, tres mandobles, recetas de supervivencia, una pestaña creativa propia y reparación con diamantes.

  • Vacío: el conjunto completo otorga Velocidad y Caída lenta; el mandoble aplica Oscuridad.

  • Glaciar: el conjunto completo otorga Resistencia y Respiración acuática; el mandoble aplica Lentitud.

  • Berserker: el conjunto completo otorga Fuerza y Resistencia al fuego; el mandoble aplica Debilidad. Su mandoble usa material de netherita.

Los golpes especiales también producen un sonido y partículas. Para obtenerlos: Vacío se fabrica con diamantes y amatistas; Glaciar, con diamantes y hielo azul; Berserker, con diamantes y lingotes de netherita. Cada mandoble tiene su receta temática.

Aviso sobre el arte: se generaron las texturas de armadura de Vacío y Glaciar, y la del mandoble de Vacío. Se agotaron los créditos de generación antes de crear el arte de Berserker y los otros dos mandobles; por ahora esos elementos usan apariencias vanilla.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
48 598
src/main/java/com/kodari/arcane/ArcaneArsenal.java
package com.kodari.arcane;

import java.util.Map;

import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.resources.Identifier;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ToolMaterial;
import net.minecraft.world.item.equipment.ArmorMaterial;
import net.minecraft.world.item.equipment.ArmorType;
import net.minecraft.world.item.equipment.EquipmentAsset;
import net.minecraft.world.item.equipment.EquipmentAssets;
import net.minecraft.world.item.equipment.ArmorMaterials;
import net.minecraft.world.level.Level;

public class ArcaneArsenal implements ModInitializer {
	public static final String MOD_ID = "arcane_arsenal";
	private static int armorEffectTimer;

	private static final ArmorMaterial VOID_MATERIAL = createArmorMaterial("void");
	private static final ArmorMaterial GLACIER_MATERIAL = createArmorMaterial("glacier");
	private static final ArmorMaterial BERSERKER_MATERIAL = createArmorMaterial("berserker");

	private static final Item VOID_HELMET = registerArmor("void_helmet", VOID_MATERIAL, ArmorType.HELMET);
	private static final Item VOID_CHESTPLATE = registerArmor("void_chestplate", VOID_MATERIAL, ArmorType.CHESTPLATE);
	private static final Item VOID_LEGGINGS = registerArmor("void_leggings", VOID_MATERIAL, ArmorType.LEGGINGS);
	private static final Item VOID_BOOTS = registerArmor("void_boots", VOID_MATERIAL, ArmorType.BOOTS);
	private static final Item GLACIER_HELMET = registerArmor("glacier_helmet", GLACIER_MATERIAL, ArmorType.HELMET);
	private static final Item GLACIER_CHESTPLATE = registerArmor("glacier_chestplate", GLACIER_MATERIAL, ArmorType.CHESTPLATE);
	private static final Item GLACIER_LEGGINGS = registerArmor("glacier_leggings", GLACIER_MATERIAL, ArmorType.LEGGINGS);
	private static final Item GLACIER_BOOTS = registerArmor("glacier_boots", GLACIER_MATERIAL, ArmorType.BOOTS);
	private static final Item BERSERKER_HELMET = registerArmor("berserker_helmet", BERSERKER_MATERIAL, ArmorType.HELMET);
	private static final Item BERSERKER_CHESTPLATE = registerArmor("berserker_chestplate", BERSERKER_MATERIAL, ArmorType.CHESTPLATE);
	private static final Item BERSERKER_LEGGINGS = registerArmor("berserker_leggings", BERSERKER_MATERIAL, ArmorType.LEGGINGS);
	private static final Item BERSERKER_BOOTS = registerArmor("berserker_boots", BERSERKER_MATERIAL, ArmorType.BOOTS);

	private static final Item VOID_GREATSWORD = registerSword("void_greatsword", ToolMaterial.DIAMOND);
	private static final Item GLACIER_GREATSWORD = registerSword("glacier_greatsword", ToolMaterial.DIAMOND);
	private static final Item BERSERKER_GREATSWORD = registerSword("berserker_greatsword", ToolMaterial.NETHERITE);

	private static final ResourceKey<CreativeModeTab> CREATIVE_TAB_KEY = ResourceKey.create(
			Registries.CREATIVE_MODE_TAB,
			Identifier.fromNamespaceAndPath(MOD_ID, "arsenal")
	);

	@Override
	public void onInitialize() {
		registerCreativeTab();
		registerArmorEffects();
		registerWeaponEffects();
	}

	private static ArmorMaterial createArmorMaterial(String name) {
		ResourceKey<EquipmentAsset> assetKey = ResourceKey.create(
				EquipmentAssets.ROOT_ID,
				Identifier.fromNamespaceAndPath(MOD_ID, name)
		);
		return new ArmorMaterial(
				33,
				Map.of(
						ArmorType.HELMET, 3,
						ArmorType.CHESTPLATE, 8,
						ArmorType.LEGGINGS, 6,
						ArmorType.BOOTS, 3
				),
				10,
				SoundEvents.ARMOR_EQUIP_DIAMOND,
				2.0F,
				0.0F,
				ItemTags.REPAIRS_DIAMOND_ARMOR,
				assetKey
		);
	}

	private static Item registerArmor(String path, ArmorMaterial material, ArmorType type) {
		ResourceKey<Item> key = itemKey(path);
		Item item = new Item(new Item.Properties().setId(key).humanoidArmor(material, type));
		return Registry.register(BuiltInRegistries.ITEM, key, item);
	}

	private static Item registerSword(String path, ToolMaterial material) {
		ResourceKey<Item> key = itemKey(path);
		Item item = new Item(new Item.Properties().setId(key).sword(material, 3.0F, -2.4F));
		return Registry.register(BuiltInRegistries.ITEM, key, item);
	}

	private static ResourceKey<Item> itemKey(String path) {
		return ResourceKey.create(Registries.ITEM, Identifier.fromNamespaceAndPath(MOD_ID, path));
	}

	private static void registerCreativeTab() {
		CreativeModeTab tab = FabricCreativeModeTab.builder()
				.title(net.minecraft.network.chat.Component.literal("Arcane Arsenal"))
				.icon(() -> new ItemStack(VOID_GREATSWORD))
				.displayItems((parameters, output) -> {
					output.accept(VOID_HELMET);
					output.accept(VOID_CHESTPLATE);
					output.accept(VOID_LEGGINGS);
					output.accept(VOID_BOOTS);
					output.accept(VOID_GREATSWORD);
					output.accept(GLACIER_HELMET);
					output.accept(GLACIER_CHESTPLATE);
					output.accept(GLACIER_LEGGINGS);
					output.accept(GLACIER_BOOTS);
					output.accept(GLACIER_GREATSWORD);
					output.accept(BERSERKER_HELMET);
					output.accept(BERSERKER_CHESTPLATE);
					output.accept(BERSERKER_LEGGINGS);
					output.accept(BERSERKER_BOOTS);
					output.accept(BERSERKER_GREATSWORD);
				})
				.build();
		Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, CREATIVE_TAB_KEY, tab);
	}

	private static void registerArmorEffects() {
		ServerTickEvents.END_SERVER_TICK.register(server -> {
			if (++armorEffectTimer % 40 != 0) {
				return;
			}
			server.getPlayerList().getPlayers().forEach(ArcaneArsenal::applySetEffects);
		});
	}

	private static void applySetEffects(Player player) {
		if (wearingSet(player, VOID_HELMET, VOID_CHESTPLATE, VOID_LEGGINGS, VOID_BOOTS)) {
			applyEffect(player, MobEffects.SPEED, 0);
			applyEffect(player, MobEffects.SLOW_FALLING, 0);
		} else if (wearingSet(player, GLACIER_HELMET, GLACIER_CHESTPLATE, GLACIER_LEGGINGS, GLACIER_BOOTS)) {
			applyEffect(player, MobEffects.RESISTANCE, 0);
			applyEffect(player, MobEffects.WATER_BREATHING, 0);
		} else if (wearingSet(player, BERSERKER_HELMET, BERSERKER_CHESTPLATE, BERSERKER_LEGGINGS, BERSERKER_BOOTS)) {
			applyEffect(player, MobEffects.STRENGTH, 0);
			applyEffect(player, MobEffects.FIRE_RESISTANCE, 0);
		}
	}

	private static boolean wearingSet(Player player, Item helmet, Item chestplate, Item leggings, Item boots) {
		return player.getItemBySlot(EquipmentSlot.HEAD).getItem() == helmet
				&& player.getItemBySlot(EquipmentSlot.CHEST).getItem() == chestplate
				&& player.getItemBySlot(EquipmentSlot.LEGS).getItem() == leggings
				&& player.getItemBySlot(EquipmentSlot.FEET).getItem() == boots;
	}

	private static void applyEffect(LivingEntity entity, Holder<MobEffect> effect, int amplifier) {
		entity.addEffect(new MobEffectInstance(effect, 80, amplifier, true, false));
	}

	private static void registerWeaponEffects() {
		AttackEntityCallback.EVENT.register((player, level, hand, target, hitResult) -> {
			if (level.isClientSide() || !(target instanceof LivingEntity livingTarget)) {
				return InteractionResult.PASS;
			}

			Item weapon = player.getMainHandItem().getItem();
			Holder<MobEffect> effect;
			float pitch;
			if (weapon == VOID_GREATSWORD) {
				effect = MobEffects.DARKNESS;
				pitch = 0.8F;
			} else if (weapon == GLACIER_GREATSWORD) {
				effect = MobEffects.SLOWNESS;
				pitch = 1.2F;
			} else if (weapon == BERSERKER_GREATSWORD) {
				effect = MobEffects.WEAKNESS;
				pitch = 0.95F;
			} else {
				return InteractionResult.PASS;
			}

			applyEffect(livingTarget, effect, 0);
			level.playSound(null, livingTarget.blockPosition(), SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.PLAYERS, 0.8F, pitch);
			if (level instanceof ServerLevel serverLevel) {
				serverLevel.sendParticles(ParticleTypes.CRIT, livingTarget.getX(), livingTarget.getY() + 0.8, livingTarget.getZ(), 8, 0.25, 0.25, 0.25, 0.02);
			}
			return InteractionResult.PASS;
		});