Skip to content

Commit

Permalink
feat: rework Ravenous Claw (3rd revision)
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Jun 16, 2023
1 parent 88217ef commit dde4ba6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void renderOrnateCorner(PoseStack poseStack, int x, int y) {
}

static void renderChargeBar(PoseStack poseStack, int screenWidth, int screenHeight, Font font, int charge, float chargePct) {
int x = screenWidth / 4 * 3 - 25; // 51/2 ~= 25
int x = screenWidth - 51 - 16;
int y = screenHeight - 5 - 16;

RenderSystem.setShaderTexture(0, CHARGE_BAR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class ModDamageSources {
public static final DamageSource CHEST_BITE = createDamage("chest_bite").bypassArmor();

public static final DamageSource CORROSIVE_ACID = createDamage("corrosive_acid");
public static final DamageSource BLEED = createDamage("bleed").bypassArmor().bypassMagic().bypassInvul();
public static final DamageSource BLEED = createDamage("bleed").bypassArmor().bypassMagic().bypassEnchantments();

public static final DamageSource FALL_ON_SPIKE = createDamage("spike_fall_on").bypassArmor().setIsFall();
public static final DamageSource IMPALED_BY_SPIKE = createDamage("spike_impale").bypassArmor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public boolean canBeDepleted() {
return false;
}

@Override
public boolean isFoil(ItemStack stack) {
return false;
}

@Override
public boolean isBarVisible(ItemStack stack) {
return getNutrients(stack) > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,42 +219,47 @@ public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity atta
boolean isFullAttackStrength = !(attacker instanceof Player player) || player.getAttackStrengthScale(0.5f) >= 0.9f;
boolean isNotCreativePlayer = !MobUtil.isCreativePlayer(attacker);

if (isNotCreativePlayer) {
switch (livingToolState) {
case BROKEN -> { /* do nothing */ }
case DORMANT -> consumeNutrients(stack, 1);
case AWAKENED -> consumeCharge(stack, 1);
}
}
switch (livingToolState) {
case BROKEN -> { /* do nothing */ }
case DORMANT -> {
if (isNotCreativePlayer) {
consumeNutrients(stack, 1);
}

if (isFullAttackStrength) {
switch (livingToolState) {
case BROKEN -> { /* do nothing */ }
case DORMANT -> {
if (isFullAttackStrength) {
playBloodyClawsFX(attacker);
if (attacker.getRandom().nextInt(12) == 0) { //8.3%
attacker.level.playSound(null, attacker.getX(), attacker.getY(), attacker.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, attacker.getSoundSource(), 1f, 1.5f);

CombatUtil.applyBleedEffect(target, 20);
}
}
case AWAKENED -> {

if (target.isDeadOrDying()) {
addCharge(stack, 5);
}
}
case AWAKENED -> {
if (isNotCreativePlayer) {
consumeCharge(stack, 1);
}

if (isFullAttackStrength) {
playBloodyClawsFX(attacker);
if (attacker.getRandom().nextInt(5) == 0) { //20%
attacker.level.playSound(null, attacker.getX(), attacker.getY(), attacker.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, attacker.getSoundSource(), 1f, 1.5f);

playBloodExplosionFX(target);
CombatUtil.hurtWithBleed(target, 0.1f * target.getMaxHealth());
if (CombatUtil.getBleedEffectLevel(target) < 2) {
playBloodExplosionFX(target);
CombatUtil.hurtWithBleed(target, 0.1f * target.getMaxHealth());
}

CombatUtil.applyBleedEffect(target, 20);
}
}
}
}

if (target.isDeadOrDying()) {
addCharge(stack, 2);
}

return true;
}

Expand All @@ -267,14 +272,15 @@ public void appendHoverText(ItemStack stack, @Nullable Level level, List<Compone
}
case DORMANT -> {
tooltip.add(ComponentUtil.emptyLine());
tooltip.add(ComponentUtil.literal("On Charged Hit:").withStyle(ChatFormatting.GRAY));
tooltip.add(ComponentUtil.literal(" 8% Bleed Chance").withStyle(ChatFormatting.DARK_GRAY));
tooltip.add(ComponentUtil.literal("Bleed Proc:").withStyle(ChatFormatting.GRAY));
tooltip.add(ComponentUtil.literal(" 8% chance to add one bleed stack (max 2)").withStyle(ChatFormatting.DARK_GRAY));
}
case AWAKENED -> {
tooltip.add(ComponentUtil.emptyLine());
tooltip.add(ComponentUtil.literal("On Charged Hit:").withStyle(ChatFormatting.GRAY));
tooltip.add(ComponentUtil.literal(" 20% Bleed Chance").withStyle(ChatFormatting.DARK_GRAY));
tooltip.add(ComponentUtil.literal(" 20% Blood Explosion Chance (deals 10% of max health as damage)").withStyle(ChatFormatting.DARK_GRAY));
tooltip.add(ComponentUtil.literal("Bleed Proc:").withStyle(ChatFormatting.GRAY));
tooltip.add(ComponentUtil.literal(" 20% chance to add one bleed stack (max 2)").withStyle(ChatFormatting.DARK_GRAY));
tooltip.add(ComponentUtil.literal("Blood Explosion:").withStyle(ChatFormatting.GRAY));
tooltip.add(ComponentUtil.literal(" on bleed proc deals 10% of max health as damage").withStyle(ChatFormatting.DARK_GRAY));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@ public static void hurtWithBleed(LivingEntity livingEntity, float damage) {
public static void applyBleedEffect(LivingEntity livingEntity, int seconds) {
livingEntity.addEffect(new MobEffectInstance(ModMobEffects.BLEED.get(), seconds * 20, 0, false, false, true));
}

public static int getBleedEffectLevel(LivingEntity target) {
MobEffectInstance effectInstance = target.getEffect(ModMobEffects.BLEED.get());
if (effectInstance == null) {
return 0;
}
return effectInstance.getAmplifier() + 1;
}

}

0 comments on commit dde4ba6

Please sign in to comment.