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 class DiamondTotemItem extends TotemItem {
|
||||||
public DiamondTotemItem() {
|
public DiamondTotemItem() {
|
||||||
super(Rarity.RARE, Config.Server.getDiamondTotemConfig().getDurability());
|
super(createProperties(Rarity.RARE, Config.Server.getDiamondTotemConfig().getDurability(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
@ -18,4 +18,9 @@ public class DiamondTotemItem extends TotemItem {
|
|||||||
public boolean isCharge(ItemStack stack) {
|
public boolean isCharge(ItemStack stack) {
|
||||||
return (stack.getItem() instanceof DiamondChargeItem);
|
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.item.charge.IronChargeItem;
|
||||||
import dev.micle.totemofreviving.setup.Config;
|
import dev.micle.totemofreviving.setup.Config;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.Rarity;
|
||||||
|
|
||||||
public class IronTotemItem extends TotemItem {
|
public class IronTotemItem extends TotemItem {
|
||||||
public IronTotemItem() {
|
public IronTotemItem() {
|
||||||
super(Config.Server.getIronTotemConfig().getDurability());
|
super(createProperties(Rarity.COMMON, Config.Server.getIronTotemConfig().getDurability(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
@ -17,4 +18,9 @@ public class IronTotemItem extends TotemItem {
|
|||||||
public boolean isCharge(ItemStack stack) {
|
public boolean isCharge(ItemStack stack) {
|
||||||
return (stack.getItem() instanceof IronChargeItem);
|
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 class NetheriteTotemItem extends TotemItem {
|
||||||
public NetheriteTotemItem() {
|
public NetheriteTotemItem() {
|
||||||
super(Rarity.EPIC, Config.Server.getNetheriteTotemConfig().getDurability());
|
super(createProperties(Rarity.EPIC, Config.Server.getNetheriteTotemConfig().getDurability(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
@ -18,9 +18,9 @@ public class NetheriteTotemItem extends TotemItem {
|
|||||||
public boolean isCharge(ItemStack stack) {
|
public boolean isCharge(ItemStack stack) {
|
||||||
return (stack.getItem() instanceof NetheriteChargeItem);
|
return (stack.getItem() instanceof NetheriteChargeItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFireResistant() {
|
public Config.TotemConfig getConfig() {
|
||||||
return true;
|
return Config.Server.getNetheriteTotemConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import net.minecraft.world.item.Rarity;
|
|||||||
|
|
||||||
public class StrawTotemItem extends TotemItem {
|
public class StrawTotemItem extends TotemItem {
|
||||||
public StrawTotemItem() {
|
public StrawTotemItem() {
|
||||||
super(Rarity.UNCOMMON, Config.Server.getStrawTotemConfig().getDurability());
|
super(createProperties(Rarity.UNCOMMON, Config.Server.getStrawTotemConfig().getDurability(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getName() {
|
public static String getName() {
|
||||||
@ -18,4 +18,9 @@ public class StrawTotemItem extends TotemItem {
|
|||||||
public boolean isCharge(ItemStack stack) {
|
public boolean isCharge(ItemStack stack) {
|
||||||
return (stack.getItem() instanceof StrawChargeItem);
|
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;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class TotemItem extends Item {
|
public abstract class TotemItem extends Item {
|
||||||
public TotemItem(int durability) {
|
public TotemItem(Properties properties) {
|
||||||
this(Rarity.COMMON, durability);
|
super(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TotemItem(Rarity rarity, int durability) {
|
public static Properties createProperties(Rarity rarity, int durability, boolean isFireResistant) {
|
||||||
super(new Properties().stacksTo(1).rarity(rarity).durability(durability));
|
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);
|
public abstract boolean isCharge(ItemStack stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user