Skip to content

Commit 4066b93

Browse files
Acuadragon100grappigegovertJeryn99
authored
Fix Valkyrien Skies (#542)
Co-authored-by: Govert de Gans <grappigegovert@hotmail.com> Co-authored-by: Craig <sandedshoes@gmail.com>
1 parent eec3b27 commit 4066b93

File tree

17 files changed

+336
-29
lines changed

17 files changed

+336
-29
lines changed

changelog.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
# Version 2.1.6
1+
# Version 2.1.7
22

33
![TARDIS Refined](https://wiki.tardisrefined.net/TARDIS-Refined-Wiki/tardis_refined_v2_1.png)
44

55
#### Changes
66
- Amethyst Screwdriver tooltip now is colored gray.
77

88
#### Bug Fix
9+
- Bug fix: TARDIS exterior disappears when moved by other mods.
10+
- Bug fix: Taking off or landing a TARDIS on a Valkyrien Skies ship breaks the ship.
11+
- Bug fix: Impossible to enter TARDIS when on a Valkyrien Skies ship.
12+
- Bug fix: TARDIS shows shipyard coordinates when on a Valkyrien Skies ship.
13+
- Bug fix: Player does not face the right horizontal direction when entering/exiting a TARDIS on a Valkyrien Skies ship.
14+
- Partial bug fix: Player falls through Valkyrien Skies ship when exiting the TARDIS.
15+
- Bug fix: TARDIS does not take Valkyrien Skies ships into account when computing travel distance.
16+
- Bug fix: TARDIS does not automatically try to land on ships.
17+
- Bug fix: Flickering when spectating TARDIS exterior on a Valkyrien Skies ship.
18+
919
- Bug fix: Fixes Console Textures having left over prefabs
1020
- Bug fix: Fixes Forge not having the same access level as Fabric (https://github.com/WhoCraft/TardisRefined/issues/477)
1121
- Bug fix: Fixed Shulker shells not having correct texture paths

common/src/main/java/whocraft/tardis_refined/common/block/shell/GlobalShellBlock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, Block
6868
}
6969

7070
@Nullable
71-
@Override
71+
@Override // Always assume it's placed by another mod. That setting is set to false when the TARDIS_ID is set.
7272
public BlockEntity newBlockEntity(BlockPos blockPos, BlockState blockState) {
73-
return new GlobalShellBlockEntity(blockPos, blockState);
73+
return new GlobalShellBlockEntity(blockPos, blockState).setPlacedByOtherMod(true);
7474
}
7575

7676
@Nullable

common/src/main/java/whocraft/tardis_refined/common/block/shell/ShellBaseBlock.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
import net.minecraft.world.level.material.FluidState;
2020
import net.minecraft.world.level.material.Fluids;
2121
import net.minecraft.world.phys.AABB;
22+
import net.minecraft.world.phys.Vec3;
2223
import net.minecraft.world.phys.shapes.CollisionContext;
2324
import net.minecraft.world.phys.shapes.VoxelShape;
2425
import org.jetbrains.annotations.NotNull;
2526
import org.jetbrains.annotations.Nullable;
2627
import whocraft.tardis_refined.common.blockentity.shell.ExteriorShell;
2728
import whocraft.tardis_refined.common.util.TRTeleporter;
29+
import whocraft.tardis_refined.compat.ModCompatChecker;
30+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2831

2932
public abstract class ShellBaseBlock extends BaseEntityBlock implements SimpleWaterloggedBlock, Fallable {
3033

common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator;
2828
import whocraft.tardis_refined.common.capability.tardis.upgrades.UpgradeHandler;
2929
import whocraft.tardis_refined.common.dimension.DimensionHandler;
30+
import whocraft.tardis_refined.common.tardis.TardisNavLocation;
3031
import whocraft.tardis_refined.common.tardis.manager.AestheticHandler;
3132
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
3233
import whocraft.tardis_refined.common.util.DimensionUtil;
@@ -44,6 +45,7 @@ public abstract class ShellBaseBlockEntity extends BlockEntity implements Exteri
4445
public AnimationState liveliness = new AnimationState();
4546
protected ResourceKey<Level> TARDIS_ID;
4647
private boolean hasPotentialToBeRemoved = false;
48+
private boolean placedByOtherMod = false; // We don't serialize this by design, because other mods might still create duplicates.
4749

4850
public ShellBaseBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
4951
super(blockEntityType, blockPos, blockState);
@@ -54,11 +56,17 @@ public ResourceKey<Level> getTardisId() {
5456
return this.TARDIS_ID;
5557
}
5658

59+
public ShellBaseBlockEntity setPlacedByOtherMod(boolean placedByOtherMod) {
60+
this.placedByOtherMod = placedByOtherMod;
61+
return this;
62+
}
63+
5764
@Override
5865
public void setTardisId(ResourceKey<Level> levelKey) {
5966
this.TARDIS_ID = levelKey;
6067
this.setChanged();
6168
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), Block.UPDATE_ALL);
69+
placedByOtherMod = false; // If any mod runs this function we can be sure they have probably set the current location property.
6270
}
6371

6472
@Override
@@ -161,6 +169,13 @@ public void tick(Level level, BlockPos blockPos, BlockState blockState, ShellBas
161169

162170
TardisLevelOperator.get(tardisLevel).ifPresent(tardisLevelOperator -> {
163171
if(!tardisLevelOperator.getPilotingManager().isInFlight()) {
172+
if (placedByOtherMod) { // If placed by another mod we don't want it to delete itself.
173+
var dir = level.getBlockState(blockPos).getOptionalValue(ShellBaseBlock.FACING).orElse(Direction.NORTH);
174+
tardisLevelOperator.getPilotingManager().setCurrentLocation(
175+
new TardisNavLocation(blockPos, dir, level.dimension())
176+
);
177+
placedByOtherMod = false;
178+
}
164179
if (isInvalidTardis(tardisLevelOperator)) {
165180
BlockPos myCurrentPosition = getBlockPos();
166181
level.removeBlock(myCurrentPosition, false);

common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.world.entity.LivingEntity;
1010
import net.minecraft.world.entity.player.Abilities;
1111
import net.minecraft.world.entity.player.Player;
12+
import net.minecraft.world.phys.Vec3;
1213
import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator;
1314
import whocraft.tardis_refined.common.network.messages.player.C2SExitTardisView;
1415
import whocraft.tardis_refined.common.network.messages.player.S2CResetPostShellView;
@@ -18,6 +19,8 @@
1819
import whocraft.tardis_refined.common.util.DimensionUtil;
1920
import whocraft.tardis_refined.common.util.Platform;
2021
import whocraft.tardis_refined.common.util.TRTeleporter;
22+
import whocraft.tardis_refined.compat.ModCompatChecker;
23+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2124

2225
import javax.annotation.Nullable;
2326
import java.util.Objects;
@@ -104,9 +107,15 @@ public void startShellView(ServerPlayer serverPlayer, TardisLevelOperator tardis
104107
if (spectateTarget != null) {
105108

106109
BlockPos spectatePos = spectateTarget.getPosition();
110+
Vec3 accurateSpectatePos = Vec3.atBottomCenterOf(spectatePos);
107111

108-
if (spectateTarget.getPosition().distManhattan(new Vec3i((int) player.position().x, (int) player.position().y, (int) player.position().z)) > 3 || !player.level().dimension().location().toString().equals(spectateTarget.getDimensionKey().location().toString())) {
109-
TRTeleporter.simpleTeleport(player, spectateTarget.getLevel(), spectatePos.getX() + 0.5, spectatePos.getY(), spectatePos.getZ() + 0.5, playerPreviousRot, playerPreviousYaw);
112+
if (ModCompatChecker.valkyrienSkies()) {
113+
accurateSpectatePos = VSHelper.toWorldPosition(spectateTarget.getLevel(), spectatePos, accurateSpectatePos);
114+
spectatePos = VSHelper.toWorldPosition(spectateTarget.getLevel(), spectatePos);
115+
}
116+
117+
if (spectatePos.distManhattan(new Vec3i((int) player.position().x, (int) player.position().y, (int) player.position().z)) > 3 || !player.level().dimension().location().toString().equals(spectateTarget.getDimensionKey().location().toString())) {
118+
TRTeleporter.simpleTeleport(player, spectateTarget.getLevel(), accurateSpectatePos.x, accurateSpectatePos.y, accurateSpectatePos.z, playerPreviousRot, playerPreviousYaw);
110119
}
111120
updatePlayerAbilities(serverPlayer, serverPlayer.getAbilities(), true);
112121
setRenderVortex(timeVortex);

common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/CoordinateControl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
1111
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
1212
import whocraft.tardis_refined.common.util.PlayerUtil;
13+
import whocraft.tardis_refined.compat.ModCompatChecker;
14+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
1315

1416

1517
public class CoordinateControl extends whocraft.tardis_refined.common.tardis.control.Control {
@@ -54,6 +56,11 @@ private boolean changeCoord(TardisLevelOperator operator, ConsoleTheme theme, Co
5456
case Z -> potentialPos = potentialPos.offset(0, 0, incrementAmount);
5557
}
5658

59+
if (ModCompatChecker.valkyrienSkies()) {
60+
pilotManager.setTargetLocation(VSHelper.toWorldLocation(pilotManager.getTargetLocation()));
61+
potentialPos = VSHelper.toWorldPosition(targetLocation.getLevel(), potentialPos);
62+
}
63+
5764
//Use vanilla check which accounts for both world height and horizontal bounds
5865
if (pilotManager.getTargetLocation().getLevel().isInWorldBounds(potentialPos)) {
5966

common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/DimensionalControl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
1313
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
1414
import whocraft.tardis_refined.common.util.*;
15+
import whocraft.tardis_refined.compat.ModCompatChecker;
16+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
1517
import whocraft.tardis_refined.constants.ModMessages;
1618
import whocraft.tardis_refined.registry.TRUpgrades;
1719

@@ -82,6 +84,9 @@ private boolean changeDim(TardisLevelOperator operator, ConsoleTheme theme, Cont
8284
}
8385
}
8486

87+
if (ModCompatChecker.valkyrienSkies()) {
88+
pilotManager.setTargetLocation(VSHelper.toWorldLocation(pilotManager.getTargetLocation()));
89+
}
8590
pilotManager.setTargetDimension(dimensions.get(nextIndex));
8691

8792
PlayerUtil.sendMessage(player, Component.translatable(ModMessages.CONTROL_DIMENSION_SELECTED, MiscHelper.getCleanDimensionName(pilotManager.getTargetLocation().getDimensionKey())), true);

common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/ReadoutControl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import whocraft.tardis_refined.common.tardis.TardisNavLocation;
99
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
1010
import whocraft.tardis_refined.common.util.PlayerUtil;
11+
import whocraft.tardis_refined.compat.ModCompatChecker;
12+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
1113
import whocraft.tardis_refined.constants.ModMessages;
1214

1315
public class ReadoutControl extends whocraft.tardis_refined.common.tardis.control.Control {
@@ -23,6 +25,9 @@ public ReadoutControl(ResourceLocation id, String langId) {
2325
public boolean onLeftClick(TardisLevelOperator operator, ConsoleTheme theme, ControlEntity controlEntity, Player player) {
2426

2527
TardisNavLocation currentPosition = operator.getPilotingManager().getCurrentLocation();
28+
if (ModCompatChecker.valkyrienSkies()) {
29+
currentPosition = VSHelper.toWorldLocation(currentPosition);
30+
}
2631
PlayerUtil.sendMessage(player, Component.translatable(ModMessages.CURRENT).append(" - X: " + currentPosition.getPosition().getX() + " Y: " + currentPosition.getPosition().getY() + " Z: " + currentPosition.getPosition().getZ() + " F: " + currentPosition.getDirection().getName() + " D: " + currentPosition.getDimensionKey().location().getPath()), true);
2732

2833

@@ -33,6 +38,9 @@ public boolean onLeftClick(TardisLevelOperator operator, ConsoleTheme theme, Con
3338
public boolean onRightClick(TardisLevelOperator operator, ConsoleTheme theme, ControlEntity controlEntity, Player player) {
3439

3540
TardisNavLocation targetLocation = operator.getPilotingManager().getTargetLocation();
41+
if (ModCompatChecker.valkyrienSkies()) {
42+
targetLocation = VSHelper.toWorldLocation(targetLocation);
43+
}
3644
PlayerUtil.sendMessage(player, Component.translatable(ModMessages.DESTINATION).append(" - X: " + targetLocation.getPosition().getX() + " Y: " + targetLocation.getPosition().getY() + " Z: " + targetLocation.getPosition().getZ() + " F: " + targetLocation.getDirection().getName() + " D: " + targetLocation.getDimensionKey().location().getPath()), true);
3745

3846
return true;

common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/RotationControl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
1010
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
1111
import whocraft.tardis_refined.common.util.PlayerUtil;
12+
import whocraft.tardis_refined.compat.ModCompatChecker;
13+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
1214

1315
public class RotationControl extends whocraft.tardis_refined.common.tardis.control.Control {
1416
public RotationControl(ResourceLocation id) {
@@ -32,6 +34,9 @@ public boolean onLeftClick(TardisLevelOperator operator, ConsoleTheme theme, Con
3234
private boolean rotateDir(TardisLevelOperator operator, ConsoleTheme theme, ControlEntity controlEntity, Player player, boolean clockwise) {
3335
if (!operator.getLevel().isClientSide()) {
3436
TardisPilotingManager pilotManager = operator.getPilotingManager();
37+
if (ModCompatChecker.valkyrienSkies()) {
38+
pilotManager.setTargetLocation(VSHelper.toWorldLocation(pilotManager.getTargetLocation()));
39+
}
3540

3641
Direction dir = pilotManager.getTargetLocation().getDirection();
3742
pilotManager.getTargetLocation().setDirection(clockwise ? dir.getClockWise() : dir.getCounterClockWise());

common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme;
1818
import whocraft.tardis_refined.common.util.MiscHelper;
1919
import whocraft.tardis_refined.common.util.PlayerUtil;
20+
import whocraft.tardis_refined.compat.ModCompatChecker;
21+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2022
import whocraft.tardis_refined.constants.ModMessages;
2123

2224
public class MonitorControl extends Control {
@@ -56,8 +58,15 @@ public boolean onRightClick(TardisLevelOperator operator, ConsoleTheme theme, Co
5658
if (key.interactMonitor(hand, player, controlEntity, player.getUsedItemHand()))
5759
isSyncingKey = true;
5860
}
59-
if (!isSyncingKey)
60-
new S2COpenMonitor(operator.getInteriorManager().isWaitingToGenerate(), operator.getPilotingManager().getCurrentLocation(), operator.getPilotingManager().getTargetLocation(), operator.getUpgradeHandler(), operator.getAestheticHandler().getShellTheme()).send((ServerPlayer) player);
61+
if (!isSyncingKey) {
62+
var currentLocation = operator.getPilotingManager().getCurrentLocation();
63+
var targetLocation = operator.getPilotingManager().getTargetLocation();
64+
if (ModCompatChecker.valkyrienSkies()) {
65+
currentLocation = VSHelper.toWorldLocation(currentLocation);
66+
targetLocation = VSHelper.toWorldLocation(targetLocation);
67+
}
68+
new S2COpenMonitor(operator.getInteriorManager().isWaitingToGenerate(), currentLocation, targetLocation, operator.getUpgradeHandler(), operator.getAestheticHandler().getShellTheme()).send((ServerPlayer) player);
69+
}
6170
return true;
6271
}
6372
return false;

0 commit comments

Comments
 (0)