Skip to content

Commit cfa15f2

Browse files
committed
Add swords to dual weapons and axes to melee weapons.
Axes are almost always considered melee weapons anyway. Additionally Swords should always be considered dual weapons.
1 parent ee04ce2 commit cfa15f2

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.provismet.CombatPlusCore.mixin;
2+
3+
import org.spongepowered.asm.mixin.Mixin;
4+
5+
import com.provismet.CombatPlusCore.interfaces.MeleeWeapon;
6+
7+
import net.minecraft.block.Block;
8+
import net.minecraft.item.AxeItem;
9+
import net.minecraft.item.MiningToolItem;
10+
import net.minecraft.item.ToolMaterial;
11+
import net.minecraft.registry.tag.TagKey;
12+
13+
@Mixin(AxeItem.class)
14+
public class AxeItemMixin extends MiningToolItem implements MeleeWeapon {
15+
protected AxeItemMixin(float attackDamage, float attackSpeed, ToolMaterial material, TagKey<Block> effectiveBlocks, Settings settings) {
16+
super(attackDamage, attackSpeed, material, effectiveBlocks, settings);
17+
}
18+
19+
@Override
20+
public float getWeaponDamage () {
21+
return this.getAttackDamage();
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.provismet.CombatPlusCore.mixin;
2+
3+
import org.spongepowered.asm.mixin.Final;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.Shadow;
6+
7+
import com.provismet.CombatPlusCore.interfaces.DualWeapon;
8+
9+
import net.minecraft.item.SwordItem;
10+
import net.minecraft.item.ToolItem;
11+
import net.minecraft.item.ToolMaterial;
12+
13+
@Mixin(SwordItem.class)
14+
public abstract class SwordItemMixin extends ToolItem implements DualWeapon {
15+
protected SwordItemMixin (ToolMaterial material, Settings settings) {
16+
super(material, settings);
17+
}
18+
19+
@Shadow
20+
@Final
21+
private float attackDamage;
22+
23+
@Override
24+
public float getWeaponDamage () {
25+
return this.attackDamage;
26+
}
27+
}

src/main/resources/combat-plus.mixins.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"mixins": [
66
"ItemStackMixin",
77
"PlayerEntityMixin",
8-
"MobEntityMixin"
8+
"MobEntityMixin",
9+
"AxeItemMixin",
10+
"SwordItemMixin"
911
],
1012
"injectors": {
1113
"defaultRequire": 1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"replace": false,
33
"values": [
4-
"#combat-plus:dual_weapon"
4+
"#combat-plus:dual_weapon",
5+
{
6+
"required": false,
7+
"id": "#minecraft:axes"
8+
}
59
]
610
}

0 commit comments

Comments
 (0)