Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new constructor to SwordItem to allow setting Tool data component #1046

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion patches/net/minecraft/world/item/SwordItem.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
--- a/net/minecraft/world/item/SwordItem.java
+++ b/net/minecraft/world/item/SwordItem.java
@@ -26,6 +_,13 @@
@@ -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_) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,5 @@ public com.mojang.blaze3d.vertex.VertexFormatElement$Usage$SetupState
public com.mojang.blaze3d.vertex.VertexFormatElement$Usage$ClearState
public net.minecraft.world.level.block.LiquidBlock fluid
public net.minecraft.world.item.BucketItem content
public net.minecraft.world.item.ItemStack addToTooltip(Lnet/minecraft/core/component/DataComponentType;Lnet/minecraft/world/item/Item$TooltipContext;Ljava/util/function/Consumer;Lnet/minecraft/world/item/TooltipFlag;)V
public net.minecraft.world.item.ItemStack addToTooltip(Lnet/minecraft/core/component/DataComponentType;Lnet/minecraft/world/item/Item$TooltipContext;Ljava/util/function/Consumer;Lnet/minecraft/world/item/TooltipFlag;)V
public net.minecraft.world.item.SwordItem createToolProperties()Lnet/minecraft/world/item/component/Tool;
Loading