mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-22 20:04:56 +01:00
Fix the bug that can't kill command-generated monsters
Command-generated monsters do not have spawnentry so we have to get data from getMonsterData
This commit is contained in:
@@ -5,6 +5,7 @@ import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.def.CodexAnimalData;
|
||||
import emu.grasscutter.data.def.CodexReliquaryData;
|
||||
import emu.grasscutter.game.entity.EntityMonster;
|
||||
import emu.grasscutter.game.entity.GameEntity;
|
||||
import emu.grasscutter.game.inventory.GameItem;
|
||||
import emu.grasscutter.game.inventory.ItemType;
|
||||
@@ -79,22 +80,21 @@ public class PlayerCodex {
|
||||
}
|
||||
|
||||
public void checkAnimal(GameEntity target, CodexAnimalData.CodexAnimalUnlockCondition condition){
|
||||
if(target.getEntityType() == 2){
|
||||
var monsterId = target.getSpawnEntry().getMonsterId();
|
||||
if(target instanceof EntityMonster){
|
||||
var monsterId = ((EntityMonster)target).getMonsterData().getId();
|
||||
var codexAnimal = GameData.getCodexAnimalDataMap().get(monsterId);
|
||||
|
||||
if(!getUnlockedAnimal().containsKey(monsterId)) {
|
||||
if (codexAnimal != null) {
|
||||
if(codexAnimal.getUnlockCondition() == condition){
|
||||
if(codexAnimal.getUnlockCondition() == condition || codexAnimal.getUnlockCondition() == null){
|
||||
getUnlockedAnimal().put(monsterId, 1);
|
||||
player.save();
|
||||
this.player.sendPacket(new PacketCodexDataUpdateNotify(3, monsterId));
|
||||
}
|
||||
}
|
||||
}else{
|
||||
getUnlockedAnimal().put(monsterId, getUnlockedAnimal().get(monsterId) + 1);
|
||||
player.save();
|
||||
}
|
||||
player.save();
|
||||
this.player.sendPacket(new PacketCodexDataUpdateNotify(3, monsterId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user