From e7aeaa83e74dfa43582016ce8f7a584eb09a4c1b Mon Sep 17 00:00:00 2001 From: TelepathicGrunt <40846040+TelepathicGrunt@users.noreply.github.com> Date: Fri, 14 Jun 2024 11:25:54 -0400 Subject: [PATCH] Restore two lost SwordItem patches (#1046 and #1010) (#1102) --- .../minecraft/world/item/SwordItem.java.patch | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/patches/net/minecraft/world/item/SwordItem.java.patch b/patches/net/minecraft/world/item/SwordItem.java.patch index f03be3c3fd..1549f174cf 100644 --- a/patches/net/minecraft/world/item/SwordItem.java.patch +++ b/patches/net/minecraft/world/item/SwordItem.java.patch @@ -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); -+ } + } }