Enhanced armor stats and tooltips. Improved clarity with detailed shift-based descriptions.

This commit is contained in:
IM23a-spirgif
2025-05-30 18:54:41 +02:00
parent a82d366550
commit 3c4ef551bc
5 changed files with 84 additions and 15 deletions
@@ -20,12 +20,12 @@ import java.util.function.Supplier;
public class ModArmorMaterials { public class ModArmorMaterials {
public static final Holder<ArmorMaterial> STALINIUM_ARMOR_MATERIAL = register("stalinium", public static final Holder<ArmorMaterial> STALINIUM_ARMOR_MATERIAL = register("stalinium",
Util.make(new EnumMap<>(ArmorItem.Type.class), attribute -> { Util.make(new EnumMap<>(ArmorItem.Type.class), attribute -> {
attribute.put(ArmorItem.Type.BOOTS, 5); attribute.put(ArmorItem.Type.BOOTS, 6);
attribute.put(ArmorItem.Type.LEGGINGS, 7); attribute.put(ArmorItem.Type.LEGGINGS, 8);
attribute.put(ArmorItem.Type.CHESTPLATE, 9); attribute.put(ArmorItem.Type.CHESTPLATE, 10);
attribute.put(ArmorItem.Type.HELMET, 5); attribute.put(ArmorItem.Type.HELMET, 6);
attribute.put(ArmorItem.Type.BODY, 11); attribute.put(ArmorItem.Type.BODY, 12);
}), 16, 2f, 0.1f, () -> ModItems.STALINIUM_INGOT.get()); }), 25, 3.5f, 0.15f, () -> ModItems.STALINIUM_INGOT.get());
private static Holder<ArmorMaterial> register(String name, EnumMap<ArmorItem.Type, Integer> typeProtection, private static Holder<ArmorMaterial> register(String name, EnumMap<ArmorItem.Type, Integer> typeProtection,
@@ -1,7 +1,9 @@
package net.krituximon.stalinium.item.custom; package net.krituximon.stalinium.item.custom;
import net.krituximon.stalinium.item.ModArmorMaterials; import net.krituximon.stalinium.item.ModArmorMaterials;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects; import net.minecraft.world.effect.MobEffects;
@@ -10,6 +12,7 @@ import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@@ -64,4 +67,14 @@ public class StaliniumBootsItem extends ArmorItem {
public boolean isDamaged(ItemStack stack) { public boolean isDamaged(ItemStack stack) {
return false; return false;
} }
@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
if(Screen.hasShiftDown()) {
tooltipComponents.add(Component.translatable("item.stalinium_boots.tooltip_shift"));
} else {
tooltipComponents.add(Component.translatable("item.stalinium_boots.tooltip"));
}
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}
} }
@@ -2,15 +2,19 @@ package net.krituximon.stalinium.item.custom;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import net.krituximon.stalinium.item.ModArmorMaterials; import net.krituximon.stalinium.item.ModArmorMaterials;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects; import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ArmorItem; import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.ArmorMaterial; import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@@ -80,10 +84,8 @@ public class StaliniumChestplateLeggingsItem extends ArmorItem {
if (leggingsStack.isEmpty() || chestplateStack.isEmpty()) { if (leggingsStack.isEmpty() || chestplateStack.isEmpty()) {
return false; return false;
} }
ArmorItem leggingsItem = (ArmorItem) leggingsStack.getItem(); ArmorItem leggingsItem = (ArmorItem) leggingsStack.getItem();
ArmorItem chestplateItem = (ArmorItem) chestplateStack.getItem(); ArmorItem chestplateItem = (ArmorItem) chestplateStack.getItem();
return leggingsItem.getMaterial() == mapArmorMaterial return leggingsItem.getMaterial() == mapArmorMaterial
&& chestplateItem.getMaterial() == mapArmorMaterial; && chestplateItem.getMaterial() == mapArmorMaterial;
} }
@@ -103,4 +105,21 @@ public class StaliniumChestplateLeggingsItem extends ArmorItem {
public boolean isDamaged(ItemStack stack) { public boolean isDamaged(ItemStack stack) {
return false; return false;
} }
@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
boolean shift = Screen.hasShiftDown();
EquipmentSlot slot = this.getEquipmentSlot();
if (slot == EquipmentSlot.CHEST) {
tooltipComponents.add( shift
? Component.translatable("item.stalinium_chestplate.tooltip_shift")
: Component.translatable("item.stalinium_chestplate.tooltip") );
} else if (slot == EquipmentSlot.LEGS) {
tooltipComponents.add( shift
? Component.translatable("item.stalinium_leggings.tooltip_shift")
: Component.translatable("item.stalinium_leggings.tooltip") );
}
}
} }
@@ -1,7 +1,9 @@
package net.krituximon.stalinium.item.custom; package net.krituximon.stalinium.item.custom;
import net.krituximon.stalinium.Stalinium; import net.krituximon.stalinium.Stalinium;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Holder; import net.minecraft.core.Holder;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@@ -10,10 +12,13 @@ import net.minecraft.world.item.ArmorMaterial;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.effect.MobEffectInstance; import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects; import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.TooltipFlag;
import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber; import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.entity.player.AttackEntityEvent; import net.neoforged.neoforge.event.entity.player.AttackEntityEvent;
import java.util.List;
public class StaliniumHelmetItem extends ArmorItem { public class StaliniumHelmetItem extends ArmorItem {
public StaliniumHelmetItem(Holder<ArmorMaterial> material, Type slot, Properties props) { public StaliniumHelmetItem(Holder<ArmorMaterial> material, Type slot, Properties props) {
super(material, slot, props); super(material, slot, props);
@@ -41,4 +46,24 @@ public class StaliniumHelmetItem extends ArmorItem {
)); ));
} }
} }
@Override
public boolean isDamageable(ItemStack stack) {
return false;
}
@Override
public boolean isDamaged(ItemStack stack) {
return false;
}
@Override
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
if (Screen.hasShiftDown()) {
tooltipComponents.add(Component.translatable("item.stalinium_helmet.tooltip_shift"));
} else {
tooltipComponents.add(Component.translatable("item.stalinium_helmet.tooltip"));
}
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}
} }
@@ -24,18 +24,30 @@
"effect.stalinium.stalinium_charge": "For the Motherland!", "effect.stalinium.stalinium_charge": "For the Motherland!",
"item.stalinium_sword.tooltip": "Sword made out of §cStalinium§0\n\n§l§cPower to the people!§0\n\n§l§cForward, Comrades!\n§f(Shift to expand)", "item.stalinium_sword.tooltip": "Sword made out of §cStalinium§0\n\n§l§cPower to the people!§0\n\n§l§cForward, Comrades!\n\n§f(Shift to expand)",
"item.stalinium_sword.tooltip_shift": "Sword made out of §cStalinium\n\n§l§cPower to the people!:§f\nWhen hitting an enemy, allies within 5 blocks gain Strength 1 for 5 seconds\n\n§l§cForward, Comrades!:§f\nPressing Right Click applies a speed and haste boost on yourself and all allies infront of you.", "item.stalinium_sword.tooltip_shift": "Sword made out of §cStalinium\n\n§l§cPower to the people!:§f\nWhen hitting an enemy, allies within 5 blocks gain Strength 1 for 5 seconds\n\n§l§cForward, Comrades!:§f\nPressing Right Click applies a speed and haste boost on yourself and all allies infront of you.",
"item.stalinium_axe.tooltip": "Axe made out of §cStalinium§0\n\n§l§cStalinium Efficiency§0\n\n§l§cLumber for the People\n§f(Shift to expand)", "item.stalinium_axe.tooltip": "Axe made out of §cStalinium§0\n\n§l§cStalinium Efficiency§0\n\n§l§cLumber for the People\n\n§f(Shift to expand)",
"item.stalinium_axe.tooltip_shift": "Axe made out of §cStalinium\n\n§l§cStalinium Efficiency:§f\nInstantly break trees\n\n§l§cLumber of the people:§f\nEach nearby ally gets 1 plank and 1 sapling per log broken with the axe.", "item.stalinium_axe.tooltip_shift": "Axe made out of §cStalinium\n\n§l§cStalinium Efficiency:§f\nInstantly break trees\n\n§l§cLumber for the people:§f\nEach nearby ally gets 1 plank and 1 sapling per log broken with the axe.",
"item.stalinium_shovel.tooltip": "Shovel made out of §cStalinium§0\n\n§l§cPath of Progress§0\n\n§l§cTo Each According to Their Labor\n§f(Shift to expand)", "item.stalinium_shovel.tooltip": "Shovel made out of §cStalinium§0\n\n§l§cPath of Progress§0\n\n§l§cTo Each According to Their Labor\n\n§f(Shift to expand)",
"item.stalinium_shovel.tooltip_shift": "Shovel made out of §cStalinium\n\n§l§cPath of Progress:§f\nDigs a 3x3 area.\n\n§l§cTo Each According to Their Labor:§f\nMining grants Haste II to you, and Haste I to nearby comrades.", "item.stalinium_shovel.tooltip_shift": "Shovel made out of §cStalinium\n\n§l§cPath of Progress:§f\nDigs a 3x3 area.\n\n§l§cTo Each According to Their Labor:§f\nMining grants Haste II to you, and Haste I to nearby comrades.",
"item.stalinium_hoe.tooltip": "Hoe made out of §cStalinium§0\n\n§l§cRain Dividend§0\n\n§l§cShared Bounty\n§f(Shift to expand)", "item.stalinium_hoe.tooltip": "Hoe made out of §cStalinium§0\n\n§l§cRain Dividend§0\n\n§l§cShared Bounty\n\n§f(Shift to expand)",
"item.stalinium_hoe.tooltip_shift": "Hoe made out of §cStalinium\n\n§l§cRain Dividend:§f\nRain doubles your harvest yields.\n\n§l§cShared Bounty:§f\n50% chance your comrades get the same crop drops as you.", "item.stalinium_hoe.tooltip_shift": "Hoe made out of §cStalinium\n\n§l§cRain Dividend:§f\nRain doubles your harvest yields.\n\n§l§cShared Bounty:§f\n50% chance your comrades get the same crop drops as you.",
"item.stalinium_pickaxe.tooltip": "Pickaxe made out of §cStalinium§0\n\n§l§cVein of Unity:§0\n\n§l§cOre for All\n§f(Shift to expand)", "item.stalinium_pickaxe.tooltip": "Pickaxe made out of §cStalinium§0\n\n§l§cVein of Unity§0\n\n§l§cOre for All\n\n§f(Shift to expand)",
"item.stalinium_pickaxe.tooltip_shift": "Pickaxe made out of §cStalinium\n\n§l§cVein of Unity:§f\nInstantly mines all connected ore blocks.\n\n§l§cOre for all:§f\n50% chance nearby comrades also receive your ore drops." "item.stalinium_pickaxe.tooltip_shift": "Pickaxe made out of §cStalinium\n\n§l§cVein of Unity:§f\nInstantly mines all connected ore blocks.\n\n§l§cOre for all:§f\n50% chance nearby comrades also receive your ore drops.",
"item.stalinium_boots.tooltip": "Boots made out of §cStalinium\n\n§l§cMarch of Progress\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many\n\n§f(Shift to expand)",
"item.stalinium_boots.tooltip_shift": "Boots made out of §cStalinium\n\n§l§cMarch of Progress:§f\nSprinting gives you and everyone nearby Speed I.\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many: Gain more hearts the more allies are nearby.",
"item.stalinium_helmet.tooltip": "Helmet made out of §cStalinium\n\n§l§cWatchful Comrade\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many\n\n§f(Shift to expand)",
"item.stalinium_helmet.tooltip_shift": "Helmet made out of §cStalinium\n\n§l§cWatchful Comrade:§f\nHitting an enemy marks them for everyone to see.\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many: Gain more hearts the more allies are nearby.",
"item.stalinium_chestplate.tooltip": "Chestplate made out of §cStalinium\n\n§l§cIron Will of the Collective\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many\n\n§f(Shift to expand)",
"item.stalinium_chestplate.tooltip_shift": "Chestplate made out of §cStalinium\n\n§l§cIron Will of the Collective:§f\nWhen wearing the chestplate alongside the leggings, gain Resistance I.\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many: Gain more hearts the more allies are nearby.",
"item.stalinium_leggings.tooltip": "Leggings made out of §cStalinium\n\n§l§cIron Will of the Collective\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many\n\n§f(Shift to expand)",
"item.stalinium_leggings.tooltip_shift": "Leggings made out of §cStalinium\n\n§l§cIron Will of the Collective:§f\nWhen wearing the chestplate alongside the leggings, gain Resistance I.\n\n§fFull Armor Set Bonus:\n§l§cPower of the Many: Gain more hearts the more allies are nearby."
} }