Implemented new methods for each totem item. Implemented helper for generating item properties, now also adding totem data to the item.
This commit is contained in:
@ -7,7 +7,7 @@ import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class DiamondTotemItem extends TotemItem {
|
||||
public DiamondTotemItem() {
|
||||
super(Rarity.RARE, Config.Server.getDiamondTotemConfig().getDurability());
|
||||
super(createProperties(Rarity.RARE, Config.Server.getDiamondTotemConfig().getDurability(), false));
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
@ -18,4 +18,9 @@ public class DiamondTotemItem extends TotemItem {
|
||||
public boolean isCharge(ItemStack stack) {
|
||||
return (stack.getItem() instanceof DiamondChargeItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config.TotemConfig getConfig() {
|
||||
return Config.Server.getDiamondTotemConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,10 +3,11 @@ package dev.micle.totemofreviving.item.totem;
|
||||
import dev.micle.totemofreviving.item.charge.IronChargeItem;
|
||||
import dev.micle.totemofreviving.setup.Config;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class IronTotemItem extends TotemItem {
|
||||
public IronTotemItem() {
|
||||
super(Config.Server.getIronTotemConfig().getDurability());
|
||||
super(createProperties(Rarity.COMMON, Config.Server.getIronTotemConfig().getDurability(), false));
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
@ -17,4 +18,9 @@ public class IronTotemItem extends TotemItem {
|
||||
public boolean isCharge(ItemStack stack) {
|
||||
return (stack.getItem() instanceof IronChargeItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config.TotemConfig getConfig() {
|
||||
return Config.Server.getIronTotemConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class NetheriteTotemItem extends TotemItem {
|
||||
public NetheriteTotemItem() {
|
||||
super(Rarity.EPIC, Config.Server.getNetheriteTotemConfig().getDurability());
|
||||
super(createProperties(Rarity.EPIC, Config.Server.getNetheriteTotemConfig().getDurability(), true));
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
@ -20,7 +20,7 @@ public class NetheriteTotemItem extends TotemItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFireResistant() {
|
||||
return true;
|
||||
public Config.TotemConfig getConfig() {
|
||||
return Config.Server.getNetheriteTotemConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import net.minecraft.world.item.Rarity;
|
||||
|
||||
public class StrawTotemItem extends TotemItem {
|
||||
public StrawTotemItem() {
|
||||
super(Rarity.UNCOMMON, Config.Server.getStrawTotemConfig().getDurability());
|
||||
super(createProperties(Rarity.UNCOMMON, Config.Server.getStrawTotemConfig().getDurability(), false));
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
@ -18,4 +18,9 @@ public class StrawTotemItem extends TotemItem {
|
||||
public boolean isCharge(ItemStack stack) {
|
||||
return (stack.getItem() instanceof StrawChargeItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config.TotemConfig getConfig() {
|
||||
return Config.Server.getStrawTotemConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,12 +30,20 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class TotemItem extends Item {
|
||||
public TotemItem(int durability) {
|
||||
this(Rarity.COMMON, durability);
|
||||
public TotemItem(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
public TotemItem(Rarity rarity, int durability) {
|
||||
super(new Properties().stacksTo(1).rarity(rarity).durability(durability));
|
||||
public static Properties createProperties(Rarity rarity, int durability, boolean isFireResistant) {
|
||||
Properties properties = new Properties().stacksTo(1).rarity(rarity).durability(durability);
|
||||
|
||||
if (isFireResistant) properties = properties.fireResistant();
|
||||
|
||||
properties = properties.component(ModDataComponents.TOTEM_DATA.get(), new TotemData(
|
||||
0, "", "", 0, 0
|
||||
));
|
||||
|
||||
return properties;
|
||||
}
|
||||
|
||||
public abstract boolean isCharge(ItemStack stack);
|
||||
|
||||
Reference in New Issue
Block a user