mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 17:02:57 +08:00
Fix #2114 (metaMonster can be null)
This commit is contained in:
parent
55a7c0314d
commit
eda5e8c5e0
@ -34,6 +34,7 @@ import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE;
|
import static emu.grasscutter.scripts.constants.EventType.EVENT_SPECIFIC_MONSTER_HP_CHANGE;
|
||||||
@ -53,7 +54,7 @@ public class EntityMonster extends GameEntity {
|
|||||||
@Getter @Setter private int poseId;
|
@Getter @Setter private int poseId;
|
||||||
@Getter @Setter private int aiId = -1;
|
@Getter @Setter private int aiId = -1;
|
||||||
|
|
||||||
@Getter @Setter private SceneMonster metaMonster;
|
@Nullable @Getter @Setter private SceneMonster metaMonster;
|
||||||
|
|
||||||
public EntityMonster(Scene scene, MonsterData monsterData, Position pos, int level) {
|
public EntityMonster(Scene scene, MonsterData monsterData, Position pos, int level) {
|
||||||
super(scene);
|
super(scene);
|
||||||
@ -206,15 +207,19 @@ public class EntityMonster extends GameEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SceneEntityInfo toProto() {
|
public SceneEntityInfo toProto() {
|
||||||
|
var data = this.getMonsterData();
|
||||||
|
|
||||||
var authority = EntityAuthorityInfo.newBuilder()
|
var authority = EntityAuthorityInfo.newBuilder()
|
||||||
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||||
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||||
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(this.getBornPos().toProto()))
|
.setAiInfo(SceneEntityAiInfo.newBuilder()
|
||||||
|
.setIsAiOpen(true)
|
||||||
|
.setBornPos(this.getBornPos().toProto()))
|
||||||
.setBornPos(this.getBornPos().toProto())
|
.setBornPos(this.getBornPos().toProto())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
var entityInfo = SceneEntityInfo.newBuilder()
|
var entityInfo = SceneEntityInfo.newBuilder()
|
||||||
.setEntityId(getId())
|
.setEntityId(this.getId())
|
||||||
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_MONSTER)
|
.setEntityType(ProtEntityType.PROT_ENTITY_TYPE_MONSTER)
|
||||||
.setMotionInfo(this.getMotionInfo())
|
.setMotionInfo(this.getMotionInfo())
|
||||||
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||||
@ -226,25 +231,27 @@ public class EntityMonster extends GameEntity {
|
|||||||
|
|
||||||
entityInfo.addPropList(PropPair.newBuilder()
|
entityInfo.addPropList(PropPair.newBuilder()
|
||||||
.setType(PlayerProperty.PROP_LEVEL.getId())
|
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||||
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, getLevel()))
|
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, this.getLevel()))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
var monsterInfo = SceneMonsterInfo.newBuilder()
|
var monsterInfo = SceneMonsterInfo.newBuilder()
|
||||||
.setMonsterId(getMonsterId())
|
.setMonsterId(getMonsterId())
|
||||||
.setGroupId(this.getGroupId())
|
.setGroupId(this.getGroupId())
|
||||||
.setConfigId(this.getConfigId())
|
.setConfigId(this.getConfigId())
|
||||||
.addAllAffixList(getMonsterData().getAffix())
|
.addAllAffixList(data.getAffix())
|
||||||
.setAuthorityPeerId(getWorld().getHostPeerId())
|
.setAuthorityPeerId(this.getWorld().getHostPeerId())
|
||||||
.setPoseId(this.getPoseId())
|
.setPoseId(this.getPoseId())
|
||||||
.setBlockId(getScene().getId())
|
.setBlockId(this.getScene().getId())
|
||||||
.setBornType(MonsterBornType.MONSTER_BORN_TYPE_DEFAULT);
|
.setBornType(MonsterBornType.MONSTER_BORN_TYPE_DEFAULT);
|
||||||
if (metaMonster.special_name_id != 0) {
|
|
||||||
monsterInfo.setTitleId(metaMonster.title_id)
|
|
||||||
.setSpecialNameId(metaMonster.special_name_id);
|
|
||||||
} else if (getMonsterData().getDescribeData() != null) {
|
|
||||||
monsterInfo.setTitleId(getMonsterData().getDescribeData().getTitleId())
|
|
||||||
.setSpecialNameId(getMonsterData().getSpecialNameId());
|
|
||||||
|
|
||||||
|
if (this.metaMonster != null) {
|
||||||
|
if (this.metaMonster.special_name_id != 0) {
|
||||||
|
monsterInfo.setTitleId(this.metaMonster.title_id)
|
||||||
|
.setSpecialNameId(this.metaMonster.special_name_id);
|
||||||
|
} else if (data.getDescribeData() != null) {
|
||||||
|
monsterInfo.setTitleId(data.getDescribeData().getTitleId())
|
||||||
|
.setSpecialNameId(data.getSpecialNameId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.getMonsterWeaponId() > 0) {
|
if (this.getMonsterWeaponId() > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user