generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
186 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jdk: | ||
- openjdk17 |
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/client/java/com/example/mixin/client/ExampleClientMixin.java
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.provismet.CombatPlusCore; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
|
||
public class CPCMain implements ModInitializer { | ||
public static final String MODID = "combatplus-core"; | ||
public static final Logger LOGGER = LoggerFactory.getLogger("Combat+ Core"); | ||
|
||
@Override | ||
public void onInitialize () { | ||
|
||
} | ||
|
||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/provismet/CombatPlusCore/api/CombatPlusEntrypoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.provismet.CombatPlusCore.api; | ||
|
||
public interface CombatPlusEntrypoint { | ||
public void onInitialize (); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/provismet/CombatPlusCore/enchantments/ExtraEnchantmentTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.provismet.CombatPlusCore.enchantments; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import net.minecraft.item.Item; | ||
import net.minecraft.item.SwordItem; | ||
|
||
public class ExtraEnchantmentTarget { | ||
private List<Class<? extends Item>> targets; | ||
|
||
public static ExtraEnchantmentTarget DualWeapons; | ||
|
||
public ExtraEnchantmentTarget () { | ||
this.targets = new ArrayList<>(); | ||
} | ||
|
||
public boolean add (Class<? extends Item> itemClass) { | ||
return this.targets.add(itemClass); | ||
} | ||
|
||
public boolean accepts (Item item) { | ||
for (Class<? extends Item> itemClass : this.targets) { | ||
if (itemClass.isInstance(item)) return true; | ||
} | ||
return false; | ||
} | ||
|
||
public static void init () { | ||
DualWeapons = new ExtraEnchantmentTarget(); | ||
DualWeapons.add(SwordItem.class); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/provismet/CombatPlusCore/enchantments/OffHandEnchantment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.provismet.CombatPlusCore.enchantments; | ||
|
||
import com.provismet.CombatPlusCore.interfaces.CPCEnchantment; | ||
|
||
import net.minecraft.enchantment.DamageEnchantment; | ||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.enchantment.EnchantmentTarget; | ||
import net.minecraft.enchantment.FireAspectEnchantment; | ||
import net.minecraft.enchantment.LuckEnchantment; | ||
import net.minecraft.enchantment.SweepingEnchantment; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.item.ItemStack; | ||
|
||
public abstract class OffHandEnchantment extends Enchantment implements CPCEnchantment { | ||
|
||
protected OffHandEnchantment (Rarity weight, EnchantmentTarget target, EquipmentSlot[] slotTypes) { | ||
super(weight, target, new EquipmentSlot[] {EquipmentSlot.OFFHAND}); | ||
} | ||
|
||
@Override | ||
public boolean canAccept (Enchantment other) { | ||
return super.canAccept(other) && | ||
!(other instanceof DamageEnchantment) && | ||
!(other instanceof FireAspectEnchantment) && | ||
!(other instanceof SweepingEnchantment) && | ||
!(other instanceof LuckEnchantment); | ||
} | ||
|
||
@Override | ||
public boolean isAcceptableItem (ItemStack itemStack) { | ||
return ExtraEnchantmentTarget.DualWeapons.accepts(itemStack.getItem()); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/provismet/CombatPlusCore/interfaces/CPCEnchantment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.provismet.CombatPlusCore.interfaces; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
|
||
public interface CPCEnchantment { | ||
public default float getAttackDamage (int level, LivingEntity user, LivingEntity target) { | ||
return 0f; | ||
} | ||
|
||
public default boolean shouldApplyDamage (int level, EquipmentSlot slot, LivingEntity user, @Nullable LivingEntity target) { | ||
return false; | ||
} | ||
|
||
public default boolean shouldApplyEffects (int level, EquipmentSlot slot, LivingEntity user, @Nullable LivingEntity target) { | ||
return false; | ||
} | ||
|
||
public default void postChargeHit (int level, LivingEntity user, LivingEntity target) { | ||
|
||
} | ||
|
||
public default void postCriticalHit (int level, LivingEntity user, LivingEntity target) { | ||
|
||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/provismet/CombatPlusCore/utility/CPCEnchantmentHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.provismet.CombatPlusCore.utility; | ||
|
||
import org.apache.commons.lang3.mutable.MutableFloat; | ||
|
||
import com.provismet.CombatPlusCore.interfaces.CPCEnchantment; | ||
|
||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.enchantment.EnchantmentHelper; | ||
import net.minecraft.entity.EquipmentSlot; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.NbtCompound; | ||
import net.minecraft.nbt.NbtList; | ||
import net.minecraft.registry.Registries; | ||
|
||
public class CPCEnchantmentHelper { | ||
public static float getAttackDamage (LivingEntity user, LivingEntity target) { | ||
MutableFloat totalDamage = new MutableFloat(); | ||
|
||
for (EquipmentSlot slot : EquipmentSlot.values()) { | ||
ItemStack itemStack = user.getEquippedStack(slot); | ||
|
||
CPCEnchantmentHelper.forEach((enchantment, level) -> { | ||
if (enchantment instanceof CPCEnchantment cpcEnchant && cpcEnchant.shouldApplyDamage(level, slot, user, target)) totalDamage.add(cpcEnchant.getAttackDamage(level, user, target)); | ||
else totalDamage.add(enchantment.getAttackDamage(level, target.getGroup())); | ||
}, itemStack); | ||
} | ||
return totalDamage.floatValue(); | ||
} | ||
|
||
public static void forEach (Consumer consumer, ItemStack itemStack) { | ||
if (itemStack.isEmpty()) return; | ||
|
||
NbtList nbtList = itemStack.getEnchantments(); | ||
for (int i = 0; i < nbtList.size(); ++i) { | ||
NbtCompound nbtCompound = nbtList.getCompound(i); | ||
Registries.ENCHANTMENT.getOrEmpty(EnchantmentHelper.getIdFromNbt(nbtCompound)).ifPresent(enchantment -> consumer.accept(enchantment, EnchantmentHelper.getLevelFromNbt(nbtCompound))); | ||
} | ||
} | ||
|
||
@FunctionalInterface | ||
private static interface Consumer { | ||
public void accept (Enchantment enchantment, int level); | ||
} | ||
} |
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,39 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "modid", | ||
"id": "combat-plus", | ||
"version": "${version}", | ||
"name": "Example mod", | ||
"description": "This is an example description! Tell everyone what your mod is about!", | ||
"name": "Combat+ Core", | ||
"description": "Core library mod for the Combat+ series.", | ||
"authors": [ | ||
"Me!" | ||
"Provismet" | ||
], | ||
"contact": { | ||
"homepage": "https://fabricmc.net/", | ||
"sources": "https://github.com/FabricMC/fabric-example-mod" | ||
}, | ||
"license": "CC0-1.0", | ||
"icon": "assets/modid/icon.png", | ||
"license": "MIT", | ||
"icon": "assets/combat-plus/icon.png", | ||
"environment": "*", | ||
"entrypoints": { | ||
"main": [ | ||
"com.example.ExampleMod" | ||
], | ||
"client": [ | ||
"com.example.ExampleModClient" | ||
"com.provismet.CombatPlusCore.CPCMain" | ||
] | ||
}, | ||
"mixins": [ | ||
"modid.mixins.json", | ||
{ | ||
"config": "modid.client.mixins.json", | ||
"environment": "client" | ||
} | ||
], | ||
"depends": { | ||
"fabricloader": ">=0.15.0", | ||
"minecraft": "~1.20.4", | ||
"fabricloader": ">=0.14.0", | ||
"minecraft": "~1.20", | ||
"java": ">=17", | ||
"fabric-api": "*" | ||
}, | ||
"suggests": { | ||
"another-mod": "*" | ||
} | ||
"extra-damage-enchantments": "*", | ||
"dual-swords": "*" | ||
}, | ||
"custom": { | ||
"modmenu": { | ||
"badges": ["library"] | ||
} | ||
} | ||
} |