Ported charge items. Implemented property helper. Made netherite charges fire-resistant.

This commit is contained in:
2026-01-11 00:25:55 +01:00
parent 935ccd14bb
commit 1c45352037
5 changed files with 21 additions and 18 deletions

View File

@ -6,28 +6,27 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
public class ChargeItem extends Item {
public ChargeItem() {
this(Rarity.COMMON);
public ChargeItem(Properties properties) {
super(properties);
}
public ChargeItem(Rarity rarity) {
super(new Properties().stacksTo(64).rarity(rarity));
public static Properties createProperties(Rarity rarity, boolean isFireResistant) {
Properties properties = new Properties().stacksTo(64).rarity(rarity);
if (isFireResistant) properties = properties.fireResistant();
return properties;
}
@Override
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag tooltipFlag) {
tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
super.appendHoverText(stack, world, tooltip, tooltipFlag);
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
tooltipComponents.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
}
}

View File

@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
public class DiamondChargeItem extends ChargeItem {
public DiamondChargeItem() {
super(Rarity.RARE);
super(createProperties(Rarity.RARE, false));
}
public static String getName() {

View File

@ -1,7 +1,11 @@
package dev.micle.totemofreviving.item.charge;
import net.minecraft.world.item.Rarity;
public class IronChargeItem extends ChargeItem {
public IronChargeItem() {}
public IronChargeItem() {
super(createProperties(Rarity.COMMON, false));
}
public static String getName() {
return "iron_charge";

View File

@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
public class NetheriteChargeItem extends ChargeItem {
public NetheriteChargeItem() {
super(Rarity.EPIC);
super(createProperties(Rarity.EPIC, true));
}
public static String getName() {

View File

@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
public class StrawChargeItem extends ChargeItem {
public StrawChargeItem() {
super(Rarity.UNCOMMON);
super(createProperties(Rarity.UNCOMMON, false));
}
public static String getName() {