Clean up some Position usage to avoid unneccessary unpacks

This commit is contained in:
AnimeGitB
2022-08-22 17:08:34 +09:30
parent dbf2b91d03
commit 36b71d0198
7 changed files with 23 additions and 47 deletions

View File

@@ -13,7 +13,6 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq;
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
import emu.grasscutter.utils.Position;
import emu.grasscutter.utils.Utils;
public class GadgetGatherObject extends GadgetContent {
@@ -69,11 +68,10 @@ public class GadgetGatherObject extends GadgetContent {
scene,
player,
GameData.getItemDataMap().get(itemId),
new Position(
getGadget().getPosition().getX() + (float)Utils.randomRange(1,5) / 5,
getGadget().getPosition().getY() + 2f,
getGadget().getPosition().getZ() + (float)Utils.randomRange(1,5) / 5
),
getGadget().getPosition().clone()
.addY(2f)
.addX(Utils.randomFloatRange(-1f, 1f))
.addZ(Utils.randomFloatRange(-1f, 1f)),
1,
true);

View File

@@ -11,7 +11,6 @@ import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.GatherGadgetInfoOuterClass.GatherGadgetInfo;
import emu.grasscutter.net.proto.GadgetInteractReqOuterClass.GadgetInteractReq;
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
import emu.grasscutter.utils.Position;
import emu.grasscutter.utils.Utils;
public class GadgetGatherPoint extends GadgetContent {
@@ -61,14 +60,13 @@ public class GadgetGatherPoint extends GadgetContent {
for (int i = 0 ; i < times ; i++) {
EntityItem item = new EntityItem(
scene,
player,
scene,
player,
GameData.getItemDataMap().get(itemId),
new Position(
getGadget().getPosition().getX() + (float)Utils.randomRange(1,5) / 5,
getGadget().getPosition().getY() + 2f,
getGadget().getPosition().getZ() + (float)Utils.randomRange(1,5) / 5
),
getGadget().getPosition().clone()
.addY(2f)
.addX(Utils.randomFloatRange(-1f, 1f))
.addZ(Utils.randomFloatRange(-1f, 1f)),
1,
true);

View File

@@ -25,11 +25,7 @@ public class MapMark {
public MapMark(MapMarkPoint mapMarkPoint) {
this.sceneId = mapMarkPoint.getSceneId();
this.name = mapMarkPoint.getName();
this.position = new Position(
mapMarkPoint.getPos().getX(),
mapMarkPoint.getPos().getY(),
mapMarkPoint.getPos().getZ()
);
this.position = new Position(mapMarkPoint.getPos());
this.mapMarkPointType = mapMarkPoint.getPointType();
this.monsterId = mapMarkPoint.getMonsterId();
this.mapMarkFromType = mapMarkPoint.getFromType();

View File

@@ -497,11 +497,7 @@ public class StaminaManager extends BasePlayerManager {
}
}
previousState = currentState;
previousCoordinates = new Position(
currentCoordinates.getX(),
currentCoordinates.getY(),
currentCoordinates.getZ()
);
previousCoordinates = currentCoordinates.clone();
}
}