Skip to content

Commit

Permalink
Update to 1.20.6 and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ExDrill committed May 4, 2024
1 parent 3791759 commit 3f070ce
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
4 changes: 0 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ version = project.minecraft_version + "-" + project.mod_version
group = project.maven_group

repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
maven {
url = 'https://jitpack.io'
}
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
minecraft_version=1.20.5
loader_version=0.15.10
minecraft_version=1.20.6
loader_version=0.15.11

# Mod Properties
mod_version = 2.6.0
mod_version = 2.6.1
maven_group = com.teamabode
archives_base_name = guarding

# Dependencies
fabric_version=0.97.5+1.20.5
sketch_version=1.20.5-1.0.0
fabric_version=0.97.8+1.20.6
sketch_version=1.20.6-1.1.0
26 changes: 2 additions & 24 deletions src/main/java/com/teamabode/guarding/Guarding.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.teamabode.guarding;

import com.teamabode.guarding.core.init.*;
import com.teamabode.sketch.core.api.config.Config;
import com.teamabode.sketch.core.api.config.ConfigBuilder;
import com.teamabode.sketch.core.api.config.ConfigManager;
import net.fabricmc.api.ModInitializer;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
Expand All @@ -17,28 +16,6 @@ public class Guarding implements ModInitializer {

public static final TagKey<Item> SHIELD_ENCHANTABLE = TagKey.create(Registries.ITEM, id("enchantable/shield"));

public static final Config CONFIG = new ConfigBuilder(MOD_ID)
.addGroup("general", builder -> {
builder.addBooleanProperty("no_shield_block_delay", true);
return builder;
})
.addGroup("parry", builder -> {
builder.addFloatProperty("exhaustion_cost", 2.0f);
builder.addFloatProperty("knockback_strength", 0.5f);
builder.addFloatProperty("projectile_launch_strength", 1.25f);
return builder;
})
.addGroup("barbed", builder -> {
builder.addFloatProperty("damage_amount", 2.0f);
builder.addFloatProperty("damage_chance", 0.2f);
return builder;
})
.addGroup("pummeling", builder -> {
builder.addFloatProperty("additional_knockback_strength_per_level", 0.15f);
return builder;
})
.build();

public void onInitialize() {
GuardingItems.init();
GuardingEnchantments.init();
Expand All @@ -47,6 +24,7 @@ public void onInitialize() {
GuardingCallbacks.init();
GuardingCritieriaTriggers.init();
GuardingRecipeSerializers.init();
ConfigManager.INSTANCE.register(GuardingConfig.INSTANCE);
}

public static ResourceLocation id(String name) {
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/teamabode/guarding/GuardingConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.teamabode.guarding;

import com.teamabode.sketch.core.api.config.Config;
import com.teamabode.sketch.core.api.config.FloatProperty;

public class GuardingConfig extends Config {
public static final GuardingConfig INSTANCE = new GuardingConfig();

public final FloatProperty exhaustionCost;
public final FloatProperty knockbackStrength;
public final FloatProperty projectileReflectStrength;
public final FloatProperty damageAmount;
public final FloatProperty damageChance;
public final FloatProperty additionalKnockbackStrengthPerLevel;

public GuardingConfig() {
super("guarding");
this.exhaustionCost = new FloatProperty("exhaustion_cost", 2.0f);
this.knockbackStrength = new FloatProperty("knockback_strength", 0.5f);
this.projectileReflectStrength = new FloatProperty("projectile_reflect_strength", 1.25f);
this.damageAmount = new FloatProperty("damage_amount", 2.0f);
this.damageChance = new FloatProperty("damage_chance", 0.2f);
this.additionalKnockbackStrengthPerLevel = new FloatProperty("additional_knockback_strength_per_level", 0.15f);

this.defineCategory("parry", this.exhaustionCost, this.knockbackStrength, this.projectileReflectStrength);
this.defineCategory("barbed", this.damageAmount, this.damageChance);
this.defineCategory("pummeling", this.additionalKnockbackStrengthPerLevel);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.teamabode.guarding.core.init;

import com.teamabode.guarding.Guarding;
import com.teamabode.guarding.GuardingConfig;
import com.teamabode.guarding.core.access.ProjectileAccessor;
import com.teamabode.sketch.core.api.event.ShieldEvents;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -38,7 +39,7 @@ private static void onBlocked(Player user, DamageSource source, float amount) {
// Logic for blocking a living entity
private static void blockLivingEntity(Player user, LivingEntity attacker, boolean isParry) {
if (isParry) {
float exhaustion = Guarding.CONFIG.getGroup("parry").getFloatProperty("exhaustion_cost");
float exhaustion = GuardingConfig.INSTANCE.exhaustionCost.get();
float strength = getKnockbackStrength(user.getUseItem());

user.causeFoodExhaustion(exhaustion);
Expand All @@ -51,18 +52,18 @@ private static void blockLivingEntity(Player user, LivingEntity attacker, boolea
// Logic for blocking a projectile
private static void blockProjectile(Player user, Entity damageCauser, Projectile projectile, boolean isParry) {
if (!isParry || damageCauser == null) return;
float projectileLaunchStrength = Guarding.CONFIG.getGroup("parry").getFloatProperty("projectile_launch_strength");
float projectileReflectStrength = GuardingConfig.INSTANCE.projectileReflectStrength.get();
if (projectile instanceof ProjectileAccessor accessor) accessor.setParrier(user);
Vec3 motion = new Vec3(user.getX() - damageCauser.getX(), 0.0f, user.getZ() - damageCauser.getZ()).scale(projectileLaunchStrength);
Vec3 motion = new Vec3(user.getX() - damageCauser.getX(), 0.0f, user.getZ() - damageCauser.getZ()).scale(projectileReflectStrength);
projectile.setDeltaMovement(motion.x(), -1.5f, motion.z());
projectile.hurtMarked = true;
}

// Handles all code for the barbed enchantment
private static void handleBarbed(Player user, LivingEntity attacker, boolean isParry) {
RandomSource random = user.getRandom();
float damage = Guarding.CONFIG.getGroup("barbed").getFloatProperty("damage_amount");
float chance = Guarding.CONFIG.getGroup("barbed").getFloatProperty("damage_chance");
float damage = GuardingConfig.INSTANCE.damageAmount.get();
float chance = GuardingConfig.INSTANCE.damageChance.get();
int barbedLevel = EnchantmentHelper.getItemEnchantmentLevel(GuardingEnchantments.BARBED, user.getUseItem());
if (barbedLevel <= 0) return;
damage += isParry ? 1.0f : 0.0f; // Parrying will cause barbed to increase it's power.
Expand All @@ -75,8 +76,8 @@ private static void handleBarbed(Player user, LivingEntity attacker, boolean isP

// Determines the knockback strength on parry
private static float getKnockbackStrength(ItemStack stack) {
float baseStrength = Guarding.CONFIG.getGroup("parry").getFloatProperty("knockback_strength");
float additionalStrength = Guarding.CONFIG.getGroup("pummeling").getFloatProperty("additional_knockback_strength_per_level");
float baseStrength = GuardingConfig.INSTANCE.knockbackStrength.get();
float additionalStrength = GuardingConfig.INSTANCE.additionalKnockbackStrengthPerLevel.get();
int pummelingLevel = EnchantmentHelper.getItemEnchantmentLevel(GuardingEnchantments.PUMMELING, stack);
float pummelStrength = pummelingLevel > 0 ? pummelingLevel * additionalStrength : 0.0f;

Expand Down

0 comments on commit 3f070ce

Please sign in to comment.