Skip to content

Commit

Permalink
Merge pull request #273 from ZsoltMolnarrr/rwa-compat
Browse files Browse the repository at this point in the history
Update workspace to 1.20.1, add RWA compat
  • Loading branch information
chronosacaria authored Apr 19, 2024
2 parents bcb6725 + ce1e749 commit a067722
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ dependencies {
// Clumps
modImplementation "com.blamejared.clumps:Clumps-fabric-${project.minecraft_version}:${project.clumps_version}"

// Projectile Damage
modImplementation "maven.modrinth:projectile-damage-attribute:${project.projectile_damage_version}+${project.minecraft_version}-fabric"
// Ranged Weapon API
modImplementation "maven.modrinth:ranged-weapon-api:${project.ranged_weapon_api_version}"

// Cloth Config
modApi("me.shedaniel.cloth:cloth-config-fabric:${project.cloth_config_version}") {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

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

# Mod Properties
Expand All @@ -14,12 +14,12 @@ org.gradle.jvmargs=-Xmx1G

# Dependencies
# check this on https://fabricmc.net/develop/
fabric_version=0.83.0+1.20
fabric_version=0.87.0+1.20.1
cloth_config_version=11.0.99
mixin_extras_version=0.2.0-beta.8

# Compatibility
clumps_version=11.0.0.1
projectile_damage_version=3.2.1
clumps_version=12.0.0.3
ranged_weapon_api_version=1.1.1+1.20.1
reach_entity_attributes_version=2.4.0
#pehkui_version=3.7.8
5 changes: 5 additions & 0 deletions src/main/java/chronosacaria/mcdw/Mcdw.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package chronosacaria.mcdw;

import chronosacaria.mcdw.compat.RangedWeaponAPICompat;
import chronosacaria.mcdw.configs.CompatibilityFlags;
import chronosacaria.mcdw.configs.McdwConfig;
import chronosacaria.mcdw.data.ConfigItemEnabledCondition;
import chronosacaria.mcdw.networking.OffhandAttackPacket;
import chronosacaria.mcdw.registries.*;
import me.shedaniel.autoconfig.AutoConfig;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -39,5 +41,8 @@ public void onInitialize() {
SummonedEntityRegistry.register();
StatusEffectsRegistry.register();
EnchantmentRestrictionsRegistry.register();
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
RangedWeaponAPICompat.init();
}
}
}
35 changes: 35 additions & 0 deletions src/main/java/chronosacaria/mcdw/compat/RangedWeaponAPICompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package chronosacaria.mcdw.compat;

import chronosacaria.mcdw.enums.*;
import net.fabric_extras.ranged_weapon.api.CustomRangedWeapon;
import net.fabric_extras.ranged_weapon.api.RangedConfig;
import net.minecraft.item.Item;

import java.util.HashMap;

