Commit 30c7bb94 authored by Melledy's avatar Melledy
Browse files

Merge branch 'dev-world-scripts' of https://github.com/Grasscutters/Grasscutter into development

parents 8e6aa50c 5a3e9bc3
...@@ -37,7 +37,7 @@ public class ScriptMonsterTideService { ...@@ -37,7 +37,7 @@ public class ScriptMonsterTideService {
this.sceneScriptManager.getScriptMonsterSpawnService().addMonsterDeadListener(onMonsterDead); this.sceneScriptManager.getScriptMonsterSpawnService().addMonsterDeadListener(onMonsterDead);
// spawn the first turn // spawn the first turn
for (int i = 0; i < this.monsterSceneLimit; i++) { for (int i = 0; i < this.monsterSceneLimit; i++) {
this.sceneScriptManager.getScriptMonsterSpawnService().spawnMonster(group.id, getNextMonster()); sceneScriptManager.addEntity(this.sceneScriptManager.createMonster(group.id, group.block_id, getNextMonster()));
} }
} }
...@@ -73,7 +73,7 @@ public class ScriptMonsterTideService { ...@@ -73,7 +73,7 @@ public class ScriptMonsterTideService {
monsterKillCount.incrementAndGet(); monsterKillCount.incrementAndGet();
if (monsterTideCount.get() > 0) { if (monsterTideCount.get() > 0) {
// add more // add more
sceneScriptManager.getScriptMonsterSpawnService().spawnMonster(currentGroup.id, getNextMonster()); sceneScriptManager.addEntity(sceneScriptManager.createMonster(currentGroup.id, currentGroup.block_id, getNextMonster()));
} }
// spawn the last turn of monsters // spawn the last turn of monsters
// fix the 5-2 // fix the 5-2
......
...@@ -19,6 +19,7 @@ import emu.grasscutter.game.quest.ServerQuestHandler; ...@@ -19,6 +19,7 @@ import emu.grasscutter.game.quest.ServerQuestHandler;
import emu.grasscutter.game.shop.ShopManager; import emu.grasscutter.game.shop.ShopManager;
import emu.grasscutter.game.tower.TowerScheduleManager; import emu.grasscutter.game.tower.TowerScheduleManager;
import emu.grasscutter.game.world.World; import emu.grasscutter.game.world.World;
import emu.grasscutter.game.world.WorldDataManager;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.server.event.types.ServerEvent; import emu.grasscutter.server.event.types.ServerEvent;
...@@ -55,25 +56,15 @@ public final class GameServer extends KcpServer { ...@@ -55,25 +56,15 @@ public final class GameServer extends KcpServer {
private final CommandMap commandMap; private final CommandMap commandMap;
private final TaskMap taskMap; private final TaskMap taskMap;
private final DropManager dropManager; private final DropManager dropManager;
private final WorldDataManager worldDataManager;
private final CombineManger combineManger; private final CombineManger combineManger;
private final TowerScheduleManager towerScheduleManager; private final TowerScheduleManager towerScheduleManager;
private static InetSocketAddress getAdapterInetSocketAddress(){
InetSocketAddress inetSocketAddress;
if(GAME_INFO.bindAddress.equals("")){
inetSocketAddress=new InetSocketAddress(GAME_INFO.bindPort);
}else{
inetSocketAddress=new InetSocketAddress(
GAME_INFO.bindAddress,
GAME_INFO.bindPort
);
}
return inetSocketAddress;
}
public GameServer() { public GameServer() {
this(getAdapterInetSocketAddress()); this(getAdapterInetSocketAddress());
} }
public GameServer(InetSocketAddress address) { public GameServer(InetSocketAddress address) {
ChannelConfig channelConfig = new ChannelConfig(); ChannelConfig channelConfig = new ChannelConfig();
channelConfig.nodelay(true,40,2,true); channelConfig.nodelay(true,40,2,true);
...@@ -104,7 +95,7 @@ public final class GameServer extends KcpServer { ...@@ -104,7 +95,7 @@ public final class GameServer extends KcpServer {
this.expeditionManager = new ExpeditionManager(this); this.expeditionManager = new ExpeditionManager(this);
this.combineManger = new CombineManger(this); this.combineManger = new CombineManger(this);
this.towerScheduleManager = new TowerScheduleManager(this); this.towerScheduleManager = new TowerScheduleManager(this);
this.worldDataManager = new WorldDataManager(this);
// Hook into shutdown event. // Hook into shutdown event.
Runtime.getRuntime().addShutdownHook(new Thread(this::onServerShutdown)); Runtime.getRuntime().addShutdownHook(new Thread(this::onServerShutdown));
} }
...@@ -173,11 +164,27 @@ public final class GameServer extends KcpServer { ...@@ -173,11 +164,27 @@ public final class GameServer extends KcpServer {
return towerScheduleManager; return towerScheduleManager;
} }
public WorldDataManager getWorldDataManager() {
return worldDataManager;
}
public TaskMap getTaskMap() { public TaskMap getTaskMap() {
return this.taskMap; return this.taskMap;
} }
private static InetSocketAddress getAdapterInetSocketAddress(){
InetSocketAddress inetSocketAddress;
if(GAME_INFO.bindAddress.equals("")){
inetSocketAddress=new InetSocketAddress(GAME_INFO.bindPort);
}else{
inetSocketAddress=new InetSocketAddress(
GAME_INFO.bindAddress,
GAME_INFO.bindPort
);
}
return inetSocketAddress;
}
public void registerPlayer(Player player) { public void registerPlayer(Player player) {
getPlayers().put(player.getUid(), player); getPlayers().put(player.getUid(), player);
} }
......
...@@ -3,7 +3,6 @@ package emu.grasscutter.server.game; ...@@ -3,7 +3,6 @@ package emu.grasscutter.server.game;
import java.io.File; import java.io.File;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Set; import java.util.Set;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerDebugMode; import emu.grasscutter.Grasscutter.ServerDebugMode;
import emu.grasscutter.game.Account; import emu.grasscutter.game.Account;
...@@ -17,8 +16,9 @@ import emu.grasscutter.utils.FileUtils; ...@@ -17,8 +16,9 @@ import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import static emu.grasscutter.Configuration.*;
import static emu.grasscutter.utils.Language.translate; import static emu.grasscutter.utils.Language.translate;
import static emu.grasscutter.Configuration.*;
public class GameSession implements GameSessionManager.KcpChannel { public class GameSession implements GameSessionManager.KcpChannel {
private final GameServer server; private final GameServer server;
......
...@@ -13,7 +13,7 @@ public class HandlerGadgetInteractReq extends PacketHandler { ...@@ -13,7 +13,7 @@ public class HandlerGadgetInteractReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
GadgetInteractReq req = GadgetInteractReq.parseFrom(payload); GadgetInteractReq req = GadgetInteractReq.parseFrom(payload);
session.getPlayer().interactWith(req.getGadgetEntityId(), req); session.getPlayer().interactWith(req.getGadgetEntityId(), req.getOpType());
} }
} }
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetInvestigationMonsterReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketGetInvestigationMonsterRsp;
@Opcodes(PacketOpcodes.GetInvestigationMonsterReq)
public class HandlerGetInvestigationMonsterReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = GetInvestigationMonsterReqOuterClass.GetInvestigationMonsterReq.parseFrom(payload);
session.send(new PacketGetInvestigationMonsterRsp(req.getCityIdListList()));
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.dungeons.DungeonChallenge; import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChallengeDataNotifyOuterClass.ChallengeDataNotify; import emu.grasscutter.net.proto.ChallengeDataNotifyOuterClass.ChallengeDataNotify;
public class PacketChallengeDataNotify extends BasePacket { public class PacketChallengeDataNotify extends BasePacket {
public PacketChallengeDataNotify(DungeonChallenge challenge, int index, int value) { public PacketChallengeDataNotify(WorldChallenge challenge, int index, int value) {
super(PacketOpcodes.ChallengeDataNotify); super(PacketOpcodes.ChallengeDataNotify);
ChallengeDataNotify proto = ChallengeDataNotify.newBuilder() ChallengeDataNotify proto = ChallengeDataNotify.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.dungeons.DungeonChallenge; import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DungeonChallengeBeginNotifyOuterClass.DungeonChallengeBeginNotify; import emu.grasscutter.net.proto.DungeonChallengeBeginNotifyOuterClass.DungeonChallengeBeginNotify;
public class PacketDungeonChallengeBeginNotify extends BasePacket { public class PacketDungeonChallengeBeginNotify extends BasePacket {
public PacketDungeonChallengeBeginNotify(DungeonChallenge challenge) { public PacketDungeonChallengeBeginNotify(WorldChallenge challenge) {
super(PacketOpcodes.DungeonChallengeBeginNotify, true); super(PacketOpcodes.DungeonChallengeBeginNotify, true);
DungeonChallengeBeginNotify proto = DungeonChallengeBeginNotify.newBuilder() DungeonChallengeBeginNotify proto = DungeonChallengeBeginNotify.newBuilder()
.setChallengeId(challenge.getChallengeId()) .setChallengeId(challenge.getChallengeId())
.setChallengeIndex(challenge.getChallengeIndex()) .setChallengeIndex(challenge.getChallengeIndex())
.setGroupId(challenge.getGroup().id) .setGroupId(challenge.getGroup().id)
.addParamList(challenge.getObjective()) .addAllParamList(challenge.getParamList())
.addParamList(challenge.getTimeLimit())
.build(); .build();
this.setData(proto); this.setData(proto);
} }
} }
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.dungeons.DungeonChallenge; import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DungeonChallengeFinishNotifyOuterClass.DungeonChallengeFinishNotify; import emu.grasscutter.net.proto.DungeonChallengeFinishNotifyOuterClass.DungeonChallengeFinishNotify;
public class PacketDungeonChallengeFinishNotify extends BasePacket { public class PacketDungeonChallengeFinishNotify extends BasePacket {
public PacketDungeonChallengeFinishNotify(DungeonChallenge challenge) { public PacketDungeonChallengeFinishNotify(WorldChallenge challenge) {
super(PacketOpcodes.DungeonChallengeFinishNotify, true); super(PacketOpcodes.DungeonChallengeFinishNotify, true);
DungeonChallengeFinishNotify proto = DungeonChallengeFinishNotify.newBuilder() DungeonChallengeFinishNotify proto = DungeonChallengeFinishNotify.newBuilder()
...@@ -15,7 +15,7 @@ public class PacketDungeonChallengeFinishNotify extends BasePacket { ...@@ -15,7 +15,7 @@ public class PacketDungeonChallengeFinishNotify extends BasePacket {
.setIsSuccess(challenge.isSuccess()) .setIsSuccess(challenge.isSuccess())
.setChallengeRecordType(2) .setChallengeRecordType(2)
.build(); .build();
this.setData(proto); this.setData(proto);
} }
} }
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.dungeons.DungeonChallenge; import emu.grasscutter.game.dungeons.challenge.WorldChallenge;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DungeonSettleNotifyOuterClass.DungeonSettleNotify; import emu.grasscutter.net.proto.DungeonSettleNotifyOuterClass.DungeonSettleNotify;
...@@ -9,7 +9,7 @@ import emu.grasscutter.net.proto.TowerLevelEndNotifyOuterClass.TowerLevelEndNoti ...@@ -9,7 +9,7 @@ import emu.grasscutter.net.proto.TowerLevelEndNotifyOuterClass.TowerLevelEndNoti
public class PacketDungeonSettleNotify extends BasePacket { public class PacketDungeonSettleNotify extends BasePacket {
public PacketDungeonSettleNotify(DungeonChallenge challenge) { public PacketDungeonSettleNotify(WorldChallenge challenge) {
super(PacketOpcodes.DungeonSettleNotify); super(PacketOpcodes.DungeonSettleNotify);
DungeonSettleNotify proto = DungeonSettleNotify.newBuilder() DungeonSettleNotify proto = DungeonSettleNotify.newBuilder()
...@@ -22,10 +22,10 @@ public class PacketDungeonSettleNotify extends BasePacket { ...@@ -22,10 +22,10 @@ public class PacketDungeonSettleNotify extends BasePacket {
this.setData(proto); this.setData(proto);
} }
public PacketDungeonSettleNotify(DungeonChallenge challenge, public PacketDungeonSettleNotify(WorldChallenge challenge,
boolean canJump, boolean canJump,
boolean hasNextLevel, boolean hasNextLevel,
int nextFloorId int nextFloorId
) { ) {
super(PacketOpcodes.DungeonSettleNotify); super(PacketOpcodes.DungeonSettleNotify);
......
...@@ -4,20 +4,27 @@ import emu.grasscutter.game.entity.EntityBaseGadget; ...@@ -4,20 +4,27 @@ import emu.grasscutter.game.entity.EntityBaseGadget;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp; import emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp;
import emu.grasscutter.net.proto.InterOpTypeOuterClass;
import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketGadgetInteractRsp extends BasePacket { public class PacketGadgetInteractRsp extends BasePacket {
public PacketGadgetInteractRsp(EntityBaseGadget gadget, InteractType interact) { public PacketGadgetInteractRsp(EntityBaseGadget gadget, InteractType interact) {
this(gadget, interact, null);
}
public PacketGadgetInteractRsp(EntityBaseGadget gadget, InteractType interact, InterOpTypeOuterClass.InterOpType opType) {
super(PacketOpcodes.GadgetInteractRsp); super(PacketOpcodes.GadgetInteractRsp);
GadgetInteractRsp proto = GadgetInteractRsp.newBuilder() var proto = GadgetInteractRsp.newBuilder()
.setGadgetEntityId(gadget.getId()) .setGadgetEntityId(gadget.getId())
.setInteractType(interact) .setInteractType(interact)
.setGadgetId(gadget.getGadgetId()) .setGadgetId(gadget.getGadgetId());
.build();
if(opType != null){
proto.setOpType(opType);
}
this.setData(proto); this.setData(proto.build());
} }
public PacketGadgetInteractRsp() { public PacketGadgetInteractRsp() {
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetActivityInfoRspOuterClass;
import java.util.List;
public class PacketGetInvestigationMonsterRsp extends BasePacket {
public PacketGetInvestigationMonsterRsp(List<Integer> cityIdListList) {
super(PacketOpcodes.GetInvestigationMonsterRsp);
var resp = GetActivityInfoRspOuterClass.GetActivityInfoRsp.newBuilder();
this.setData(resp.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityNPC;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GroupSuiteNotifyOuterClass;
import java.util.List;
public class PacketGroupSuiteNotify extends BasePacket {
/**
* control which npc suite is loaded
*/
public PacketGroupSuiteNotify(List<EntityNPC> list) {
super(PacketOpcodes.GroupSuiteNotify);
var proto = GroupSuiteNotifyOuterClass.GroupSuiteNotify.newBuilder();
list.forEach(item -> proto.putGroupMap(item.getGroupId(), item.getSuiteId()));
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.entity.GameEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.props.LifeState; import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify; import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify;
import emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType; import emu.grasscutter.net.proto.PlayerDieTypeOuterClass.PlayerDieType;
import emu.grasscutter.net.proto.ServerBuffOuterClass.ServerBuff;
import java.util.ArrayList;
public class PacketLifeStateChangeNotify extends BasePacket { public class PacketLifeStateChangeNotify extends BasePacket {
public PacketLifeStateChangeNotify(GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
.setEntityId(target.getId())
.setLifeState(lifeState.getValue())
.build();
this.setData(proto);
}
public PacketLifeStateChangeNotify(GameEntity attacker, GameEntity target, LifeState lifeState) { public PacketLifeStateChangeNotify(GameEntity attacker, GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify); super(PacketOpcodes.LifeStateChangeNotify);
......
...@@ -36,7 +36,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket { ...@@ -36,7 +36,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket {
this(player.getTeamManager().getCurrentAvatarEntity()); this(player.getTeamManager().getCurrentAvatarEntity());
} }
public PacketSceneEntityAppearNotify(Collection<GameEntity> entities, VisionType visionType) { public PacketSceneEntityAppearNotify(Collection<? extends GameEntity> entities, VisionType visionType) {
super(PacketOpcodes.SceneEntityAppearNotify, true); super(PacketOpcodes.SceneEntityAppearNotify, true);
SceneEntityAppearNotify.Builder proto = SceneEntityAppearNotify.newBuilder() SceneEntityAppearNotify.Builder proto = SceneEntityAppearNotify.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.game.entity.gadget.GadgetWorktop;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.WorktopOptionNotifyOuterClass.WorktopOptionNotify; import emu.grasscutter.net.proto.WorktopOptionNotifyOuterClass.WorktopOptionNotify;
...@@ -13,8 +14,8 @@ public class PacketWorktopOptionNotify extends BasePacket { ...@@ -13,8 +14,8 @@ public class PacketWorktopOptionNotify extends BasePacket {
WorktopOptionNotify.Builder proto = WorktopOptionNotify.newBuilder() WorktopOptionNotify.Builder proto = WorktopOptionNotify.newBuilder()
.setGadgetEntityId(gadget.getId()); .setGadgetEntityId(gadget.getId());
if (gadget.getWorktopOptions() != null) { if (gadget.getContent() instanceof GadgetWorktop worktop) {
proto.addAllOptionList(gadget.getWorktopOptions()); proto.addAllOptionList(worktop.getWorktopOptions());
} }
this.setData(proto); this.setData(proto);
......
...@@ -137,6 +137,9 @@ public class ConfigContainer { ...@@ -137,6 +137,9 @@ public class ConfigContainer {
public int bindPort = 22102; public int bindPort = 22102;
/* This is the port used in the default region. */ /* This is the port used in the default region. */
public int accessPort = 0; public int accessPort = 0;
/* Entities within a certain range will be loaded for the player */
public int loadEntitiesForPlayerRange = 100;
public boolean enableScriptInBigWorld = false;
public boolean enableConsole = true; public boolean enableConsole = true;
public GameOptions gameOptions = new GameOptions(); public GameOptions gameOptions = new GameOptions();
public JoinOptions joinOptions = new JoinOptions(); public JoinOptions joinOptions = new JoinOptions();
......
...@@ -9,6 +9,7 @@ import java.net.URI; ...@@ -9,6 +9,7 @@ import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.*; import java.nio.file.*;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -103,7 +104,7 @@ public final class FileUtils { ...@@ -103,7 +104,7 @@ public final class FileUtils {
result = Arrays.stream(f.listFiles()).map(File::toPath).toList(); result = Arrays.stream(f.listFiles()).map(File::toPath).toList();
} }
return result; return result;
} }
......
...@@ -3,7 +3,7 @@ package emu.grasscutter.utils; ...@@ -3,7 +3,7 @@ package emu.grasscutter.utils;
import java.io.Serializable; import java.io.Serializable;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import com.github.davidmoten.rtreemulti.geometry.Point;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
import emu.grasscutter.net.proto.VectorOuterClass.Vector; import emu.grasscutter.net.proto.VectorOuterClass.Vector;
...@@ -162,4 +162,20 @@ public class Position implements Serializable { ...@@ -162,4 +162,20 @@ public class Position implements Serializable {
.setZ(this.getZ()) .setZ(this.getZ())
.build(); .build();
} }
public Point toPoint(){
return Point.create(x,y,z);
}
/**
* To XYZ array for Spatial Index
*/
public double[] toDoubleArray(){
return new double[]{ x, y, z};
}
/**
* To XZ array for Spatial Index (Blocks)
*/
public double[] toXZDoubleArray(){
return new double[]{x, z};
}
} }
[
{
"objNames" : [
"SceneObj_Chest_Default_Lv1",
"SceneObj_Chest_Locked_Lv1",
"SceneObj_Chest_Bramble_Lv1",
"SceneObj_Chest_Frozen_Lv1",
"SceneObj_Chest_Rock_Lv1",
"SceneObj_EssenceChest_Default_Lv1",
"SceneObj_EssenceChest_Locked_Lv1"
],
"advExp" : 10,
"resin" : 0,
"mora" : 257,
"sigil" : 1,
"content" : [
{
"itemId" : 104011,
"count": 3
},
{
"itemId" : 104001,
"count": 1
}
],
"randomCount": 4,
"randomContent": [
{
"itemId" : 11101,
"count": 1
},
{
"itemId" : 11201,
"count": 1
},
{
"itemId" : 12101,
"count": 1
},
{
"itemId" : 12201,
"count": 1
},
{
"itemId" : 13101,
"count": 1
},
{
"itemId" : 13201,
"count": 1
},
{
"itemId" : 14101,
"count": 1
},
{
"itemId" : 14201,
"count": 1
},
{
"itemId" : 15101,
"count": 1
},
{
"itemId" : 15201,
"count": 1
}
]
},
{
"objNames" : [
"SceneObj_Chest_Default_Lv2",
"SceneObj_Chest_Locked_Lv2",
"SceneObj_Chest_Bramble_Lv2",
"SceneObj_Chest_Frozen_Lv2"
],
"advExp" : 20,
"resin" : 2,
"mora" : 756,
"sigil" : 2,
"content" : [
{
"itemId" : 104012,
"count": 3
},
{
"itemId" : 104002,
"count": 1
}
],
"randomCount": 4,
"randomContent": [
{
"itemId" : 11201,
"count": 1
},
{
"itemId" : 11301,
"count": 1
},
{
"itemId" : 12201,
"count": 1
},
{
"itemId" : 12301,
"count": 1
},
{
"itemId" : 13201,
"count": 1
},
{
"itemId" : 13301,
"count": 1
},
{
"itemId" : 14201,
"count": 1
},
{
"itemId" : 14301,
"count": 1
},
{
"itemId" : 15201,
"count": 1
},
{
"itemId" : 15301,
"count": 1
}
]
}
]
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment