Skip to content

Commit

Permalink
Updated tooltips
Browse files Browse the repository at this point in the history
  • Loading branch information
Leronus committed Aug 8, 2024
1 parent 2c79657 commit eaa28dd
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 7 deletions.
21 changes: 20 additions & 1 deletion src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.AxeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand All @@ -16,10 +22,23 @@ public ModAxeItem(ToolMaterial material, float attackDamage, float attackSpeed,
super(material, settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx battleaxe, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_AXE) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_AXE) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
if (stack.getItem() instanceof MiningToolItem item) {
if (item.getMaterial() == ModToolMaterials.RUBY){
if (item.getMaterial() == ModToolMaterials.RUBY){
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.auto_smelt").formatted(Formatting.DARK_RED)));
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import mod.leronus.mores.item.ModItems;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
Expand All @@ -16,6 +19,26 @@ public ModBattleAxeItem(ToolMaterial toolMaterial, Item.Settings settings) {
super(toolMaterial, settings);
}

/**
* Called when an enemy is attacked using the sword
* @param stack Itemstack used to attack with
* @param target Target entity that is being attacked
* @param attacker The entity attacking the enemy
* @return Hurt enemy
*/
@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx battleaxe, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_BATTLEAXE) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_BATTLEAXE) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
if (stack.getItem() instanceof ModBattleAxeItem){
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/mod/leronus/mores/item/custom/ModHoeItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.HoeItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
Expand All @@ -16,10 +20,23 @@ public ModHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Se
super(material, settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx battleaxe, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_HOE) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_HOE) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
if (stack.getItem() instanceof MiningToolItem item) {
if (item.getMaterial() == ModToolMaterials.RUBY){
if (item.getMaterial() == ModToolMaterials.RUBY){
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.auto_smelt").formatted(Formatting.DARK_RED)));
}
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/mod/leronus/mores/item/custom/ModPickaxeItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.PickaxeItem;
Expand All @@ -18,10 +22,23 @@ public ModPickaxeItem(ToolMaterial material, int attackDamage, float attackSpeed
super(material, settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx battleaxe, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_PICKAXE) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_PICKAXE) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
if (stack.getItem() instanceof MiningToolItem item) {
if (item.getMaterial() == ModToolMaterials.RUBY){
if (item.getMaterial() == ModToolMaterials.RUBY){
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.auto_smelt").formatted(Formatting.DARK_RED)));
}
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/mod/leronus/mores/item/custom/ModShovelItem.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.MiningToolItem;
import net.minecraft.item.ShovelItem;
Expand All @@ -16,10 +20,23 @@ public ModShovelItem(ToolMaterial material, float attackDamage, float attackSpee
super(material,settings);
}

@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx battleaxe, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_SHOVEL) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_SHOVEL) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
}

@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
if (stack.getItem() instanceof MiningToolItem item) {
if (item.getMaterial() == ModToolMaterials.RUBY){
if (item.getMaterial() == ModToolMaterials.RUBY){
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.auto_smelt").formatted(Formatting.DARK_RED)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> to
}
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.durability").formatted(Formatting.GRAY).append(Text.translatable(String.valueOf(((ModSwordItem) stack.getItem()).getMaterial().getDurability())).formatted(Formatting.LIGHT_PURPLE)));
if (stack.getItem() == ModItems.RUBY_SWORD || stack.getItem() == ModItems.RUBY_MACE || stack.getItem() == ModItems.RUBY_BATTLEAXE || stack.getItem() == ModItems.RUBY_DAGGER) {
if (stack.getItem() == ModItems.RUBY_SWORD || stack.getItem() == ModItems.RUBY_MACE || stack.getItem() == ModItems.RUBY_DAGGER) {
tooltip.add(Text.translatable(Formatting.GRAY + "mores.bonus" + Formatting.RED + "Burn Effect"));
}
}
Expand All @@ -45,11 +45,11 @@ public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> to
@Override
public boolean postHit(ItemStack stack, LivingEntity target, LivingEntity attacker) {
//If the item is an onyx sword, apply wither effect on targetEntity
if(stack.getItem() == ModItems.ONYX_SWORD || stack.getItem() == ModItems.ONYX_MACE || stack.getItem() == ModItems.ONYX_DAGGER || stack.getItem() == ModItems.ONYX_BATTLEAXE) {
if(stack.getItem() == ModItems.ONYX_SWORD || stack.getItem() == ModItems.ONYX_MACE || stack.getItem() == ModItems.ONYX_DAGGER) {
target.addStatusEffect(new StatusEffectInstance(StatusEffects.WITHER, 250, 1, false, false));
}
//If the item is a ruby sword, apply fire effect on targetEntity
if(stack.getItem() == ModItems.RUBY_SWORD || stack.getItem() == ModItems.RUBY_MACE || stack.getItem() == ModItems.RUBY_DAGGER || stack.getItem() == ModItems.RUBY_BATTLEAXE) {
if(stack.getItem() == ModItems.RUBY_SWORD || stack.getItem() == ModItems.RUBY_MACE || stack.getItem() == ModItems.RUBY_DAGGER) {
target.setOnFireFor(5);
}
return super.postHit(stack, target, attacker);
Expand Down

0 comments on commit eaa28dd

Please sign in to comment.