diff --git a/src/generated/main/java/emu/grasscutter/net/proto/HomeTransferReqOuterClass.java b/src/generated/main/java/emu/grasscutter/net/proto/HomeTransferReqOuterClass.java
index cd89b2939..6f2bfac37 100644
--- a/src/generated/main/java/emu/grasscutter/net/proto/HomeTransferReqOuterClass.java
+++ b/src/generated/main/java/emu/grasscutter/net/proto/HomeTransferReqOuterClass.java
@@ -25,10 +25,10 @@ public final class HomeTransferReqOuterClass {
int getGuid();
/**
- * bool JFEOCNJLCLG = 5;
- * @return The jFEOCNJLCLG.
+ * bool is_transfer_to_main_house_point = 5;
+ * @return The isTransferToMainHousePoint.
*/
- boolean getJFEOCNJLCLG();
+ boolean getIsTransferToMainHousePoint();
/**
* bool is_transfer_to_safe_point = 3;
@@ -93,7 +93,7 @@ public final class HomeTransferReqOuterClass {
}
case 40: {
- jFEOCNJLCLG_ = input.readBool();
+ isTransferToMainHousePoint_ = input.readBool();
break;
}
case 96: {
@@ -144,15 +144,15 @@ public final class HomeTransferReqOuterClass {
return guid_;
}
- public static final int JFEOCNJLCLG_FIELD_NUMBER = 5;
- private boolean jFEOCNJLCLG_;
+ public static final int IS_TRANSFER_TO_MAIN_HOUSE_POINT_FIELD_NUMBER = 5;
+ private boolean isTransferToMainHousePoint_;
/**
- * bool JFEOCNJLCLG = 5;
- * @return The jFEOCNJLCLG.
+ * bool is_transfer_to_main_house_point = 5;
+ * @return The isTransferToMainHousePoint.
*/
@java.lang.Override
- public boolean getJFEOCNJLCLG() {
- return jFEOCNJLCLG_;
+ public boolean getIsTransferToMainHousePoint() {
+ return isTransferToMainHousePoint_;
}
public static final int IS_TRANSFER_TO_SAFE_POINT_FIELD_NUMBER = 3;
@@ -183,8 +183,8 @@ public final class HomeTransferReqOuterClass {
if (isTransferToSafePoint_ != false) {
output.writeBool(3, isTransferToSafePoint_);
}
- if (jFEOCNJLCLG_ != false) {
- output.writeBool(5, jFEOCNJLCLG_);
+ if (isTransferToMainHousePoint_ != false) {
+ output.writeBool(5, isTransferToMainHousePoint_);
}
if (guid_ != 0) {
output.writeUInt32(12, guid_);
@@ -202,9 +202,9 @@ public final class HomeTransferReqOuterClass {
size += com.google.protobuf.CodedOutputStream
.computeBoolSize(3, isTransferToSafePoint_);
}
- if (jFEOCNJLCLG_ != false) {
+ if (isTransferToMainHousePoint_ != false) {
size += com.google.protobuf.CodedOutputStream
- .computeBoolSize(5, jFEOCNJLCLG_);
+ .computeBoolSize(5, isTransferToMainHousePoint_);
}
if (guid_ != 0) {
size += com.google.protobuf.CodedOutputStream
@@ -227,8 +227,8 @@ public final class HomeTransferReqOuterClass {
if (getGuid()
!= other.getGuid()) return false;
- if (getJFEOCNJLCLG()
- != other.getJFEOCNJLCLG()) return false;
+ if (getIsTransferToMainHousePoint()
+ != other.getIsTransferToMainHousePoint()) return false;
if (getIsTransferToSafePoint()
!= other.getIsTransferToSafePoint()) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
@@ -244,9 +244,9 @@ public final class HomeTransferReqOuterClass {
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + GUID_FIELD_NUMBER;
hash = (53 * hash) + getGuid();
- hash = (37 * hash) + JFEOCNJLCLG_FIELD_NUMBER;
+ hash = (37 * hash) + IS_TRANSFER_TO_MAIN_HOUSE_POINT_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
- getJFEOCNJLCLG());
+ getIsTransferToMainHousePoint());
hash = (37 * hash) + IS_TRANSFER_TO_SAFE_POINT_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(
getIsTransferToSafePoint());
@@ -390,7 +390,7 @@ public final class HomeTransferReqOuterClass {
super.clear();
guid_ = 0;
- jFEOCNJLCLG_ = false;
+ isTransferToMainHousePoint_ = false;
isTransferToSafePoint_ = false;
@@ -421,7 +421,7 @@ public final class HomeTransferReqOuterClass {
public emu.grasscutter.net.proto.HomeTransferReqOuterClass.HomeTransferReq buildPartial() {
emu.grasscutter.net.proto.HomeTransferReqOuterClass.HomeTransferReq result = new emu.grasscutter.net.proto.HomeTransferReqOuterClass.HomeTransferReq(this);
result.guid_ = guid_;
- result.jFEOCNJLCLG_ = jFEOCNJLCLG_;
+ result.isTransferToMainHousePoint_ = isTransferToMainHousePoint_;
result.isTransferToSafePoint_ = isTransferToSafePoint_;
onBuilt();
return result;
@@ -474,8 +474,8 @@ public final class HomeTransferReqOuterClass {
if (other.getGuid() != 0) {
setGuid(other.getGuid());
}
- if (other.getJFEOCNJLCLG() != false) {
- setJFEOCNJLCLG(other.getJFEOCNJLCLG());
+ if (other.getIsTransferToMainHousePoint() != false) {
+ setIsTransferToMainHousePoint(other.getIsTransferToMainHousePoint());
}
if (other.getIsTransferToSafePoint() != false) {
setIsTransferToSafePoint(other.getIsTransferToSafePoint());
@@ -540,33 +540,33 @@ public final class HomeTransferReqOuterClass {
return this;
}
- private boolean jFEOCNJLCLG_ ;
+ private boolean isTransferToMainHousePoint_ ;
/**
- * bool JFEOCNJLCLG = 5;
- * @return The jFEOCNJLCLG.
+ * bool is_transfer_to_main_house_point = 5;
+ * @return The isTransferToMainHousePoint.
*/
@java.lang.Override
- public boolean getJFEOCNJLCLG() {
- return jFEOCNJLCLG_;
+ public boolean getIsTransferToMainHousePoint() {
+ return isTransferToMainHousePoint_;
}
/**
- * bool JFEOCNJLCLG = 5;
- * @param value The jFEOCNJLCLG to set.
+ * bool is_transfer_to_main_house_point = 5;
+ * @param value The isTransferToMainHousePoint to set.
* @return This builder for chaining.
*/
- public Builder setJFEOCNJLCLG(boolean value) {
+ public Builder setIsTransferToMainHousePoint(boolean value) {
- jFEOCNJLCLG_ = value;
+ isTransferToMainHousePoint_ = value;
onChanged();
return this;
}
/**
- * bool JFEOCNJLCLG = 5;
+ * bool is_transfer_to_main_house_point = 5;
* @return This builder for chaining.
*/
- public Builder clearJFEOCNJLCLG() {
+ public Builder clearIsTransferToMainHousePoint() {
- jFEOCNJLCLG_ = false;
+ isTransferToMainHousePoint_ = false;
onChanged();
return this;
}
@@ -668,10 +668,11 @@ public final class HomeTransferReqOuterClass {
descriptor;
static {
java.lang.String[] descriptorData = {
- "\n\025HomeTransferReq.proto\"W\n\017HomeTransferR" +
- "eq\022\014\n\004guid\030\014 \001(\r\022\023\n\013JFEOCNJLCLG\030\005 \001(\010\022!\n" +
- "\031is_transfer_to_safe_point\030\003 \001(\010B\033\n\031emu." +
- "grasscutter.net.protob\006proto3"
+ "\n\025HomeTransferReq.proto\"k\n\017HomeTransferR" +
+ "eq\022\014\n\004guid\030\014 \001(\r\022\'\n\037is_transfer_to_main_" +
+ "house_point\030\005 \001(\010\022!\n\031is_transfer_to_safe" +
+ "_point\030\003 \001(\010B\033\n\031emu.grasscutter.net.prot" +
+ "ob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@@ -682,7 +683,7 @@ public final class HomeTransferReqOuterClass {
internal_static_HomeTransferReq_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_HomeTransferReq_descriptor,
- new java.lang.String[] { "Guid", "JFEOCNJLCLG", "IsTransferToSafePoint", });
+ new java.lang.String[] { "Guid", "IsTransferToMainHousePoint", "IsTransferToSafePoint", });
}
// @@protoc_insertion_point(outer_class_scope)
diff --git a/src/generated/main/java/emu/grasscutter/net/proto/TryEnterHomeReqOuterClass.java b/src/generated/main/java/emu/grasscutter/net/proto/TryEnterHomeReqOuterClass.java
index d96715b26..574c3360c 100644
--- a/src/generated/main/java/emu/grasscutter/net/proto/TryEnterHomeReqOuterClass.java
+++ b/src/generated/main/java/emu/grasscutter/net/proto/TryEnterHomeReqOuterClass.java
@@ -37,10 +37,10 @@ public final class TryEnterHomeReqOuterClass {
int getTargetPoint();
/**
- * bool JFEOCNJLCLG = 12;
- * @return The jFEOCNJLCLG.
+ * bool is_transfer_to_main_house_point = 12;
+ * @return The isTransferToMainHousePoint.
*/
- boolean getJFEOCNJLCLG();
+ boolean getIsTransferToMainHousePoint();
}
/**
*
@@ -109,7 +109,7 @@ public final class TryEnterHomeReqOuterClass { } case 96: { - jFEOCNJLCLG_ = input.readBool(); + isTransferToMainHousePoint_ = input.readBool(); break; } default: { @@ -177,15 +177,15 @@ public final class TryEnterHomeReqOuterClass { return targetPoint_; } - public static final int JFEOCNJLCLG_FIELD_NUMBER = 12; - private boolean jFEOCNJLCLG_; + public static final int IS_TRANSFER_TO_MAIN_HOUSE_POINT_FIELD_NUMBER = 12; + private boolean isTransferToMainHousePoint_; /** - *bool JFEOCNJLCLG = 12;
- * @return The jFEOCNJLCLG. + *bool is_transfer_to_main_house_point = 12;
+ * @return The isTransferToMainHousePoint. */ @java.lang.Override - public boolean getJFEOCNJLCLG() { - return jFEOCNJLCLG_; + public boolean getIsTransferToMainHousePoint() { + return isTransferToMainHousePoint_; } private byte memoizedIsInitialized = -1; @@ -211,8 +211,8 @@ public final class TryEnterHomeReqOuterClass { if (isTransferToSafePoint_ != false) { output.writeBool(9, isTransferToSafePoint_); } - if (jFEOCNJLCLG_ != false) { - output.writeBool(12, jFEOCNJLCLG_); + if (isTransferToMainHousePoint_ != false) { + output.writeBool(12, isTransferToMainHousePoint_); } unknownFields.writeTo(output); } @@ -235,9 +235,9 @@ public final class TryEnterHomeReqOuterClass { size += com.google.protobuf.CodedOutputStream .computeBoolSize(9, isTransferToSafePoint_); } - if (jFEOCNJLCLG_ != false) { + if (isTransferToMainHousePoint_ != false) { size += com.google.protobuf.CodedOutputStream - .computeBoolSize(12, jFEOCNJLCLG_); + .computeBoolSize(12, isTransferToMainHousePoint_); } size += unknownFields.getSerializedSize(); memoizedSize = size; @@ -260,8 +260,8 @@ public final class TryEnterHomeReqOuterClass { != other.getIsTransferToSafePoint()) return false; if (getTargetPoint() != other.getTargetPoint()) return false; - if (getJFEOCNJLCLG() - != other.getJFEOCNJLCLG()) return false; + if (getIsTransferToMainHousePoint() + != other.getIsTransferToMainHousePoint()) return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -280,9 +280,9 @@ public final class TryEnterHomeReqOuterClass { getIsTransferToSafePoint()); hash = (37 * hash) + TARGET_POINT_FIELD_NUMBER; hash = (53 * hash) + getTargetPoint(); - hash = (37 * hash) + JFEOCNJLCLG_FIELD_NUMBER; + hash = (37 * hash) + IS_TRANSFER_TO_MAIN_HOUSE_POINT_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getJFEOCNJLCLG()); + getIsTransferToMainHousePoint()); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -427,7 +427,7 @@ public final class TryEnterHomeReqOuterClass { targetPoint_ = 0; - jFEOCNJLCLG_ = false; + isTransferToMainHousePoint_ = false; return this; } @@ -458,7 +458,7 @@ public final class TryEnterHomeReqOuterClass { result.targetUid_ = targetUid_; result.isTransferToSafePoint_ = isTransferToSafePoint_; result.targetPoint_ = targetPoint_; - result.jFEOCNJLCLG_ = jFEOCNJLCLG_; + result.isTransferToMainHousePoint_ = isTransferToMainHousePoint_; onBuilt(); return result; } @@ -516,8 +516,8 @@ public final class TryEnterHomeReqOuterClass { if (other.getTargetPoint() != 0) { setTargetPoint(other.getTargetPoint()); } - if (other.getJFEOCNJLCLG() != false) { - setJFEOCNJLCLG(other.getJFEOCNJLCLG()); + if (other.getIsTransferToMainHousePoint() != false) { + setIsTransferToMainHousePoint(other.getIsTransferToMainHousePoint()); } this.mergeUnknownFields(other.unknownFields); onChanged(); @@ -641,33 +641,33 @@ public final class TryEnterHomeReqOuterClass { return this; } - private boolean jFEOCNJLCLG_ ; + private boolean isTransferToMainHousePoint_ ; /** - *bool JFEOCNJLCLG = 12;
- * @return The jFEOCNJLCLG. + *bool is_transfer_to_main_house_point = 12;
+ * @return The isTransferToMainHousePoint. */ @java.lang.Override - public boolean getJFEOCNJLCLG() { - return jFEOCNJLCLG_; + public boolean getIsTransferToMainHousePoint() { + return isTransferToMainHousePoint_; } /** - *bool JFEOCNJLCLG = 12;
- * @param value The jFEOCNJLCLG to set. + *bool is_transfer_to_main_house_point = 12;
+ * @param value The isTransferToMainHousePoint to set. * @return This builder for chaining. */ - public Builder setJFEOCNJLCLG(boolean value) { + public Builder setIsTransferToMainHousePoint(boolean value) { - jFEOCNJLCLG_ = value; + isTransferToMainHousePoint_ = value; onChanged(); return this; } /** - *bool JFEOCNJLCLG = 12;
+ *bool is_transfer_to_main_house_point = 12;
* @return This builder for chaining. */ - public Builder clearJFEOCNJLCLG() { + public Builder clearIsTransferToMainHousePoint() { - jFEOCNJLCLG_ = false; + isTransferToMainHousePoint_ = false; onChanged(); return this; } @@ -738,11 +738,11 @@ public final class TryEnterHomeReqOuterClass { descriptor; static { java.lang.String[] descriptorData = { - "\n\025TryEnterHomeReq.proto\"s\n\017TryEnterHomeR" + - "eq\022\022\n\ntarget_uid\030\004 \001(\r\022!\n\031is_transfer_to" + - "_safe_point\030\t \001(\010\022\024\n\014target_point\030\005 \001(\r\022" + - "\023\n\013JFEOCNJLCLG\030\014 \001(\010B\033\n\031emu.grasscutter." + - "net.protob\006proto3" + "\n\025TryEnterHomeReq.proto\"\207\001\n\017TryEnterHome" + + "Req\022\022\n\ntarget_uid\030\004 \001(\r\022!\n\031is_transfer_t" + + "o_safe_point\030\t \001(\010\022\024\n\014target_point\030\005 \001(\r" + + "\022\'\n\037is_transfer_to_main_house_point\030\014 \001(" + + "\010B\033\n\031emu.grasscutter.net.protob\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, @@ -753,7 +753,7 @@ public final class TryEnterHomeReqOuterClass { internal_static_TryEnterHomeReq_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_TryEnterHomeReq_descriptor, - new java.lang.String[] { "TargetUid", "IsTransferToSafePoint", "TargetPoint", "JFEOCNJLCLG", }); + new java.lang.String[] { "TargetUid", "IsTransferToSafePoint", "TargetPoint", "IsTransferToMainHousePoint", }); } // @@protoc_insertion_point(outer_class_scope) diff --git a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java index 96de2ce33..7fc0039c9 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeSceneItem.java @@ -9,9 +9,12 @@ import emu.grasscutter.game.entity.EntityHomeAnimal; import emu.grasscutter.game.world.Position; import emu.grasscutter.game.world.Scene; import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo; + +import javax.annotation.Nullable; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import lombok.*; import lombok.experimental.FieldDefaults; @@ -81,6 +84,21 @@ public class HomeSceneItem { return mainHouse == null || mainHouse.getAsItem() == null; } + @Nullable + public Position getTeleportPointPos(int guid) { + var pos = new AtomicReference(); + + this.getBlockItems().values().stream() + .map(HomeBlockItem::getDeployFurnitureList) + .flatMap(Collection::stream) + .filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid) + .map(HomeFurnitureItem::getSpawnPos) + .findFirst() + .ifPresent(pos::set); + + return pos.get(); + } + public List getAnimals(Scene scene) { return this.blockItems.values().stream() .map(HomeBlockItem::getDeployAnimalList) diff --git a/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java b/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java index f6f31e7b7..8a28595b1 100644 --- a/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java +++ b/src/main/java/emu/grasscutter/game/home/HomeWorldMPSystem.java @@ -2,11 +2,18 @@ package emu.grasscutter.game.home; import emu.grasscutter.game.player.Player; import emu.grasscutter.game.props.EnterReason; -import emu.grasscutter.game.world.*; +import emu.grasscutter.game.world.Position; +import emu.grasscutter.game.world.World; import emu.grasscutter.game.world.data.TeleportProperties; -import emu.grasscutter.net.proto.*; -import emu.grasscutter.server.event.player.*; -import emu.grasscutter.server.game.*; +import emu.grasscutter.net.proto.EnterTypeOuterClass; +import emu.grasscutter.net.proto.OtherPlayerEnterHomeNotifyOuterClass; +import emu.grasscutter.net.proto.PlayerApplyEnterHomeResultNotifyOuterClass; +import emu.grasscutter.net.proto.RetcodeOuterClass; +import emu.grasscutter.server.event.player.PlayerEnterHomeEvent; +import emu.grasscutter.server.event.player.PlayerLeaveHomeEvent; +import emu.grasscutter.server.event.player.PlayerTeleportEvent; +import emu.grasscutter.server.game.BaseGameSystem; +import emu.grasscutter.server.game.GameServer; import emu.grasscutter.server.packet.send.*; public class HomeWorldMPSystem extends BaseGameSystem { @@ -98,10 +105,10 @@ public class HomeWorldMPSystem extends BaseGameSystem { return; } - this.enterHome(requester, owner); + this.enterHome(requester, owner, 0, false); } - public void enterHome(Player requester, Player owner) { + public void enterHome(Player requester, Player owner, int teleportPoint, boolean toSafe) { if (requester.getWorld().isMultiplayer()) { return; } @@ -134,9 +141,16 @@ public class HomeWorldMPSystem extends BaseGameSystem { } int realmId = 2000 + owner.getCurrentRealmId(); - targetHome.getHomeSceneItem(realmId); + var item = targetHome.getHomeSceneItem(realmId); targetHome.save(); - var pos = world.getSceneById(realmId).getScriptManager().getConfig().born_pos; + var pos = toSafe ? world.getSceneById(realmId).getScriptManager().getConfig().born_pos : item.getBornPos(); + + if (teleportPoint != 0) { + var target = item.getTeleportPointPos(teleportPoint); + if (target != null) { + pos = target; + } + } requester.getPrevPosForHome().set(requester.getPosition()); requester.setCurHomeWorld(world); @@ -188,21 +202,12 @@ public class HomeWorldMPSystem extends BaseGameSystem { player.getPosition().set(pos); var world = new World(player); world.addPlayer(player, prevScene); - player - .getCurHomeWorld() - .sendPacketToHostIfOnline( - new PacketOtherPlayerEnterOrLeaveHomeNotify( - player, - OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); - player.setCurHomeWorld(this.server.getHomeWorldOrCreate(player)); + player.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(player, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); + var myHome = this.server.getHomeWorldOrCreate(player); + player.setCurHomeWorld(myHome); + myHome.getHome().onOwnerLogin(player); - player.sendPacket( - new PacketPlayerEnterSceneNotify( - player, - EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, - EnterReason.TeamBack, - prevScene, - pos)); + player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, EnterReason.TeamBack, prevScene, pos)); return true; } @@ -234,13 +239,10 @@ public class HomeWorldMPSystem extends BaseGameSystem { victim.getPosition().set(victim.getPrevPosForHome()); var world = new World(victim); world.addPlayer(victim, 3); - victim - .getCurHomeWorld() - .sendPacketToHostIfOnline( - new PacketOtherPlayerEnterOrLeaveHomeNotify( - victim, - OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); - victim.setCurHomeWorld(this.server.getHomeWorldOrCreate(victim)); + victim.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(victim, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE)); + var myHome = this.server.getHomeWorldOrCreate(victim); + victim.setCurHomeWorld(myHome); + myHome.getHome().onOwnerLogin(victim); victim.sendPacket( new PacketPlayerEnterSceneNotify( diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java index 89ec4952b..3f1394932 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerHomeTransferReq.java @@ -1,11 +1,11 @@ package emu.grasscutter.server.packet.recv; -import com.github.davidmoten.guavamini.Lists; -import emu.grasscutter.game.home.HomeFurnitureItem; -import emu.grasscutter.net.packet.*; +import emu.grasscutter.net.packet.BasePacket; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.proto.HomeTransferReqOuterClass; import emu.grasscutter.server.game.GameSession; -import java.util.List; @Opcodes(PacketOpcodes.HomeTransferReq) public class HandlerHomeTransferReq extends PacketHandler { @@ -16,28 +16,15 @@ public class HandlerHomeTransferReq extends PacketHandler { var home = player.getCurHomeWorld().getHome(); var item = home.getHomeSceneItem(player.getSceneId()); - if (req.getIsTransferToSafePoint()) { - player - .getCurHomeWorld() - .transferPlayerToScene(player, player.getSceneId(), item.getBornPos()); - } else { - for (var homeBlockItem : item.getBlockItems().values()) { - List items = Lists.newArrayList(); - items.addAll(homeBlockItem.getDeployFurnitureList()); - items.addAll(homeBlockItem.getPersistentFurnitureList()); - items.stream() - .filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == req.getGuid()) - .findFirst() - .ifPresent( - homeFurnitureItem -> { - player - .getCurHomeWorld() - .transferPlayerToScene( - player, player.getSceneId(), homeFurnitureItem.getSpawnPos()); - }); + var pos = req.getIsTransferToMainHousePoint() ? item.getBornPos() : player.getCurHomeWorld().getSceneById(player.getSceneId()).getScriptManager().getConfig().born_pos; + if (req.getGuid() != 0) { + var target = item.getTeleportPointPos(req.getGuid()); + if (target != null) { + pos = target; } } + player.getCurHomeWorld().transferPlayerToScene(player, player.getSceneId(), pos); session.send(new BasePacket(PacketOpcodes.HomeTransferRsp)); } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java index 03c38dcf4..15ac73f39 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerTryEnterHomeReq.java @@ -1,8 +1,12 @@ package emu.grasscutter.server.packet.recv; import emu.grasscutter.game.home.GameHome; -import emu.grasscutter.net.packet.*; -import emu.grasscutter.net.proto.*; +import emu.grasscutter.net.packet.Opcodes; +import emu.grasscutter.net.packet.PacketHandler; +import emu.grasscutter.net.packet.PacketOpcodes; +import emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass; +import emu.grasscutter.net.proto.RetcodeOuterClass; +import emu.grasscutter.net.proto.TryEnterHomeReqOuterClass; import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.packet.send.PacketTryEnterHomeRsp; @@ -45,15 +49,16 @@ public class HandlerTryEnterHomeReq extends PacketHandler { RetcodeOuterClass.Retcode.RET_HOME_HOME_REFUSE_GUEST_ENTER_VALUE, req.getTargetUid())); } - case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption - .FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { - session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer); + + case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> { + session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint()); + } } return; } - session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer); + session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint()); } }