-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d9ee601
commit e7aeaa8
Showing
1 changed file
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
+ } | ||
} | ||
} |