mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-31 18:18:04 +01:00
Implemented armor durability changes in <= b1.8.1
This commit is contained in:
parent
2840877b61
commit
4cfd04d4d8
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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.access;
|
||||
|
||||
import net.minecraft.item.ArmorItem;
|
||||
|
||||
public interface IArmorMaterials {
|
||||
|
||||
int viaFabricPlus$getBaseMultiplier(final ArmorItem.Type type);
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2024 FlorianMichael/EnZaXD <florian.michael07@gmail.com> and RK_01/RaphiMC
|
||||
* Copyright (C) 2023-2024 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.injection.access.IArmorMaterials;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.ArmorMaterials;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
@Mixin(ArmorMaterials.class)
|
||||
public abstract class MixinArmorMaterials implements IArmorMaterials {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private static EnumMap<ArmorItem.Type, Integer> BASE_DURABILITY;
|
||||
|
||||
@Override
|
||||
public int viaFabricPlus$getBaseMultiplier(ArmorItem.Type type) {
|
||||
return BASE_DURABILITY.get(type);
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,10 @@ package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft.item;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import de.florianmichael.viafabricplus.injection.access.IArmorMaterials;
|
||||
import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator;
|
||||
import net.minecraft.item.ArmorItem;
|
||||
import net.minecraft.item.ArmorMaterials;
|
||||
import net.minecraft.item.CrossbowItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
@ -45,7 +48,20 @@ public abstract class MixinItem {
|
||||
|
||||
@Redirect(method = {"getMaxDamage", "isDamageable", "getItemBarStep", "getItemBarColor"}, at = @At(value = "FIELD", target = "Lnet/minecraft/item/Item;maxDamage:I"))
|
||||
private int changeCrossbowDamage(Item instance) {
|
||||
if (instance instanceof CrossbowItem && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
if (instance instanceof ArmorItem armor && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
|
||||
final int baseMultiplier = ((IArmorMaterials) armor.getMaterial()).viaFabricPlus$getBaseMultiplier(armor.getType());
|
||||
if (armor.getMaterial() == ArmorMaterials.LEATHER)
|
||||
return baseMultiplier * 3;
|
||||
else if (armor.getMaterial() == ArmorMaterials.CHAIN || armor.getMaterial() == ArmorMaterials.GOLD)
|
||||
return baseMultiplier * 6;
|
||||
else if (armor.getMaterial() == ArmorMaterials.IRON)
|
||||
return baseMultiplier * 12;
|
||||
else if (armor.getMaterial() == ArmorMaterials.DIAMOND)
|
||||
return baseMultiplier * 24;
|
||||
else
|
||||
return maxDamage;
|
||||
} else
|
||||
if (instance instanceof CrossbowItem && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_17_1)) {
|
||||
return 326;
|
||||
} else {
|
||||
return maxDamage;
|
||||
|
@ -199,7 +199,8 @@
|
||||
"vialegacy.MixinExtensionProtocolMetadataStorage",
|
||||
"vialegacy.MixinViaLegacyConfig",
|
||||
"viaversion.MixinConfig",
|
||||
"viaversion.MixinProtocolVersion"
|
||||
"viaversion.MixinProtocolVersion",
|
||||
"fixes.minecraft.item.MixinArmorMaterials"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
Loading…
Reference in New Issue
Block a user