From 5e286c0e62bd4b988fd2bfabce02567d3a8c8661 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Tue, 7 Mar 2023 17:15:36 +0100 Subject: [PATCH] forgot version if for attribute fix --- .../injection/mixin/fixes/item/MixinItemStack.java | 10 +++++----- .../viafabricplus/settings/groups/DebugSettings.java | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java index 3434331a..7808922e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/item/MixinItemStack.java @@ -3,6 +3,7 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.item; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.viafabricplus.settings.groups.DebugSettings; import de.florianmichael.vialoadingbase.ViaLoadingBase; import net.minecraft.block.BlockState; import net.minecraft.entity.attribute.EntityAttribute; @@ -47,12 +48,11 @@ public abstract class MixinItemStack { @SuppressWarnings({"InvalidInjectorMethodSignature", "MixinAnnotationTarget"}) @ModifyVariable(method = "getAttributeModifiers", ordinal = 0, at = @At(value = "STORE", ordinal = 1)) private Multimap modifyVariableGetAttributeModifiers(Multimap modifiers) { - if (modifiers.isEmpty()) { - return modifiers; - } + if (!DebugSettings.getClassWrapper().replaceAttributeModifiers.getValue() || modifiers.isEmpty()) return modifiers; + modifiers = HashMultimap.create(modifiers); modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE); - OptionalDouble defaultAttackDamage = protocolhack_getDefaultAttackDamage(getItem()); + OptionalDouble defaultAttackDamage = viafabricplus_getDefaultAttackDamage(getItem()); if (defaultAttackDamage.isPresent()) { modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Weapon Modifier", defaultAttackDamage.getAsDouble(), EntityAttributeModifier.Operation.ADDITION)); } @@ -63,7 +63,7 @@ public abstract class MixinItemStack { } @Unique - private OptionalDouble protocolhack_getDefaultAttackDamage(Item item) { + private OptionalDouble viafabricplus_getDefaultAttackDamage(Item item) { if (item instanceof ToolItem) { ToolMaterial material = ((ToolItem) item).getMaterial(); int materialBonus; diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/groups/DebugSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/groups/DebugSettings.java index 510b7768..8fd11370 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/groups/DebugSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/groups/DebugSettings.java @@ -26,6 +26,7 @@ public class DebugSettings extends SettingGroup { // 1.9 -> 1.8.x public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, "Remove cooldowns", ProtocolRange.andOlder(ProtocolVersion.v1_8)); public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, "Send idle packet", new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2)); + public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, "Replace attribute modifiers", ProtocolRange.andOlder(ProtocolVersion.v1_8)); // 1.8.x -> 1.7.6 public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, "Replace sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));