Random code cleanup again ™️

This commit is contained in:
FlorianMichael 2024-03-04 14:58:52 +01:00
parent 52d62b0fe1
commit 2a5648fcca
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
4 changed files with 8 additions and 7 deletions

View File

@ -67,7 +67,7 @@ public abstract class MixinItemStack implements IItemStack {
if (DebugSettings.global().replaceAttributeModifiers.isEnabled() && !modifiers.isEmpty()) {
modifiers = HashMultimap.create(modifiers);
modifiers.removeAll(EntityAttributes.GENERIC_ATTACK_DAMAGE);
if (getItem() instanceof MiningToolItem tool && !(tool instanceof HoeItem) /* Hoe items didn't use the tool abstraction */) {
if (getItem() instanceof MiningToolItem tool && !(tool instanceof HoeItem) /* hoe doesn't use the tool abstraction in 1.8 */) {
modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Tool modifier", tool.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION));
} else if (getItem() instanceof SwordItem sword) {
modifiers.put(EntityAttributes.GENERIC_ATTACK_DAMAGE, new EntityAttributeModifier(Item.ATTACK_DAMAGE_MODIFIER_ID, "Weapon modifier", sword.getAttackDamage(), EntityAttributeModifier.Operation.ADDITION));

View File

@ -37,18 +37,19 @@ public abstract class MixinMiningToolItem extends ToolItem {
}
/**
* @author Mojang, FlorianMichael/EnZaXD
* @author FlorianMichael/EnZaXD
* @reason Change attack damage calculation
*/
@Overwrite
public float getAttackDamage() {
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)) {
final float materialDamage = getMaterial().getAttackDamage();
if ((Item) this instanceof PickaxeItem) {
return 2 + getMaterial().getAttackDamage();
return 2 + materialDamage;
} else if ((Item) this instanceof ShovelItem) {
return 1 + getMaterial().getAttackDamage();
return 1 + materialDamage;
} else if ((Item) this instanceof AxeItem) {
return 3 + getMaterial().getAttackDamage();
return 3 + materialDamage;
}
}
return this.attackDamage;

View File

@ -77,7 +77,7 @@ public abstract class MixinSwordItem extends ToolItem {
}
/**
* @author Mojang, FlorianMichael/EnZaXD
* @author FlorianMichael/EnZaXD
* @reason Change attack damage calculation
*/
@Overwrite

View File

@ -49,7 +49,7 @@ public class ItemTranslator {
* Converts a Minecraft item stack to a ViaVersion item stack
*
* @param stack The Minecraft item stack
* @param targetVersion The target version to convert to (e.g. r1.13)
* @param targetVersion The target version to convert to (e.g. v1.13)
* @return The ViaVersion item stack for the target version
*/
public static Item mcToVia(final ItemStack stack, final ProtocolVersion targetVersion) {