-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle chunk loading game state in 1.20.3 -> 1.20.2 (#643)
- Loading branch information
1 parent
e24a170
commit 2dd19c7
Showing
3 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...viaversion/viabackwards/protocol/protocol1_20_2to1_20_3/storage/SpawnPositionStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards | ||
* Copyright (C) 2023 ViaVersion and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.viaversion.viabackwards.protocol.protocol1_20_2to1_20_3.storage; | ||
|
||
import com.viaversion.viaversion.api.connection.StorableObject; | ||
import com.viaversion.viaversion.api.minecraft.Position; | ||
import com.viaversion.viaversion.libs.fastutil.Pair; | ||
|
||
import java.util.Objects; | ||
|
||
public class SpawnPositionStorage implements StorableObject { | ||
public static final Pair<Position, Float> DEFAULT_SPAWN_POSITION = Pair.of(new Position(8, 64, 8), 0.0F); // Default values copied from the original client | ||
|
||
private Pair<Position, Float> spawnPosition; | ||
private String dimension; | ||
|
||
public Pair<Position, Float> getSpawnPosition() { | ||
return spawnPosition; | ||
} | ||
|
||
public void setSpawnPosition(final Pair<Position, Float> spawnPosition) { | ||
this.spawnPosition = spawnPosition; | ||
} | ||
|
||
/** | ||
* Sets the dimension and resets the spawn position to the default value if the dimension changed. | ||
* | ||
* @param dimension The new dimension | ||
*/ | ||
public void setDimension(final String dimension) { | ||
final boolean changed = !Objects.equals(this.dimension, dimension); | ||
this.dimension = dimension; | ||
|
||
if (changed) { | ||
this.spawnPosition = DEFAULT_SPAWN_POSITION; | ||
} | ||
} | ||
} |