diff --git a/MORES-CHANGELOG.txt b/MORES-CHANGELOG.txt index 8aac88b..8169974 100644 --- a/MORES-CHANGELOG.txt +++ b/MORES-CHANGELOG.txt @@ -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 diff --git a/src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java b/src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java index 8d262a3..9a8d3f2 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModAxeItem.java @@ -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; @@ -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 tooltip, TooltipContext context) { if (stack.getItem() instanceof MiningToolItem item) { diff --git a/src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java b/src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java index 1516f09..5638124 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModBattleAxeItem.java @@ -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; @@ -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 tooltip, TooltipContext context) { if (stack.getItem() instanceof ModBattleAxeItem){ @@ -28,9 +48,9 @@ public void appendTooltip(ItemStack stack, @Nullable World world, List 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))); + } } } } diff --git a/src/main/java/mod/leronus/mores/item/custom/ModHoeItem.java b/src/main/java/mod/leronus/mores/item/custom/ModHoeItem.java index 533d777..14f7d85 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModHoeItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModHoeItem.java @@ -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; @@ -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 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))); } diff --git a/src/main/java/mod/leronus/mores/item/custom/ModPickaxeItem.java b/src/main/java/mod/leronus/mores/item/custom/ModPickaxeItem.java index 9329d0f..bfc6c95 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModPickaxeItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModPickaxeItem.java @@ -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; @@ -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 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))); } diff --git a/src/main/java/mod/leronus/mores/item/custom/ModShovelItem.java b/src/main/java/mod/leronus/mores/item/custom/ModShovelItem.java index 0f21290..57c193b 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModShovelItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModShovelItem.java @@ -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; @@ -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 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))); } diff --git a/src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java b/src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java index 23a4612..f83fd74 100644 --- a/src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java +++ b/src/main/java/mod/leronus/mores/item/custom/ModSwordItem.java @@ -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; @@ -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; @@ -56,15 +54,15 @@ public Multimap getAttributeModifiers( @Override public void appendTooltip(ItemStack stack, @Nullable World world, List 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))); } } }