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 6a5cef3 commit 7c3f867
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 25 deletions.
1 change: 1 addition & 0 deletions MORES-CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
v1.4.1
- Added bronze armor to trimmable armor
- Fixed ruby tools burn effect tooltip (and added to tools)

v1.4.0
Updated to Minecraft 1.20.4
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModArmorMaterials;
import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipContext;
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;
Expand All @@ -19,6 +22,19 @@ public ModAxeItem(ToolMaterial material, float attackDamage, float attackSpeed,
super(material, attackDamage, attackSpeed, 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, @Nullable World world, List<Text> tooltip, TooltipContext context) {
if (stack.getItem() instanceof MiningToolItem item) {
Expand Down
36 changes: 28 additions & 8 deletions src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package mod.leronus.mores.item.custom;

import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterial;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.*;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.world.World;
Expand All @@ -19,6 +19,26 @@ public ModBattleAxeItem(ToolMaterial toolMaterial, int attackDamageModifier, flo
super(toolMaterial, attackDamageModifier, attackSpeedModifier, 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, @Nullable World world, List<Text> tooltip, TooltipContext context) {
if (stack.getItem() instanceof ModBattleAxeItem){
Expand All @@ -28,9 +48,9 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> too
// }
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.durability").formatted(Formatting.GRAY).append(Text.translatable(String.valueOf(stack.getItem().getMaxDamage())).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) {
// tooltip.add(Text.translatable(Formatting.GRAY + "mores.bonus" + Formatting.RED + "Burn Effect"));
// }
if (((ToolItem) stack.getItem()).getMaterial() == ModToolMaterials.RUBY) {
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.burn_effect").formatted(Formatting.RED)));
}
}
}
}
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.TooltipContext;
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 @@ -18,10 +22,23 @@ public ModHoeItem(ToolMaterial material, int attackDamage, float attackSpeed, Se
super(material, attackDamage, attackSpeed, 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, @Nullable World world, List<Text> tooltip, TooltipContext context) {
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.TooltipContext;
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, attackDamage, attackSpeed, 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, @Nullable World world, List<Text> tooltip, TooltipContext context) {
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.TooltipContext;
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 @@ -18,10 +22,23 @@ public ModShovelItem(ToolMaterial material, float attackDamage, float attackSpee
super(material, attackDamage, attackSpeed, 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, @Nullable World world, List<Text> tooltip, TooltipContext context) {
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
24 changes: 11 additions & 13 deletions src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import mod.leronus.mores.item.ModItems;
import mod.leronus.mores.item.ModToolMaterials;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.item.TooltipContext;
Expand All @@ -13,10 +14,7 @@
import net.minecraft.entity.attribute.EntityAttributes;
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;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.*;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
Expand Down Expand Up @@ -56,15 +54,15 @@ public Multimap<EntityAttribute, EntityAttributeModifier> getAttributeModifiers(

@Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
if (stack.getItem() instanceof ModSwordItem){
tooltip.add(Text.literal(""));
if (stack.getItem() == ModItems.ONYX_SWORD || stack.getItem() == ModItems.ONYX_MACE || stack.getItem() == ModItems.ONYX_DAGGER) {
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.wither_effect").formatted(Formatting.DARK_GRAY)));
}
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.durability").formatted(Formatting.GRAY).append(Text.translatable(String.valueOf(stack.getItem().getMaxDamage())).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) {
tooltip.add(Text.translatable(Formatting.GRAY + "mores.bonus" + Formatting.RED + "Burn Effect"));
if (stack.getItem() instanceof ToolItem){
tooltip.add(Text.literal(""));
if (stack.getItem() == ModItems.ONYX_SWORD || stack.getItem() == ModItems.ONYX_MACE || stack.getItem() == ModItems.ONYX_DAGGER) {
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.wither_effect").formatted(Formatting.DARK_GRAY)));
}
tooltip.add(Text.literal(""));
tooltip.add(Text.translatable("mores.durability").formatted(Formatting.GRAY).append(Text.translatable(String.valueOf(stack.getItem().getMaxDamage())).formatted(Formatting.LIGHT_PURPLE)));
if (((ToolItem) stack.getItem()).getMaterial() == ModToolMaterials.RUBY) {
tooltip.add(Text.translatable("mores.bonus").formatted(Formatting.GRAY).append(Text.translatable("mores.burn_effect").formatted(Formatting.RED)));
}
}
}
Expand Down

0 comments on commit 7c3f867

Please sign in to comment.