Skip to content

Commit

Permalink
Reflection Enchantment changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Insane96 committed Sep 24, 2022
1 parent 9f4d90e commit 4ab6755
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
* No longer compatible with Reflection
* Max level increased (~~4~~ -> 5)
* Damage blocked increased (~~0.5 per level~~ -> 0.5 per level + 0.5)
* Reflection Enchantment changes
* No longer compatible with Reinforced
* Max level increased (~~3~~ -> 4)
* Damage reflected reduced (~~15%~~ -> 12.5% per level)

## 1.2.4
* Fixed possible crash with Ablaze
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ else if (event.getEntityLiving().getUseItem().getItem() instanceof SPShieldItem)
else
return;
float blockedDamage = (float) (baseBlockedDamage + ShieldReinforcedEnchantment.getDamageBlocked(event.getEntityLiving().getUseItem()));
blockedDamage -= baseBlockedDamage * ShieldReflectionEnchantment.getBlockedDamageReduction(event.getEntityLiving().getUseItem());
event.setBlockedDamage(blockedDamage);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,10 @@ public static void addDamageBlockedText(ItemStack itemStack, List<Component> com
float finalBlockedDamage = (float) (blockedDamage + ShieldReinforcedEnchantment.getDamageBlocked(reinforced));
int reflection = EnchantmentHelper.getItemEnchantmentLevel(SPEnchantments.REFLECTION.get(), itemStack);
float reflectedDamage = ShieldReflectionEnchantment.getReflectedDamage(reflection);
float blockedDamageReduction = (float) (ShieldReflectionEnchantment.getBlockedDamageReduction(reflection) * blockedDamage);
finalBlockedDamage -= blockedDamageReduction;
components.add(new TranslatableComponent(Strings.Translatable.DAMAGE_BLOCKED, new DecimalFormat("#.#").format(finalBlockedDamage)).withStyle(ChatFormatting.BLUE));
if (reinforced > 0) {
components.add(new TranslatableComponent(Strings.Translatable.REINFORCED_BONUS, new DecimalFormat("#.#").format(ShieldReinforcedEnchantment.getDamageBlocked(reinforced))).withStyle(ChatFormatting.DARK_GRAY));
}
if (reflection > 0) {
components.add(new TranslatableComponent(Strings.Translatable.REFLECTION_MALUS, new DecimalFormat("#.#").format(blockedDamageReduction)).withStyle(ChatFormatting.DARK_GRAY));
}
//Add here more blocking damage modifiers

if (reflection > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,32 @@
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentCategory;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.jetbrains.annotations.NotNull;

public class ShieldReflectionEnchantment extends Enchantment {

public static final float REFLECTED_DAMAGE = 0.15f;
public static final float REFLECTED_DAMAGE = 0.125f;
public static final float CAPPED_REFLECTED_DAMAGE = 2f;
public static final float BLOCKED_DAMAGE_REDUCTION = 0.1f;

public ShieldReflectionEnchantment() {
super(Rarity.RARE, EnchantmentCategory.BREAKABLE, new EquipmentSlot[]{EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND});
}

public int getMinCost(int p_44598_) {
return 9 + (p_44598_ - 1) * 14;
return 8 + (p_44598_ - 1) * 10;
}

public int getMaxCost(int p_44600_) {
return this.getMinCost(p_44600_) + 14;
}

public int getMaxLevel() {
return 3;
return 4;
}

@Override
public boolean checkCompatibility(@NotNull Enchantment enchantment) {
return !(enchantment instanceof ShieldReinforcedEnchantment) && super.checkCompatibility(enchantment);
}

@Override
Expand All @@ -53,14 +58,6 @@ public static float getCappedReflectedDamage(ItemStack stack) {
return getReflectedDamage(EnchantmentHelper.getItemEnchantmentLevel(SPEnchantments.REINFORCED.get(), stack));
}

public static float getBlockedDamageReduction(int level) {
return level * BLOCKED_DAMAGE_REDUCTION;
}

public static float getBlockedDamageReduction(ItemStack stack) {
return getBlockedDamageReduction(EnchantmentHelper.getItemEnchantmentLevel(SPEnchantments.REINFORCED.get(), stack));
}

public static void onBlocked(LivingEntity blockingEntity, DamageSource source, float amount) {
if (!(source.getEntity() instanceof LivingEntity sourceEntity && source.getEntity() == source.getDirectEntity()))
return;
Expand Down

0 comments on commit 4ab6755

Please sign in to comment.