Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ public InteractionResultHolder<ItemStack> use(Level level, Player player, Intera
* 获取属性的最终值(包含所有修饰符)
*/
private double getFinalAttributeValue(Player player, Holder<Attribute> attribute) {
if (player.getAttribute(attribute) != null) {
return player.getAttribute(attribute).getValue();
}
return 0.0;
return player.getAttributeValue(attribute);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/altnoir/mia/core/event/EventHandle.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public static void addGameEventBus(IEventBus gameEventBus) {
gameEventBus.addListener(MiaEvents::onLivingDeath);
gameEventBus.addListener(MiaEvents::onFinalizeSpawn);
gameEventBus.addListener(MiaEvents::onLivingDrops);
//gameEventBus.addListener(MiaEvents::onLivingDamagePost);
gameEventBus.addListener(MiaEvents::onLivingDamagePre);
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package com.altnoir.mia.core.event.common;

import com.altnoir.mia.init.MiaAttributes;
import net.minecraft.network.chat.Component;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

public class CriticalDamageEvent {
public static float onLivingCriticalDamage(LivingEntity entity, DamageSource source, float damage) {
double critChance = entity.getAttribute(MiaAttributes.CRITICAL_HIT).getValue();
double critDamage = entity.getAttribute(MiaAttributes.CRITICAL_HIT_DAMAGE).getValue();

if (source.getEntity() instanceof Player player) {
player.sendSystemMessage(Component.literal(critChance * 100 + "% 暴击率, 暴击伤害: " + critDamage));
}
var chance = player.getAttributeValue(MiaAttributes.CRITICAL_HIT);
var baseDamage = player.getAttributeValue(MiaAttributes.CRITICAL_HIT_DAMAGE);

if (critChance > 0 && entity.getRandom().nextDouble() < critChance) {
return damage * (float) (critDamage + Math.max(0, critChance - 1.0));
if (chance > 0 && entity.getRandom().nextDouble() < chance) {
return damage * (float) (baseDamage + Math.max(0, chance - 1.0));
}
}
return damage;
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/com/altnoir/mia/init/MiaEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,4 @@ public static void onLivingDamagePre(LivingDamageEvent.Pre event) {
float damage = CriticalDamageEvent.onLivingCriticalDamage(event.getEntity(), event.getSource(), event.getOriginalDamage());
event.setNewDamage(damage);
}

public static void onLivingDamagePost(LivingDamageEvent.Post event) {
if (event.getSource().getEntity() instanceof Player player) {
player.sendSystemMessage(Component.literal(event.getNewDamage() + "点伤害"));
}
}
}
39 changes: 0 additions & 39 deletions src/main/java/com/altnoir/mia/mixin/MobMixin.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/mia.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"ItemEntityMixin",
"LivingEntityMixin",
"MinecraftMixin",
"MobMixin",
"NoiseBasedChunkGeneratorMixin"
],
"client": [
Expand Down
Loading