Skip to content

Commit

Permalink
fix(uni): potential android location loss
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Dec 23, 2024
1 parent 5786ad6 commit 3ee5a83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1307,8 +1307,13 @@ private void migrateUniversalData(
var universalData = createUniversalBlock(l, sfId);

Slimefun.runSync(
() -> Slimefun.getBlockDataService()
.updateUniversalDataUUID(l.getBlock(), String.valueOf(universalData.getUUID())),
() -> {
if (Slimefun.getBlockDataService()
.isTileEntity(l.getBlock().getType())) {
Slimefun.getBlockDataService()
.updateUniversalDataUUID(l.getBlock(), String.valueOf(universalData.getUUID()));
}
},
10L);

kvData.forEach(recordSet -> universalData.setData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public SlimefunUniversalBlockData(UUID uuid, String sfId, BlockPosition present)
super(uuid, sfId);

this.lastPresent = present;
setTraitData(UniversalDataTrait.BLOCK, LocationUtils.locationToString(lastPresent.toLocation()));
}

public SlimefunUniversalBlockData(UUID uuid, String sfId, Location present) {
Expand All @@ -30,6 +31,10 @@ public void setLastPresent(BlockPosition lastPresent) {
this.lastPresent = lastPresent;
}

public void setLastPresent(Location l) {
setLastPresent(new BlockPosition(l));
}

public BlockPosition getLastPresent() {
if (lastPresent != null) {
return lastPresent;
Expand Down

0 comments on commit 3ee5a83

Please sign in to comment.