public class RangedWeaponAPICompat {
public static void init() {
var items = new HashMap<IRangedWeaponID, Item>();
items.putAll(BowsID.getItemsEnum());
items.putAll(ShortbowsID.getItemsEnum());
items.putAll(LongbowsID.getItemsEnum());
items.putAll(CrossbowsID.getItemsEnum());

for (var entry: items.entrySet()) {
var id = entry.getKey();
if (!id.getIsEnabled()) {
continue;
}
var isCrossbow = id instanceof CrossbowsID;
var item = entry.getValue();
var damage = id.getWeaponItemStats().projectileDamage;
var speed = id.getWeaponItemStats().drawSpeed;
float standardPullTime = isCrossbow ? 25F : 20F;
var pullTime = isCrossbow // Speed seems to have inverse effects on crossbows compared to bows
? speed
: standardPullTime * (20.0 / (float)speed);
var velocity = (id.getWeaponItemStats().range / 15.0f) * 3.0;
((CustomRangedWeapon)item).setRangedWeaponConfig(new RangedConfig((int) pullTime, (float) damage, (float) velocity));
}
}
}
9 changes: 2 additions & 7 deletions src/main/java/chronosacaria/mcdw/enums/BowsID.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
import net.projectile_damage.api.IProjectileWeapon;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
Expand Down Expand Up @@ -64,7 +63,7 @@ public enum BowsID implements IRangedWeaponID, IInnateEnchantment {
BowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.isEnabled = isEnabled;
this.material = material;
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
this.projectileDamage = projectileDamage;
} else {
this.projectileDamage = 0;
Expand Down Expand Up @@ -124,7 +123,7 @@ public ToolMaterial getMaterial() {

@Override
public double getProjectileDamage() {
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
return projectileDamage;
} else {
return 0;
Expand Down Expand Up @@ -188,10 +187,6 @@ public Map<Enchantment, Integer> getInnateEnchantments() {
public McdwBow makeWeapon() {
McdwBow mcdwBow = new McdwBow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
((IProjectileWeapon) mcdwBow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
((IProjectileWeapon) mcdwBow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
}
getItemsEnum().put(this, mcdwBow);
return mcdwBow;
}
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
import net.projectile_damage.api.IProjectileWeapon;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
Expand Down Expand Up @@ -63,7 +62,7 @@ public enum CrossbowsID implements IRangedWeaponID, IInnateEnchantment {
CrossbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.isEnabled = isEnabled;
this.material = material;
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
this.projectileDamage = projectileDamage;
} else {
this.projectileDamage = 0;
Expand Down Expand Up @@ -123,7 +122,7 @@ public ToolMaterial getMaterial() {

@Override
public double getProjectileDamage() {
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
return projectileDamage;
} else {
return 0;
Expand Down Expand Up @@ -186,10 +185,6 @@ public Map<Enchantment, Integer> getInnateEnchantments() {
public McdwCrossbow makeWeapon() {
McdwCrossbow mcdwCrossbow = new McdwCrossbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
((IProjectileWeapon) mcdwCrossbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
((IProjectileWeapon) mcdwCrossbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 8.0f) * 3.15);
}
getItemsEnum().put(this, mcdwCrossbow);
return mcdwCrossbow;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class RangedStats {
public RangedStats rangedStats(boolean isEnabled, String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient) {
this.isEnabled = isEnabled;
this.material = material;
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
this.projectileDamage = projectileDamage;
} else {
this.projectileDamage = 0;
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/chronosacaria/mcdw/enums/LongbowsID.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
import net.projectile_damage.api.IProjectileWeapon;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
Expand All @@ -37,7 +36,7 @@ public enum LongbowsID implements IRangedWeaponID, IInnateEnchantment {
LongbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.isEnabled = isEnabled;
this.material = material;
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
this.projectileDamage = projectileDamage;
} else {
this.projectileDamage = 0;
Expand Down Expand Up @@ -97,7 +96,7 @@ public ToolMaterial getMaterial() {

@Override
public double getProjectileDamage() {
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
return projectileDamage;
} else {
return 0;
Expand Down Expand Up @@ -143,10 +142,6 @@ public Map<Enchantment, Integer> getInnateEnchantments() {
public McdwLongbow makeWeapon() {
McdwLongbow mcdwLongbow = new McdwLongbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
((IProjectileWeapon) mcdwLongbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
((IProjectileWeapon) mcdwLongbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
}
getItemsEnum().put(this, mcdwLongbow);
return mcdwLongbow;
}
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.item.ToolMaterial;
import net.minecraft.item.ToolMaterials;
import net.projectile_damage.api.IProjectileWeapon;
import org.jetbrains.annotations.NotNull;

import java.util.EnumMap;
Expand All @@ -38,7 +37,7 @@ public enum ShortbowsID implements IRangedWeaponID, IInnateEnchantment {
ShortbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) {
this.isEnabled = isEnabled;
this.material = material;
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
this.projectileDamage = projectileDamage;
} else {
this.projectileDamage = 0;
Expand Down Expand Up @@ -97,7 +96,7 @@ public ToolMaterial getMaterial() {

@Override
public double getProjectileDamage() {
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
if (FabricLoader.getInstance().isModLoaded("ranged_weapon_api")) {
return projectileDamage;
} else {
return 0;
Expand Down Expand Up @@ -143,10 +142,6 @@ public Map<Enchantment, Integer> getInnateEnchantments() {
public McdwShortbow makeWeapon() {
McdwShortbow mcdwShortbow = new McdwShortbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material),
this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient);
if (FabricLoader.getInstance().isModLoaded("projectile_damage")) {
((IProjectileWeapon) mcdwShortbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage);
((IProjectileWeapon) mcdwShortbow).setCustomLaunchVelocity((this.getWeaponItemStats().range / 15.0f) * 3.0);
}
getItemsEnum().put(this, mcdwShortbow);
return mcdwShortbow;
}
Expand Down

0 comments on commit a067722

Please sign in to comment.