Implemented template class for charge items. Created new charge items for more totems.
This commit is contained in:
@ -1,15 +0,0 @@
|
|||||||
package dev.micle.totemofreviving.item;
|
|
||||||
|
|
||||||
import dev.micle.totemofreviving.TotemOfReviving;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.Rarity;
|
|
||||||
|
|
||||||
public class StrawChargeItem extends Item {
|
|
||||||
public StrawChargeItem() {
|
|
||||||
super(new Item.Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(64).rarity(Rarity.COMMON));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getName() {
|
|
||||||
return "straw_charge";
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,46 @@
|
|||||||
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
import dev.micle.totemofreviving.TotemOfReviving;
|
||||||
|
import dev.micle.totemofreviving.config.Config;
|
||||||
|
import dev.micle.totemofreviving.item.totem.NetheriteTotemItem;
|
||||||
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Rarity;
|
||||||
|
import net.minecraft.util.text.ITextComponent;
|
||||||
|
import net.minecraft.util.text.StringTextComponent;
|
||||||
|
import net.minecraft.util.text.TextFormatting;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
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() {
|
||||||
|
super(new Item.Properties().tab(TotemOfReviving.ITEM_GROUP).stacksTo(64).rarity(Rarity.COMMON));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
public void appendHoverText(ItemStack stack, @Nullable World world, List<ITextComponent> tooltip, ITooltipFlag tooltipFlag) {
|
||||||
|
if (isEnabled(stack)) {
|
||||||
|
tooltip.add(new StringTextComponent(TextFormatting.WHITE + "Used for charging its corresponding totem."));
|
||||||
|
} else {
|
||||||
|
tooltip.add(new StringTextComponent(TextFormatting.RED + "Totem is disabled!"));
|
||||||
|
}
|
||||||
|
super.appendHoverText(stack, world, tooltip, tooltipFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEnabled(ItemStack stack) {
|
||||||
|
Item item = stack.getItem();
|
||||||
|
if (item instanceof StrawChargeItem) { return Config.Server.getStrawTotemConfig().getIsEnabled(); }
|
||||||
|
if (item instanceof IronChargeItem) { return Config.Server.getIronTotemConfig().getIsEnabled(); }
|
||||||
|
if (item instanceof DiamondChargeItem) { return Config.Server.getDiamondTotemConfig().getIsEnabled(); }
|
||||||
|
if (item instanceof NetheriteTotemItem) { return Config.Server.getNetheriteTotemConfig().getIsEnabled(); }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
public class DiamondChargeItem extends ChargeItem {
|
||||||
|
public static String getName() {
|
||||||
|
return "diamond_charge";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
public class IronChargeItem extends ChargeItem {
|
||||||
|
public static String getName() {
|
||||||
|
return "iron_charge";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
public class NetheriteChargeItem extends ChargeItem {
|
||||||
|
public static String getName() {
|
||||||
|
return "netherite_charge";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package dev.micle.totemofreviving.item.charge;
|
||||||
|
|
||||||
|
public class StrawChargeItem extends ChargeItem {
|
||||||
|
public static String getName() {
|
||||||
|
return "straw_charge";
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user