Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
- Bug fix: Immersive Portals portal sometimes not spawning when opened from exterior.
- Bug fix: Respawn Anchor and /spawnpoint command not working inside the TARDIS
- Bug fix: Capability deserialization fails on Arclight
- Bug fix: TARDIS removes forceloading when taking off and landing.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package whocraft.tardis_refined.common.tardis.manager;

import net.minecraft.core.BlockPos;
import net.minecraft.core.SectionPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import whocraft.tardis_refined.common.block.shell.GlobalShellBlock;
Expand Down Expand Up @@ -139,39 +137,22 @@ public void removeExteriorBlock() {
if (currentPosition != null) {
BlockPos lastKnownLocationPosition = currentPosition.getPosition();
ServerLevel lastKnownLocationLevel = currentPosition.getLevel();
ChunkPos chunkPos = lastKnownLocationLevel.getChunk(lastKnownLocationPosition).getPos();
//Force load chunk
TardisPilotingManager.setChunkForced(lastKnownLocationLevel, chunkPos, true); //Set chunk to be force loaded to properly remove block
//Remove block
if (lastKnownLocationLevel.getBlockEntity(lastKnownLocationPosition) instanceof GlobalShellBlockEntity globalShellBlockEntity) {
lastKnownLocationLevel.removeBlock(lastKnownLocationPosition, false); //Set block to air with drop items flag to false
}
//Un-force load chunk
TardisPilotingManager.setChunkForced(lastKnownLocationLevel, chunkPos, false); //Set chunk to not be force loaded after we remove the block
}
}

/**
* Setup the landing data updates and physical placement of the shell block
*/
public void startLanding(TardisLevelOperator operator, TardisNavLocation location) {
ServerLevel targetLevel = location.getLevel();
BlockPos lastKnownLocationPosition = location.getPosition();
ChunkPos chunkPos = location.getLevel().getChunk(lastKnownLocationPosition).getPos();

this.isLanding = true;

//Force load target chunk
TardisPilotingManager.setChunkForced(targetLevel, chunkPos, true); //Set chunk to be force loaded to properly place block
this.isLanding = true;
operator.tardisClientData().setIsLanding(true);
operator.tardisClientData().sync();

this.placeExteriorBlockForLanding(location);

//Un-force load target chunk
TardisPilotingManager.setChunkForced(targetLevel, chunkPos, false); //Set chunk to be not be force loaded after we place the block

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,11 @@ public Optional<TardisNavLocation> findClosestValidPosition(TardisNavLocation lo
BlockPos position = location.getPosition();
Direction direction = location.getDirection();

ChunkPos chunkPos = level.getChunk(position).getPos();

var maxBuildHeight = level.getMaxBuildHeight();
var minHeight = level.getMinBuildHeight();

List<TardisNavLocation> solutionsInRow = new ArrayList<>();

//Force load chunk to search positions
setChunkForced(level, chunkPos, true);

Optional<TardisNavLocation> closest = Optional.empty();

boolean shouldLandOnShip = false;
Expand Down Expand Up @@ -465,9 +460,6 @@ public Optional<TardisNavLocation> findClosestValidPosition(TardisNavLocation lo

}

//Unforce chunk after we are done searching
setChunkForced(level, chunkPos, false);

return closest;
}

Expand Down Expand Up @@ -1400,14 +1392,4 @@ private int getLatestSpeedModifier() {
return this.speedModifier;
}

public static void setChunkForced(ServerLevel level, ChunkPos pos, boolean forced) {
if (ModCompatChecker.valkyrienSkies() && VSHelper.isChunkInShipyard(pos)) {
VSHelper.toWorldShipChunks(level, pos).forEach(p -> {
level.setChunkForced(p.x, p.z, forced);
});
} else {
level.setChunkForced(pos.x, pos.z, forced);
}
}

}