Skip to content

Commit

Permalink
Restore two lost SwordItem patches (#1046 and #1010) (#1102)
Browse files Browse the repository at this point in the history
  • Loading branch information
TelepathicGrunt authored Jun 14, 2024
1 parent d9ee601 commit e7aeaa8
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions patches/net/minecraft/world/item/SwordItem.java.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
--- a/net/minecraft/world/item/SwordItem.java
+++ b/net/minecraft/world/item/SwordItem.java
@@ -56,4 +_,9 @@
@@ -21,11 +_,25 @@
super(p_43269_, p_43272_.component(DataComponents.TOOL, createToolProperties()));
}

+ /**
+ * Neo: Allow modded Swords to set exactly what Tool data component to use for their sword.
+ */
+ public SwordItem(Tier tier, Item.Properties properties, Tool toolComponentData) {
+ super(tier, properties.component(DataComponents.TOOL, toolComponentData));
+ }
+
public static Tool createToolProperties() {
return new Tool(List.of(Tool.Rule.minesAndDrops(List.of(Blocks.COBWEB), 15.0F), Tool.Rule.overrideSpeed(BlockTags.SWORD_EFFICIENT, 1.5F)), 1.0F, 2);
}

public static ItemAttributeModifiers createAttributes(Tier p_330371_, int p_331976_, float p_332104_) {
+ return createAttributes(p_330371_, (float)p_331976_, p_332104_);
+ }
+
+ /**
+ * Neo: Method overload to allow giving a float for damage instead of an int.
+ */
+ public static ItemAttributeModifiers createAttributes(Tier p_330371_, float p_331976_, float p_332104_) {
return ItemAttributeModifiers.builder()
.add(
Attributes.ATTACK_DAMAGE,
@@ -55,5 +_,10 @@
@Override
public void postHurtEnemy(ItemStack p_345553_, LivingEntity p_345771_, LivingEntity p_346282_) {
p_345553_.hurtAndBreak(1, p_346282_, EquipmentSlot.MAINHAND);
}
+ }
+
+ @Override
+ public boolean canPerformAction(ItemStack stack, net.neoforged.neoforge.common.ToolAction toolAction) {
+ return net.neoforged.neoforge.common.ToolActions.DEFAULT_SWORD_ACTIONS.contains(toolAction);
+ }
}
}

0 comments on commit e7aeaa8

Please sign in to comment.