Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Provismet committed Dec 17, 2023
1 parent b4f1a7e commit 64e0c3e
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 110 deletions.
12 changes: 0 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ repositories {
// for more information about repositories.
}

loom {
splitEnvironmentSourceSets()

mods {
"modid" {
sourceSet sourceSets.main
sourceSet sourceSets.client
}
}

}

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.1
loader_version=0.15.0
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.2

# Mod Properties
mod_version=1.0.0
maven_group=com.example
archives_base_name=modid
maven_group=com.provismet
archives_base_name=combatplus-core

# Dependencies
fabric_version=0.91.1+1.20.4
fabric_version=0.91.0+1.20.1
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
10 changes: 0 additions & 10 deletions src/client/java/com/example/ExampleModClient.java

This file was deleted.

15 changes: 0 additions & 15 deletions src/client/java/com/example/mixin/client/ExampleClientMixin.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/client/resources/modid.client.mixins.json

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/com/example/ExampleMod.java

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/java/com/example/mixin/ExampleMixin.java

This file was deleted.

17 changes: 17 additions & 0 deletions src/main/java/com/provismet/CombatPlusCore/CPCMain.java
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 () {

}

}
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 ();
}
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);
}
}
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());
}
}
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) {

}
}
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
36 changes: 17 additions & 19 deletions src/main/resources/fabric.mod.json
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"]
}
}
}

0 comments on commit 64e0c3e

Please sign in to comment.