Skip to content

Commit

Permalink
Fixed Fillet Knifes being able to do sweeping damage. Closes #424
Browse files Browse the repository at this point in the history
  • Loading branch information
GirafiStudios committed Dec 31, 2023
1 parent 1477861 commit ec50652
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
minecraft_version=1.20.4
minecraft_version_range=[1.20.4,1.21)
neo_version=20.4.41-beta
neo_version=20.4.62-beta
neo_version_range=[20.4.35-beta,)
loader_version_range=[1,)
pack_format_number=18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static DeferredItem<Item> registerHook(Hook hook) {
}

public static class Tags {
public static final TagKey<Item> FILLET_KNIFE = tag("forge", "tools/knives");
public static final TagKey<Item> KNIVES = tag("forge", "tools/knives");
public static final TagKey<Item> FISHING_LINE = tag(Aquaculture.MOD_ID, "fishing_line");
public static final TagKey<Item> BOBBER = tag(Aquaculture.MOD_ID, "bobber");
public static final TagKey<Item> TACKLE_BOX = tag(Aquaculture.MOD_ID, "tackle_box");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import net.minecraft.world.level.Level;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import net.neoforged.neoforge.common.ToolAction;
import net.neoforged.neoforge.common.ToolActions;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -39,7 +41,7 @@ public ItemFilletKnife(Tier material) {
public boolean canApplyAtEnchantingTable(@Nonnull ItemStack stack, Enchantment enchantment) {
return super.canApplyAtEnchantingTable(stack, enchantment) && canApplyEnchantment(enchantment);
}

private boolean canApplyEnchantment(Enchantment enchantment) {
return enchantment != Enchantments.MOB_LOOTING && enchantment != Enchantments.SWEEPING_EDGE;
}
Expand All @@ -54,6 +56,12 @@ public float getDamage() {
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(@Nonnull EquipmentSlot slotType) {
return slotType == EquipmentSlot.MAINHAND ? this.attributes : ImmutableMultimap.of();
}

@Override
public boolean canPerformAction(@Nonnull ItemStack stack, @Nonnull ToolAction toolAction) {
return toolAction == ToolActions.SWORD_DIG;
}

@Override
@OnlyIn(Dist.CLIENT)
public void appendHoverText(@Nonnull ItemStack stack, @Nullable Level world, @Nonnull List<Component> tooltip, @Nonnull TooltipFlag tooltipFlag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean matches(@Nonnull CraftingContainer craftingInventory, @Nonnull Le
}
stack = slotStack;
} else {
if (!(slotStack.is(AquacultureAPI.Tags.FILLET_KNIFE) && (slotStack.isDamageableItem() || isKnifeNeptunium(slotStack.getItem())) && slotStack.getItem() instanceof TieredItem)) {
if (!(slotStack.is(AquacultureAPI.Tags.KNIVES) && (slotStack.isDamageableItem() || isKnifeNeptunium(slotStack.getItem())) && slotStack.getItem() instanceof TieredItem)) {
return false;
}
list.add(slotStack);
Expand All @@ -73,7 +73,7 @@ public ItemStack assemble(@Nonnull CraftingContainer craftingInventory, Registry
}
fish = stackSlot.copy();
} else {
if (!(stackSlot.is(AquacultureAPI.Tags.FILLET_KNIFE))) {
if (!(stackSlot.is(AquacultureAPI.Tags.KNIVES))) {
return ItemStack.EMPTY;
}
knife = item;
Expand All @@ -100,7 +100,7 @@ public NonNullList<ItemStack> getRemainingItems(CraftingContainer craftingInvent
NonNullList<ItemStack> list = NonNullList.withSize(craftingInventory.getContainerSize(), ItemStack.EMPTY);
for (int i = 0; i < list.size(); ++i) {
ItemStack stack = craftingInventory.getItem(i);
if (stack.is(AquacultureAPI.Tags.FILLET_KNIFE)) {
if (stack.is(AquacultureAPI.Tags.KNIVES)) {
ItemStack knife = stack.copy();
if (!isKnifeNeptunium(knife.getItem())) {
if (knife.hurt(1, RandomSource.create(), null)) {
Expand Down

0 comments on commit ec50652

Please sign in to comment.