Ported charge items. Implemented property helper. Made netherite charges fire-resistant.
This commit is contained in:
@ -6,28 +6,27 @@ import net.minecraft.world.item.Item;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.item.Rarity;
|
import net.minecraft.world.item.Rarity;
|
||||||
import net.minecraft.world.item.TooltipFlag;
|
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 javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChargeItem extends Item {
|
public class ChargeItem extends Item {
|
||||||
public ChargeItem() {
|
public ChargeItem(Properties properties) {
|
||||||
this(Rarity.COMMON);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChargeItem(Rarity rarity) {
|
public static Properties createProperties(Rarity rarity, boolean isFireResistant) {
|
||||||
super(new Properties().stacksTo(64).rarity(rarity));
|
Properties properties = new Properties().stacksTo(64).rarity(rarity);
|
||||||
|
|
||||||
|
if (isFireResistant) properties = properties.fireResistant();
|
||||||
|
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OnlyIn(Dist.CLIENT)
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void appendHoverText(ItemStack stack, @Nullable Level world, List<Component> tooltip, TooltipFlag tooltipFlag) {
|
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltipComponents, TooltipFlag tooltipFlag) {
|
||||||
tooltip.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
|
tooltipComponents.add(Component.literal(ChatFormatting.WHITE + "Used for charging its corresponding totem."));
|
||||||
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
super.appendHoverText(stack, context, tooltipComponents, tooltipFlag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
|
|||||||
|
|
||||||
public class DiamondChargeItem extends ChargeItem {
|
public class DiamondChargeItem extends ChargeItem {
|
||||||
public DiamondChargeItem() {
|
public DiamondChargeItem() {
|
||||||
super(Rarity.RARE);
|
super(createProperties(Rarity.RARE, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
package dev.micle.totemofreviving.item.charge;
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
|
||||||
public class IronChargeItem extends ChargeItem {
|
public class IronChargeItem extends ChargeItem {
|
||||||
public IronChargeItem() {}
|
public IronChargeItem() {
|
||||||
|
super(createProperties(Rarity.COMMON, false));
|
||||||
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
return "iron_charge";
|
return "iron_charge";
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
|
|||||||
|
|
||||||
public class NetheriteChargeItem extends ChargeItem {
|
public class NetheriteChargeItem extends ChargeItem {
|
||||||
public NetheriteChargeItem() {
|
public NetheriteChargeItem() {
|
||||||
super(Rarity.EPIC);
|
super(createProperties(Rarity.EPIC, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import net.minecraft.world.item.Rarity;
|
|||||||
|
|
||||||
public class StrawChargeItem extends ChargeItem {
|
public class StrawChargeItem extends ChargeItem {
|
||||||
public StrawChargeItem() {
|
public StrawChargeItem() {
|
||||||
super(Rarity.UNCOMMON);
|
super(createProperties(Rarity.UNCOMMON, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
|
|||||||
Reference in New Issue
Block a user