From d9185301486c9829a1d8813d3b6831f29e2490a4 Mon Sep 17 00:00:00 2001 From: PainterFlow11 <163044531+PainterFlow@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:39:25 +0100 Subject: [PATCH 1/3] - working on ToolMaterialMixin --- .../mixin/world/item/items/ToolMaterialMixin.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java b/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java index b2d49c8d..257e627a 100644 --- a/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java +++ b/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java @@ -8,9 +8,11 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.tags.BlockTags; +import net.minecraft.tags.TagKey; import net.minecraft.world.entity.EquipmentSlotGroup; import net.minecraft.world.item.Item; import net.minecraft.world.item.ToolMaterial; +import net.minecraft.world.item.component.ItemAttributeModifiers; import net.minecraft.world.item.component.Tool; import net.minecraft.world.item.component.Weapon; import net.minecraft.world.level.block.Block; @@ -32,6 +34,10 @@ public abstract class ToolMaterialMixin { private Item.Properties applyCommonProperties(Item.Properties properties) { throw new AssertionError(); } + @Shadow + private ItemAttributeModifiers createToolAttributes(float f, float g) { + throw new AssertionError(); + } @Unique private static final Map SWORD = Map.of( ToolMaterial.WOOD, new GeneralWeapon(vsqIdentifiers.vsqSwordOverride.identifier(), EquipmentSlotGroup.MAINHAND,3.0d, -2.4d, 0.0d), @@ -61,8 +67,15 @@ private void applySwordProperties(Item.Properties properties, float f, float g, return; } + HolderGetter holderGetter = BuiltInRegistries.acquireBootstrapRegistrationLookup(BuiltInRegistries.BLOCK); + cir.setReturnValue(this.applyCommonProperties(properties).component(DataComponents.TOOL, new Tool(List.of(Tool.Rule.minesAndDrops(HolderSet.direct(Blocks.COBWEB.builtInRegistryHolder()), 15.0F), Tool.Rule.overrideSpeed(holderGetter.getOrThrow(BlockTags.SWORD_INSTANTLY_MINES), Float.MAX_VALUE), Tool.Rule.overrideSpeed(holderGetter.getOrThrow(BlockTags.SWORD_EFFICIENT), 1.5F)), 1.0F, 2, false)).attributes(swordAttributes.build()).component(DataComponents.WEAPON, new Weapon(1))); + } + @Inject(method = "applyToolProperties", at = @At("HEAD"), cancellable = true) + private void applyToolProperties (Item.Properties properties, TagKey tagKey, float f, float g, float h, CallbackInfoReturnable cir) { + ToolMaterial material = (ToolMaterial) (Object) this; Dura durability = DURABILITY.getOrDefault(material, Dura.DEFAULT); HolderGetter holderGetter = BuiltInRegistries.acquireBootstrapRegistrationLookup(BuiltInRegistries.BLOCK); - cir.setReturnValue(this.applyCommonProperties(properties).component(DataComponents.TOOL, new Tool(List.of(Tool.Rule.minesAndDrops(HolderSet.direct(Blocks.COBWEB.builtInRegistryHolder()), 15.0F), Tool.Rule.overrideSpeed(holderGetter.getOrThrow(BlockTags.SWORD_INSTANTLY_MINES), Float.MAX_VALUE), Tool.Rule.overrideSpeed(holderGetter.getOrThrow(BlockTags.SWORD_EFFICIENT), 1.5F)), 1.0F, 2, false)).attributes(swordAttributes.build()).component(DataComponents.WEAPON, new Weapon(1)).durability(durability.dura())); + + cir.setReturnValue(this.applyCommonProperties(properties).component(DataComponents.TOOL, new Tool(List.of(Tool.Rule.deniesDrops(holderGetter.getOrThrow(this.incorrectBlocksForDrops)), Tool.Rule.minesAndDrops(holderGetter.getOrThrow(tagKey), this.speed)), 1.0F, 1, true)).attributes(this.createToolAttributes(f, g)).component(DataComponents.WEAPON, new Weapon(2, h)).durability(durability.dura())); } } From 48fbe8e2220c278511283da52cb963e4c0050f23 Mon Sep 17 00:00:00 2001 From: pxlarified Date: Tue, 24 Feb 2026 17:42:32 +0100 Subject: [PATCH 2/3] fix blablalbasd --- .../mixin/world/item/items/ToolMaterialMixin.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java b/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java index 257e627a..55a86324 100644 --- a/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java +++ b/src/main/java/blob/vanillasquared/mixin/world/item/items/ToolMaterialMixin.java @@ -20,6 +20,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -30,6 +31,14 @@ @Mixin(ToolMaterial.class) public abstract class ToolMaterialMixin { + @Shadow + @Final + private TagKey incorrectBlocksForDrops; + + @Shadow + @Final + private float speed; + @Shadow private Item.Properties applyCommonProperties(Item.Properties properties) { throw new AssertionError(); From b6a0163d8e2fff68ea60e2ad99753bf95c28227f Mon Sep 17 00:00:00 2001 From: PainterFlow11 <163044531+PainterFlow@users.noreply.github.com> Date: Tue, 24 Feb 2026 17:44:20 +0100 Subject: [PATCH 3/3] - removed Durability Override in AxeMixin --- .../mixin/world/item/items/AxeMixin.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/main/java/blob/vanillasquared/mixin/world/item/items/AxeMixin.java b/src/main/java/blob/vanillasquared/mixin/world/item/items/AxeMixin.java index 6bc1f6d4..c5aff091 100644 --- a/src/main/java/blob/vanillasquared/mixin/world/item/items/AxeMixin.java +++ b/src/main/java/blob/vanillasquared/mixin/world/item/items/AxeMixin.java @@ -2,7 +2,6 @@ import blob.vanillasquared.util.data.BlockComponent; import blob.vanillasquared.util.data.GeneralWeapon; -import blob.vanillasquared.util.data.Dura; import blob.vanillasquared.util.api.other.vsqIdentifiers; import net.minecraft.core.component.DataComponents; import net.minecraft.tags.BlockTags; @@ -47,17 +46,6 @@ ToolMaterial.DIAMOND, new BlockComponent(0.65F, 0.5F, 0.5F, 1.0F), ToolMaterial.NETHERITE, new BlockComponent(0.7F, 0.55F, 0.55F, 1.0F) ); - @Unique - private static final Map DURABILITY = Map.of( - ToolMaterial.WOOD, new Dura(75), - ToolMaterial.STONE, new Dura(150), - ToolMaterial.COPPER, new Dura(200), - ToolMaterial.IRON, new Dura(250), - ToolMaterial.GOLD, new Dura(100), - ToolMaterial.DIAMOND, new Dura(1550), - ToolMaterial.NETHERITE, new Dura(2069) - ); - @Inject(at = @At("HEAD"), method = "axe", cancellable = true) public void init(ToolMaterial toolMaterial, float f, float g, CallbackInfoReturnable cir) { BlockComponent blockComponent = BLOCK_COMPONENT.get(toolMaterial); @@ -66,8 +54,6 @@ public void init(ToolMaterial toolMaterial, float f, float g, CallbackInfoReturn return; } - Dura durability = DURABILITY.getOrDefault(toolMaterial, Dura.DEFAULT); - - cir.setReturnValue(this.tool(toolMaterial, BlockTags.MINEABLE_WITH_AXE, f, g, 5.0F).component(DataComponents.BLOCKS_ATTACKS, blockComponent.build()).component(DataComponents.WEAPON, new Weapon(1, 5.0F)).attributes(generalWeapon.build()).durability(durability.dura())); + cir.setReturnValue(this.tool(toolMaterial, BlockTags.MINEABLE_WITH_AXE, f, g, 5.0F).component(DataComponents.BLOCKS_ATTACKS, blockComponent.build()).component(DataComponents.WEAPON, new Weapon(1, 5.0F)).attributes(generalWeapon.build())); } }