mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 09:02:59 +08:00
Make sure the hit target is actually a monster.
This commit is contained in:
parent
febdb99855
commit
635e342a3d
@ -45,6 +45,8 @@ import com.google.protobuf.InvalidProtocolBufferException;
|
|||||||
|
|
||||||
public class EnergyManager {
|
public class EnergyManager {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
private final Map<EntityAvatar, Integer> avatarNormalProbabilities;
|
||||||
|
|
||||||
private final static Int2ObjectMap<List<EnergyDropInfo>> energyDropData = new Int2ObjectOpenHashMap<>();
|
private final static Int2ObjectMap<List<EnergyDropInfo>> energyDropData = new Int2ObjectOpenHashMap<>();
|
||||||
private final static Int2ObjectMap<List<SkillParticleGenerationInfo>> skillParticleGenerationData = new Int2ObjectOpenHashMap<>();
|
private final static Int2ObjectMap<List<SkillParticleGenerationInfo>> skillParticleGenerationData = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
@ -257,8 +259,6 @@ public class EnergyManager {
|
|||||||
entry("WEAPON_CATALYST", 10)
|
entry("WEAPON_CATALYST", 10)
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Map<EntityAvatar, Integer> avatarNormalProbabilities;
|
|
||||||
|
|
||||||
private void generateEnergyForNormalAndCharged(EntityAvatar avatar) {
|
private void generateEnergyForNormalAndCharged(EntityAvatar avatar) {
|
||||||
// This logic is based on the descriptions given in
|
// This logic is based on the descriptions given in
|
||||||
// https://genshin-impact.fandom.com/wiki/Energy#Energy_Generated_by_Normal_Attacks
|
// https://genshin-impact.fandom.com/wiki/Energy#Energy_Generated_by_Normal_Attacks
|
||||||
@ -304,6 +304,18 @@ public class EnergyManager {
|
|||||||
if (attackerEntity.isEmpty() || this.player.getTeamManager().getCurrentAvatarEntity().getId() != attackerEntity.get().getId()) {
|
if (attackerEntity.isEmpty() || this.player.getTeamManager().getCurrentAvatarEntity().getId() != attackerEntity.get().getId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure the target is an actual enemy.
|
||||||
|
GameEntity targetEntity = this.player.getScene().getEntityById(attackRes.getDefenseId());
|
||||||
|
if (!(targetEntity instanceof EntityMonster)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityMonster targetMonster = (EntityMonster)targetEntity;
|
||||||
|
String targetType = targetMonster.getMonsterData().getType();
|
||||||
|
if (!targetType.equals("MONSTER_ORDINARY") && !targetType.equals("MONSTER_BOSS")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the ability that caused this hit.
|
// Get the ability that caused this hit.
|
||||||
AbilityIdentifier ability = attackRes.getAbilityIdentifier();
|
AbilityIdentifier ability = attackRes.getAbilityIdentifier();
|
||||||
|
Loading…
Reference in New Issue
Block a user