Skip to content

Commit

Permalink
Fixed Crossbow damage offset in 1.18 -> 1.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Nov 11, 2023
1 parent b9cecbf commit 4f5ce22
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;

import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.item.CrossbowItem;
import net.minecraft.item.Item;
import net.raphimc.vialoader.util.VersionEnum;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(Item.class)
public class MixinItem {

@Shadow @Final private int maxDamage;

@Redirect(method = { "getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor" }, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
public int changeCrossbowDamage(Item instance) {
if (instance instanceof CrossbowItem && ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_18tor1_18_1)) {
return 326;
}

return maxDamage;
}
}
33 changes: 17 additions & 16 deletions src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,32 +147,33 @@
"fixes.vialegacy.MixinProtocol1_8to1_7_6_10",
"fixes.vialegacy.MixinProtocolc0_30toc0_30cpe",
"fixes.vialegacy.MixinViaLegacyConfig",
"fixes.viaversion.MixinChatItemRewriter",
"fixes.viaversion.MixinChunkType1_8",
"fixes.viaversion.MixinCommandBlockProvider",
"fixes.viaversion.MixinCommonBoss",
"fixes.viaversion.MixinNamedCompoundTagType",
"viaversion.MixinProtocolVersion",
"fixes.viaversion.MixinEntityIdRewriter",
"fixes.viaversion.MixinEntityPackets1_17",
"fixes.viaversion.MixinEntityPackets_6_1",
"fixes.viaversion.MixinEntityTracker1_9",
"fixes.viaversion.MixinInventoryAcknowledgements",
"fixes.viaversion.MixinInventoryPackets",
"fixes.viaversion.MixinMetadataRewriter1_15To1_14_4",
"fixes.viaversion.MixinMetadataRewriter1_9To1_8",
"fixes.viaversion.MixinNamedCompoundTagType",
"fixes.viaversion.MixinProtocol1_11To1_10",
"fixes.viaversion.MixinChatItemRewriter",
"viaversion.MixinAbstractFenceConnectionHandler",
"viaversion.MixinGlassConnectionHandler",
"fixes.viaversion.MixinProtocol1_12To1_11_1_3",
"fixes.viaversion.MixinSkullHandler",
"fixes.viaversion.MixinWorldPackets1_13",
"fixes.viaversion.MixinInventoryPackets",
"fixes.viaversion.MixinMetadataRewriter1_15To1_14_4",
"fixes.viaversion.MixinWorldPackets1_16_2",
"fixes.viaversion.MixinEntityPackets1_17",
"fixes.viaversion.MixinInventoryAcknowledgements",
"fixes.viaversion.MixinWorldPackets1_17",
"fixes.viaversion.MixinWorldPackets1_19",
"fixes.viaversion.MixinChunkType1_8",
"fixes.viaversion.MixinCommandBlockProvider",
"fixes.viaversion.MixinEntityPackets_6_1",
"fixes.viaversion.MixinEntityTracker1_9",
"fixes.viaversion.MixinMetadataRewriter1_9To1_8",
"jsonwebtoken.MixinClasses",
"jsonwebtoken.MixinDefaultJwtParserBuilder",
"fixes.viaversion.MixinProtocol1_12To1_11_1_3",
"viaversion.MixinProtocol1_13To1_12_2"
"viaversion.MixinAbstractFenceConnectionHandler",
"viaversion.MixinGlassConnectionHandler",
"viaversion.MixinProtocol1_13To1_12_2",
"viaversion.MixinProtocolVersion",
"fixes.minecraft.item.MixinItem"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 4f5ce22

Please sign in to comment.