Skip to content

Commit a5caa6e

Browse files
Improve Valkyrien Skies and Immersive Portals compatibility (#581)
Co-authored-by: Craig <sandedshoes@gmail.com>
1 parent b893b20 commit a5caa6e

File tree

17 files changed

+309
-35
lines changed

17 files changed

+309
-35
lines changed

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
- Amethyst Screwdriver tooltip now is colored gray.
1010
- Updated create-fabric integration to create 6.
1111

12+
#### Configs
13+
- New config option to disable teleportation for the Immersive Portals portal, instead teleporting the player directly as if Immersive Portals integration was disabled.
14+
- New config option to toggle the above setting separately when the door is on a Valkyrien Skies ship.
15+
- New config option to disable the collision box of the door while open with Immersive Portals integration enabled on Valkyrien Skies ships.
16+
1217
#### Bug Fix
1318
- Bug fix: TARDIS exterior disappears when moved by other mods.
1419
- Bug fix: Taking off or landing a TARDIS on a Valkyrien Skies ship breaks the ship.
@@ -19,12 +24,14 @@
1924
- Bug fix: TARDIS does not take Valkyrien Skies ships into account when computing travel distance.
2025
- Bug fix: TARDIS does not automatically try to land on ships.
2126
- Bug fix: Flickering when spectating TARDIS exterior on a Valkyrien Skies ship.
27+
- Bug fix: Immersive Portals portal is not rotated correctly when door is on a Valkyrien Skies ship.
2228

2329
- Bug fix: Fixes Console Textures having left over prefabs
2430
- Bug fix: Fixes Forge not having the same access level as Fabric (https://github.com/WhoCraft/TardisRefined/issues/477)
2531
- Bug fix: Fixed Shulker shells not having correct texture paths
2632
- Bug fix: Fixed the TARDIS forgetting its current dimension on world reload
2733
- Bug fix: Fix materialize around upgrade not working.
2834
- Bug fix: Fixed TARDIS being broken when created in a non-overworld dimension.
35+
- Bug fix: Immersive Portals portal sometimes not spawning when opened from exterior.
2936
- Bug fix: Respawn Anchor and /spawnpoint command not working inside the TARDIS
3037

common/src/main/java/whocraft/tardis_refined/TRConfig.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,14 @@ public Client(ForgeConfigSpec.Builder builder) {
5353
public static class Common {
5454
public final ForgeConfigSpec.BooleanValue COMPATIBILITY_IP;
5555

56+
public final ForgeConfigSpec.BooleanValue IP_VS_COLLISION;
57+
5658
public Common(ForgeConfigSpec.Builder builder) {
5759
builder.push("compatibility");
5860
COMPATIBILITY_IP = builder.comment("Toggle Immersive Portals compatibility (TR 2.0+). 2.0 has limited support").translation(ModMessages.CONFIG_IP_COMPAT).define("immersive_portals_support", true);
61+
builder.push("immersive_portals_valkyrien_skies");
62+
IP_VS_COLLISION = builder.comment("If false, the TARDIS door's collision box will be disabled when opened on a Valkyrien Skies ship if teleportation_mode_vs is set to PORTAL.").translation(ModMessages.CONFIG_IP_VS_COLLISION).define("open_door_ship_collision", true);
63+
builder.pop();
5964
builder.pop();
6065
}
6166

@@ -66,12 +71,30 @@ public static class Server {
6671
public final ForgeConfigSpec.ConfigValue<List<? extends String>> ADVENTURE_MODE_DEFAULTS;
6772
public final ForgeConfigSpec.BooleanValue ADVENTURE_MODE;
6873

74+
public final ForgeConfigSpec.EnumValue<IPTeleportationMode> IP_TELEPORTATION;
75+
public final ForgeConfigSpec.EnumValue<IPTeleportationMode> IP_TELEPORTATION_VS;
76+
77+
public enum IPTeleportationMode {
78+
PORTAL,
79+
ITP;
80+
81+
private static final String COMMENT = "PORTAL is the normal immersive portals with maximum smoothness. ITP instead teleports the player directly similar to when Immersive Portals integration is disabled, making the boti effect purely visual.";
82+
}
83+
6984
public Server(ForgeConfigSpec.Builder builder) {
7085
builder.push("travel");
7186
BANNED_DIMENSIONS = builder.translation("config.tardis_refined.banned_dimensions").comment("A list of Dimensions the TARDIS cannot land in.").defineList("banned_dimensions", Lists.newArrayList("example:dimension"), String.class::isInstance);
7287
ADVENTURE_MODE_DEFAULTS = builder.translation("config.tardis_refined.adventure_mode_defaults").comment("A list of Dimensions that are automatically sampled").defineList("adventure_mode_defaults", Lists.newArrayList("minecraft:overworld"), String.class::isInstance);
7388
ADVENTURE_MODE = builder.translation("config.tardis_refined.adventure_mode").comment("Toggles whether players must discover and sample dimensions before they can travel there").define("adventure_mode", false);
7489
builder.pop();
90+
builder.push("compatibility");
91+
builder.push("immersive_portals");
92+
IP_TELEPORTATION = builder.comment("Choose what teleportation method to use when walking through the TARDIS door. " + IPTeleportationMode.COMMENT).translation(ModMessages.CONFIG_IP_TELEPORTATION).defineEnum("teleportation_mode", IPTeleportationMode.PORTAL);
93+
builder.pop();
94+
builder.push("immersive_portals_valkyrien_skies");
95+
IP_TELEPORTATION_VS = builder.comment("Choose what teleportation method to use when walking through the TARDIS door on a Valkyrien Skies ship. " + IPTeleportationMode.COMMENT + " ITP is recommended to avoid getting stuck in walls/the void when the ship is moving.").translation(ModMessages.CONFIG_IP_TELEPORTATION_VS).defineEnum("teleportation_mode_vs", IPTeleportationMode.ITP);
96+
builder.pop();
97+
builder.pop();
7598
}
7699

77100
}

common/src/main/java/whocraft/tardis_refined/common/block/door/GlobalDoorBlock.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
import net.minecraft.world.level.block.state.StateDefinition;
1818
import net.minecraft.world.phys.BlockHitResult;
1919
import net.minecraft.world.phys.shapes.CollisionContext;
20+
import net.minecraft.world.phys.shapes.Shapes;
2021
import net.minecraft.world.phys.shapes.VoxelShape;
2122
import org.jetbrains.annotations.NotNull;
2223
import org.jetbrains.annotations.Nullable;
24+
import whocraft.tardis_refined.TRConfig;
2325
import whocraft.tardis_refined.common.blockentity.door.GlobalDoorBlockEntity;
2426
import whocraft.tardis_refined.common.blockentity.life.EyeBlockEntity;
2527
import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator;
2628
import whocraft.tardis_refined.common.tardis.manager.AestheticHandler;
29+
import whocraft.tardis_refined.compat.ModCompatChecker;
30+
import whocraft.tardis_refined.compat.portals.ImmersivePortals;
31+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2732

2833
public class GlobalDoorBlock extends InternalDoorBlock {
2934

@@ -101,6 +106,15 @@ public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, Block
101106

102107
@Override
103108
public VoxelShape getCollisionShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
109+
BlockEntity blockEntity = blockGetter.getBlockEntity(blockPos);
110+
//noinspection ConstantValue IntelliJ got confused by this for some reason...
111+
if (
112+
!TRConfig.COMMON.IP_VS_COLLISION.get() && blockEntity != null && blockEntity.getLevel() != null &&
113+
ModCompatChecker.immersivePortals() && ImmersivePortals.isTeleportingPortalPresent(blockEntity.getLevel().dimension()) &&
114+
ModCompatChecker.valkyrienSkies() && VSHelper.isBlockInShipyard(blockEntity.getLevel(), blockPos)
115+
) {
116+
return Shapes.empty();
117+
}
104118
return this.getShape(blockState, blockGetter, blockPos, collisionContext);
105119
}
106120

common/src/main/java/whocraft/tardis_refined/common/block/door/InternalDoorBlock.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ public void entityInside(BlockState blockState, Level level, BlockPos blockPos,
120120

121121
TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> {
122122
if (!tardisLevelOperator.getPilotingManager().isInFlight()) {
123-
AABB teleportAABB = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity)).bounds().move(blockPos);
123+
VoxelShape teleportShape = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity));
124+
if (teleportShape.isEmpty()) return;
125+
AABB teleportAABB = teleportShape.bounds().move(blockPos);
124126
if (TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)) {
125127
door.onAttemptEnter(blockState, serverLevel, blockPos, entity);
126128
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@
1919
import net.minecraft.world.level.block.state.properties.BooleanProperty;
2020
import net.minecraft.world.phys.BlockHitResult;
2121
import net.minecraft.world.phys.shapes.CollisionContext;
22+
import net.minecraft.world.phys.shapes.Shapes;
2223
import net.minecraft.world.phys.shapes.VoxelShape;
2324
import org.jetbrains.annotations.NotNull;
2425
import org.jetbrains.annotations.Nullable;
26+
import whocraft.tardis_refined.TRConfig;
2527
import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity;
2628
import whocraft.tardis_refined.common.blockentity.shell.ShellBaseBlockEntity;
2729
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
30+
import whocraft.tardis_refined.compat.ModCompatChecker;
31+
import whocraft.tardis_refined.compat.portals.ImmersivePortals;
32+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2833

2934
public class GlobalShellBlock extends ShellBaseBlock {
3035

@@ -52,6 +57,14 @@ public BlockState getStateForPlacement(@NotNull BlockPlaceContext blockPlaceCont
5257
@Override
5358
public VoxelShape getCollisionShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
5459
if (blockGetter.getBlockEntity(blockPos) instanceof GlobalShellBlockEntity shellBlockEntity) {
60+
//noinspection ConstantValue IntelliJ got confused by this for some reason...
61+
if (
62+
!TRConfig.COMMON.IP_VS_COLLISION.get() &&
63+
ModCompatChecker.immersivePortals() && ImmersivePortals.isTeleportingPortalPresent(shellBlockEntity.getTardisId()) &&
64+
ModCompatChecker.valkyrienSkies() && VSHelper.isBlockInShipyard(shellBlockEntity.getLevel(), blockPos)
65+
) {
66+
return Shapes.empty();
67+
}
5568
if (shellBlockEntity.theme() == ShellTheme.BRIEFCASE.getId())
5669
return BRIEFCASE_COLLISION_SHAPE;
5770
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ public void entityInside(BlockState blockState, Level level, BlockPos blockPos,
121121
if (!level.isClientSide()) {
122122
ServerLevel serverLevel = (ServerLevel) level;
123123
if (serverLevel.getBlockEntity(blockPos) instanceof ExteriorShell shellEntity) {
124-
AABB teleportAABB = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity)).bounds().move(blockPos);
124+
VoxelShape teleportShape = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity));
125+
if (teleportShape.isEmpty()) return;
126+
AABB teleportAABB = teleportShape.bounds().move(blockPos);
125127
if (TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)) {
126128
shellEntity.onAttemptEnter(blockState, serverLevel, blockPos, entity);
127129
}

common/src/main/java/whocraft/tardis_refined/common/blockentity/door/GlobalDoorBlockEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import org.jetbrains.annotations.Nullable;
1818
import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator;
1919
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
20+
import whocraft.tardis_refined.compat.ModCompatChecker;
21+
import whocraft.tardis_refined.compat.portals.ImmersivePortals;
22+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2023
import whocraft.tardis_refined.constants.NbtConstants;
2124
import whocraft.tardis_refined.patterns.ShellPattern;
2225
import whocraft.tardis_refined.patterns.ShellPatterns;
@@ -172,6 +175,14 @@ public void playDoorLockedSound(boolean lockDoor) {
172175

173176
@Override
174177
public void tick(Level level, BlockPos blockPos, BlockState blockState, InternalDoorBlockEntity blockEntity) {
178+
//noinspection ConstantValue IntelliJ got confused by this for some reason...
179+
if (
180+
!level.isClientSide() && level instanceof ServerLevel sl &&
181+
ModCompatChecker.valkyrienSkies() && VSHelper.isBlockInShipyard(level, blockPos) &&
182+
ModCompatChecker.immersivePortals() && ImmersivePortals.doPortalsExistForTardis(level.dimension())
183+
) {
184+
TardisLevelOperator.get(sl).ifPresent(ImmersivePortals::updatePortalPositions);
185+
}
175186
/* if (level instanceof ServerLevel serverLevel) {
176187
TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> {
177188
if (blockEntity.isOpen() && tardisLevelOperator.getPilotingManager().isInFlight()) {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
import whocraft.tardis_refined.common.tardis.manager.TardisExteriorManager;
2424
import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager;
2525
import whocraft.tardis_refined.common.tardis.themes.ShellTheme;
26+
import whocraft.tardis_refined.common.util.DimensionUtil;
2627
import whocraft.tardis_refined.common.util.PlayerUtil;
28+
import whocraft.tardis_refined.compat.ModCompatChecker;
29+
import whocraft.tardis_refined.compat.portals.ImmersivePortals;
30+
import whocraft.tardis_refined.compat.valkyrienskies.VSHelper;
2731
import whocraft.tardis_refined.constants.ModMessages;
2832
import whocraft.tardis_refined.constants.NbtConstants;
2933
import whocraft.tardis_refined.patterns.ShellPattern;
@@ -73,6 +77,19 @@ public GlobalShellBlockEntity setPattern(ShellPattern basePattern) {
7377
return this;
7478
}
7579

80+
@Override
81+
public void tick(Level level, BlockPos blockPos, BlockState blockState, ShellBaseBlockEntity blockEntity) {
82+
super.tick(level, blockPos, blockState, blockEntity);
83+
//noinspection ConstantValue IntelliJ got confused by this for some reason...
84+
if (
85+
!level.isClientSide() &&
86+
ModCompatChecker.valkyrienSkies() && VSHelper.isBlockInShipyard(level, blockPos) &&
87+
ModCompatChecker.immersivePortals() && ImmersivePortals.doPortalsExistForTardis(ImmersivePortals.getUUIDForTARDIS(TARDIS_ID))
88+
) {
89+
TardisLevelOperator.get(DimensionUtil.getLevel(blockEntity.TARDIS_ID)).ifPresent(ImmersivePortals::updatePortalPositions);
90+
}
91+
}
92+
7693
@Override
7794
public void load(CompoundTag pTag) {
7895
super.load(pTag);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
import whocraft.tardis_refined.constants.NbtConstants;
3939
import whocraft.tardis_refined.registry.TRUpgrades;
4040

41-
import java.util.UUID;
41+
import java.util.Optional;
42+
import java.util.concurrent.atomic.AtomicBoolean;
4243

4344
public abstract class ShellBaseBlockEntity extends BlockEntity implements ExteriorShell, BlockEntityTicker<ShellBaseBlockEntity> {
4445

@@ -143,7 +144,7 @@ public void onAttemptEnter(BlockState blockState, Level level, BlockPos external
143144
ResourceLocation theme = aesthetics.getShellTheme();
144145

145146
if (ModCompatChecker.immersivePortals()) {
146-
if (ImmersivePortals.isShellThemeSupported(theme) && ImmersivePortals.doPortalsExistForTardis(UUID.fromString(TARDIS_ID.location().getPath()))) {
147+
if (ImmersivePortals.isShellThemeSupported(theme) && ImmersivePortals.isTeleportingPortalPresent(TARDIS_ID)) {
147148
return;
148149
}
149150
}

common/src/main/java/whocraft/tardis_refined/common/capability/tardis/TardisLevelOperator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import java.util.HashSet;
4949
import java.util.Iterator;
5050
import java.util.Optional;
51-
import java.util.UUID;
5251

5352
import static whocraft.tardis_refined.common.block.shell.ShellBaseBlock.REGEN;
5453

@@ -304,7 +303,7 @@ public boolean exitTardis(Entity entity, ServerLevel doorLevel, BlockPos doorPos
304303
if (aestheticHandler.getShellTheme() != null) {
305304
ResourceLocation theme = aestheticHandler.getShellTheme();
306305
if (ModCompatChecker.immersivePortals() && !(this.internalDoor instanceof RootShellDoorBlockEntity)) {
307-
if (!ignoreDoor && level.dimensionTypeId() == TRDimensionTypes.TARDIS && ImmersivePortals.isShellThemeSupported(theme) && ImmersivePortals.doPortalsExistForTardis(UUID.fromString(doorLevel.dimension().location().getPath()))) {
306+
if (!ignoreDoor && level.dimensionTypeId() == TRDimensionTypes.TARDIS && ImmersivePortals.isShellThemeSupported(theme) && ImmersivePortals.isTeleportingPortalPresent(doorLevel.dimension())) {
308307
return false;
309308
}
310309
}

0 commit comments

Comments
 (0)