diff --git a/build.gradle b/build.gradle index c9eb690c8..9f5c222d9 100644 --- a/build.gradle +++ b/build.gradle @@ -55,7 +55,7 @@ githubRelease { owner "WhoCraft" repo "TardisRefined" tagName "v$rootProject.minecraft_version-$project.mod_version" - targetCommitish "mc/1.20.1" + targetCommitish "mc/1.20.2" releaseName "[$rootProject.minecraft_version] Tardis Refined - v$project.mod_version" generateReleaseNotes true body new File("${rootProject.projectDir}/changelog.md").text diff --git a/changelog.md b/changelog.md index e949f3f08..9177ffe4e 100644 --- a/changelog.md +++ b/changelog.md @@ -2,9 +2,13 @@ ![TARDIS Refined](https://wiki.tardisrefined.net/TARDIS-Refined-Wiki/tardis_refined_v2_1.png) - #### Bug Fixes - Bug Fix: Tardis will change locations without taking off, just by setting coordinates.[#427](https://github.com/WhoCraft/TardisRefined/issues/427) - Bug Fix: Using the amethyst screwdriver to interact with the terraformer causes a freeze crash. (v2.1.1) [#426](https://github.com/WhoCraft/TardisRefined/issues/426) - Bug Fix: Instantaneous Travel [#421](https://github.com/WhoCraft/TardisRefined/issues/421) - +- Bug Fix: Crash loop when using the console changer [#432](https://github.com/WhoCraft/TardisRefined/issues/432) +- Bug Fix: [FORGE] Shell Patterns not shown on computer bank [#425](https://github.com/WhoCraft/TardisRefined/issues/425) +- Bug Fix: Consoles not animating correctly +- Bug Fix: Tardis can travel to it's own dimension [#435](https://github.com/WhoCraft/TardisRefined/issues/435) +- Bug Fix: Enter TARDIS with door closed [#422](https://github.com/WhoCraft/TardisRefined/issues/422) +- Bug Fix: Tardis Shell Viewer not in correct position [#434](https://github.com/WhoCraft/TardisRefined/issues/434) diff --git a/common/src/main/java/dev/jeryn/frame/tardis/Frame.java b/common/src/main/java/dev/jeryn/frame/tardis/Frame.java index 4fa2f3765..e23f2da31 100644 --- a/common/src/main/java/dev/jeryn/frame/tardis/Frame.java +++ b/common/src/main/java/dev/jeryn/frame/tardis/Frame.java @@ -74,6 +74,7 @@ public static AnimationDefinition loadAnimation(ResourceManager resourceManager, ); } + return animationDefinition.build(); } diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/FactoryConsoleModel.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/FactoryConsoleModel.java index 6490bbee8..73b09a417 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/FactoryConsoleModel.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/FactoryConsoleModel.java @@ -52,12 +52,12 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev root().getAllParts().forEach(ModelPart::resetPose); TardisClientData reactions = TardisClientData.getInstance(level.dimension()); if (globalConsoleBlock == null) return; + if (globalConsoleBlock.getBlockState() == null) return; Boolean powered = globalConsoleBlock.getBlockState() == null ? true : globalConsoleBlock.getBlockState().getValue(GlobalConsoleBlock.POWERED); if (powered) { - if (!globalConsoleBlock.powerOn.isStarted()) { globalConsoleBlock.powerOff.stop(); globalConsoleBlock.powerOn.start(Minecraft.getInstance().player.tickCount); @@ -92,10 +92,10 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev this.handbrake.xRot = reactions.isHandbrakeEngaged() ? -155f : -125f; root().render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); - } + @Override public ModelPart root() { return root; diff --git a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/VictorianConsoleModel.java b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/VictorianConsoleModel.java index 8e158cb04..f8c5b5521 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/VictorianConsoleModel.java +++ b/common/src/main/java/whocraft/tardis_refined/client/model/blockentity/console/VictorianConsoleModel.java @@ -926,9 +926,12 @@ public void setupAnim(Entity entity, float f, float g, float h, float i, float j public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level level, PoseStack poseStack, VertexConsumer vertexConsumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { root().getAllParts().forEach(ModelPart::resetPose); TardisClientData reactions = TardisClientData.getInstance(level.dimension()); + if (globalConsoleBlock == null) return; + if (globalConsoleBlock.getBlockState() == null) return; Boolean powered = globalConsoleBlock.getBlockState() == null ? true : globalConsoleBlock.getBlockState().getValue(GlobalConsoleBlock.POWERED); + if (powered) { if (!globalConsoleBlock.powerOn.isStarted()) { globalConsoleBlock.powerOff.stop(); @@ -948,6 +951,7 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev this.animate(globalConsoleBlock.liveliness, IDLE, Minecraft.getInstance().player.tickCount); } } + } else { if (globalConsoleBlock != null) { if (!globalConsoleBlock.powerOff.isStarted()) { @@ -958,12 +962,14 @@ public void renderConsole(GlobalConsoleBlockEntity globalConsoleBlock, Level lev } } + float rot = 1f + (2 * ((float) reactions.getThrottleStage() / TardisPilotingManager.MAX_THROTTLE_STAGE)); throttle_control.yRot = rot; root().render(poseStack, vertexConsumer, packedLight, packedOverlay, red, green, blue, alpha); } + @Override public ResourceLocation getDefaultTexture() { return VICTORIAN_TEXTURE; diff --git a/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java b/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java index 1df493b2e..ab76d9e55 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java +++ b/common/src/main/java/whocraft/tardis_refined/client/overlays/VortexOverlay.java @@ -181,6 +181,7 @@ public static void renderOverlay(GuiGraphics gg) { pose.mulPose(Axis.ZP.rotationDegrees(mul * VORTEX.lightning_strike * 90 * Mth.sin(VORTEX.lightning_strike))); pose.pushPose(); + pose.translate(0.5,0,0); renderShell(gg, IMMERSION, 1 - demat_transparency, tardisClientData.getThrottleStage()); pose.popPose(); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java index 6fd9e0581..71ce00893 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/RenderTargetHelper.java @@ -22,6 +22,8 @@ import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.state.BlockState; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL11; import whocraft.tardis_refined.TRConfig; import whocraft.tardis_refined.TardisRefined; @@ -47,6 +49,8 @@ public class RenderTargetHelper { private static final RenderTargetHelper RENDER_TARGET_HELPER = new RenderTargetHelper(); public static StencilBufferStorage stencilBufferStorage = new StencilBufferStorage(); + public static Logger LOGGER = LogManager.getLogger("TardisRefinbed/StencilRendering"); + public static void renderVortex(GlobalDoorBlockEntity blockEntity, float partialTick, PoseStack stack, MultiBufferSource bufferSource, int packedLight, int packedOverlay) { BlockState blockstate = blockEntity.getBlockState(); @@ -106,6 +110,8 @@ private static void renderDoorOpen(GlobalDoorBlockEntity blockEntity, PoseStack // Enable and configure stencil buffer GL11.glEnable(GL11.GL_STENCIL_TEST); + checkGLError("Enabling stencil test"); + GL11.glStencilMask(0xFF); // Ensure stencil mask is set before clearing GL11.glClear(GL11.GL_STENCIL_BUFFER_BIT); // Clear stencil buffer GL11.glStencilFunc(GL11.GL_ALWAYS, 1, 0xFF); @@ -154,7 +160,13 @@ private static void renderDoorOpen(GlobalDoorBlockEntity blockEntity, PoseStack stack.popPose(); } + public static void checkGLError(String msg) { + int error; + while ((error = GL11.glGetError()) != GL11.GL_NO_ERROR) { + LOGGER.debug("{}: {}", msg, error); + } + } private static void renderNoVortex(GlobalDoorBlockEntity blockEntity, PoseStack stack, MultiBufferSource bufferSource, int packedLight, float rotation, ShellDoorModel currentModel, boolean isOpen) { stack.pushPose(); diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java index c3853571a..1d7b040da 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/vortex/ShellRenderer.java @@ -60,10 +60,12 @@ public static void renderShell(GuiGraphics guiGraphics, float control, float alp GLOBALSHELL_BLOCKENTITY.setTardisId(tardisClientData.getLevelKey()); if(Platform.isForge()) { + float scale = 2.5F; pose.scale(scale, scale, scale); } + model.renderShell(GLOBALSHELL_BLOCKENTITY, false, false, pose, vertexConsumer, 15728880, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F, 1.0F, alpha); if (fullPattern.shellTexture().emissive()) { diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java index 90df8d254..8b8c94d62 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/main/MonitorScreen.java @@ -66,7 +66,10 @@ protected void init() { .size(70, 20).build()); vortxSelectButton.active = true; */ - BackgroundlessButton extView = addRenderableWidget(BackgroundlessButton.backgroundlessBuilder(Component.literal(""), button -> new C2SBeginShellView().send()).pos(hPos + 20, -30 + height / 2).size(40, 60).build()); + BackgroundlessButton extView = addRenderableWidget(BackgroundlessButton.backgroundlessBuilder(Component.literal(""), button -> { + new C2SBeginShellView().send(); + Minecraft.getInstance().setScreen(null); + }).pos(hPos + 20, -30 + height / 2).size(40, 60).build()); extView.setTooltip(Tooltip.create(Component.translatable(ModMessages.UI_MONITOR_SHELL_VIEW))); extView.active = true; diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java index f9c2a2083..0ecf9e3d4 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/screens/ShellSelectionScreen.java @@ -33,6 +33,11 @@ public ShellSelectionScreen(ResourceLocation currentShellTheme) { super(Component.translatable(ModMessages.UI_EXTERNAL_SHELL), currentShellTheme); } + @Override + public ResourceLocation getPatternForRender() { + return PATTERN.id(); + } + @Override protected void init() { super.init(); diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/shell/ShellBaseBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/shell/ShellBaseBlock.java index 60e8f3024..0f634a1f1 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/shell/ShellBaseBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/shell/ShellBaseBlock.java @@ -138,7 +138,7 @@ public void entityInside(BlockState blockState, Level level, BlockPos blockPos, ServerLevel serverLevel = (ServerLevel) level; if (serverLevel.getBlockEntity(blockPos) instanceof ExteriorShell shellEntity) { AABB teleportAABB = this.getCollisionShape(blockState, level, blockPos, CollisionContext.of(entity)).bounds().move(blockPos); - if (TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)) { + if (blockState.getValue(OPEN) && TRTeleporter.teleportIfCollided(serverLevel, blockPos, entity, teleportAABB)) { shellEntity.onAttemptEnter(blockState, serverLevel, blockPos, entity); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java index 354bc00b2..d9f1dcd21 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/ShellBaseBlockEntity.java @@ -30,6 +30,7 @@ import whocraft.tardis_refined.common.dimension.DimensionHandler; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.TardisNavLocation; +import whocraft.tardis_refined.common.tardis.manager.AestheticHandler; import whocraft.tardis_refined.common.tardis.manager.TardisPilotingManager; import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; import whocraft.tardis_refined.common.util.Platform; @@ -113,10 +114,11 @@ public void onAttemptEnter(BlockState blockState, Level level, BlockPos external TardisLevelOperator.get(interior).ifPresent(cap -> { UpgradeHandler upgradeHandler = cap.getUpgradeHandler(); + AestheticHandler aesthetics = cap.getAestheticHandler(); if (cap.isTardisReady() && (blockState.getValue(ShellBaseBlock.OPEN) || (cap.getPilotingManager().isLanding() && TRUpgrades.MATERIALIZE_AROUND.get().isUnlocked(upgradeHandler)))) { - if (cap.getAestheticHandler().getShellTheme() != null) { - ResourceLocation theme = cap.getAestheticHandler().getShellTheme(); + if (aesthetics.getShellTheme() != null) { + ResourceLocation theme = aesthetics.getShellTheme(); if (ModCompatChecker.immersivePortals()) { if (ImmersivePortals.isShellThemeSupported(theme) && ImmersivePortals.doPortalsExistForTardis(UUID.fromString(TARDIS_ID.location().getPath()))) { diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java index 8d335c644..297f9d416 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPilot.java @@ -14,9 +14,9 @@ public interface TardisPilot { void updatePlayerAbilities(ServerPlayer player, Abilities abilities, boolean isWatcher); - void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget, boolean timeVortex); + void startShellView(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget, boolean timeVortex); - void endPlayerForInspection(ServerPlayer serverPlayer); + void endShellView(ServerPlayer serverPlayer); UUID getViewedTardis(); diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java index 5e3a9aecc..5409654e0 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/player/TardisPlayerInfo.java @@ -10,7 +10,6 @@ import net.minecraft.world.entity.player.Abilities; import net.minecraft.world.entity.player.Player; import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; -import whocraft.tardis_refined.common.dimension.TardisTeleportData; import whocraft.tardis_refined.common.network.messages.player.C2SExitTardisView; import whocraft.tardis_refined.common.network.messages.player.S2CResetPostShellView; import whocraft.tardis_refined.common.network.messages.sync.S2CSyncTardisPlayerView; @@ -48,7 +47,7 @@ public static void updateTardisForAllPlayers(TardisLevelOperator tardisLevelOper TardisPlayerInfo.get(serverPlayer).ifPresent(tardisPlayerInfo -> { if (tardisPlayerInfo.isViewingTardis()) { if (Objects.equals(tardisPlayerInfo.getViewedTardis().toString(), UUID.fromString(tardisLevelOperator.getLevelKey().location().getPath()).toString())) { - tardisPlayerInfo.setupPlayerForInspection(serverPlayer, tardisLevelOperator, tardisNavLocation, timeVortex); + tardisPlayerInfo.startShellView(serverPlayer, tardisLevelOperator, tardisNavLocation, timeVortex); } } }); @@ -88,7 +87,7 @@ public void updatePlayerAbilities(ServerPlayer player, Abilities abilities, bool } @Override - public void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget, boolean timeVortex) { + public void startShellView(ServerPlayer serverPlayer, TardisLevelOperator tardisLevelOperator, TardisNavLocation spectateTarget, boolean timeVortex) { // Set the player's viewed TARDIS UUID UUID uuid = UUID.fromString(tardisLevelOperator.getLevelKey().location().getPath()); @@ -106,7 +105,7 @@ public void setupPlayerForInspection(ServerPlayer serverPlayer, TardisLevelOpera BlockPos spectatePos = spectateTarget.getPosition(); 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())) { - TRTeleporter.simpleTeleport(player, spectateTarget.getLevel(), spectatePos.getX(), spectatePos.getY(), spectatePos.getZ(), playerPreviousRot, playerPreviousYaw); + TRTeleporter.simpleTeleport(player, spectateTarget.getLevel(), spectatePos.getX() + 0.5, spectatePos.getY(), spectatePos.getZ() + 0.5, playerPreviousRot, playerPreviousYaw); } updatePlayerAbilities(serverPlayer, serverPlayer.getAbilities(), true); setRenderVortex(timeVortex); @@ -197,11 +196,11 @@ public Player getPlayer() { } @Override - public void endPlayerForInspection(ServerPlayer serverPlayer) { + public void endShellView(ServerPlayer serverPlayer) { if (!isViewingTardis()) return; BlockPos targetPosition = getPlayerPreviousPos().getPosition(); - TRTeleporter.simpleTeleport(serverPlayer, getPlayerPreviousPos().getLevel(), targetPosition.getX(), targetPosition.getY(), targetPosition.getZ(), playerPreviousYaw, playerPreviousRot); + TRTeleporter.simpleTeleport(serverPlayer, Platform.getServer().getLevel(getPlayerPreviousPos().getDimensionKey()), targetPosition.getX() + 0.5, targetPosition.getY(), targetPosition.getZ() + 0.5, playerPreviousYaw, playerPreviousRot); updatePlayerAbilities(serverPlayer, serverPlayer.getAbilities(), false); serverPlayer.onUpdateAbilities(); new S2CResetPostShellView().send(serverPlayer); diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SBeginShellView.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SBeginShellView.java index 1ec8d919d..e2c0927a6 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SBeginShellView.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SBeginShellView.java @@ -37,7 +37,7 @@ public void handle(MessageContext context) { Level level = context.getPlayer().level(); if (level instanceof ServerLevel serverLevel) { TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> TardisPlayerInfo.get(context.getPlayer()).ifPresent(tardisInfo -> - tardisInfo.setupPlayerForInspection(player, tardisLevelOperator, tardisLevelOperator.getPilotingManager().isTakingOff() ? tardisLevelOperator.getPilotingManager().getCurrentLocation() : tardisLevelOperator.getPilotingManager().getTargetLocation(), !tardisLevelOperator.getPilotingManager().isTakingOff()) + tardisInfo.startShellView(player, tardisLevelOperator, tardisLevelOperator.getPilotingManager().isTakingOff() ? tardisLevelOperator.getPilotingManager().getCurrentLocation() : tardisLevelOperator.getPilotingManager().getTargetLocation(), tardisLevelOperator.getPilotingManager().isInFlight()) )); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SExitTardisView.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SExitTardisView.java index cbd5a65ef..0dfa34e01 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SExitTardisView.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/C2SExitTardisView.java @@ -46,7 +46,7 @@ public void handle(MessageContext context) { ServerLevel tardisLevel = Platform.getServer().getLevel(key); if (tardisLevel != null) { TardisLevelOperator.get(tardisLevel).ifPresent(tardisLevelOperator -> { - tardisInfo.endPlayerForInspection(player); + tardisInfo.endShellView(player); }); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/ExitTardisViewMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/ExitTardisViewMessage.java new file mode 100644 index 000000000..c2ae97c76 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/player/ExitTardisViewMessage.java @@ -0,0 +1,56 @@ +package whocraft.tardis_refined.common.network.messages.player; + +import net.minecraft.core.registries.Registries; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.common.capability.player.TardisPlayerInfo; +import whocraft.tardis_refined.common.capability.tardis.TardisLevelOperator; +import whocraft.tardis_refined.common.network.MessageC2S; +import whocraft.tardis_refined.common.network.MessageContext; +import whocraft.tardis_refined.common.network.MessageType; +import whocraft.tardis_refined.common.network.TardisNetwork; +import whocraft.tardis_refined.common.util.Platform; + +public class ExitTardisViewMessage extends MessageC2S { + + public ExitTardisViewMessage() { + } + + public ExitTardisViewMessage(FriendlyByteBuf buf) { + } + + @Override + public @NotNull MessageType getType() { + return TardisNetwork.TARDIS_EXIT; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + + } + + @Override + public void handle(MessageContext context) { + ServerPlayer player = context.getPlayer(); + + TardisPlayerInfo.get(player).ifPresent(tardisInfo -> { + if (tardisInfo.isViewingTardis()) { + ResourceKey key = ResourceKey.create(Registries.DIMENSION, + new ResourceLocation(TardisRefined.MODID, tardisInfo.getViewedTardis().toString())); + ServerLevel tardisLevel = Platform.getServer().getLevel(key); + if (tardisLevel != null) { + TardisLevelOperator.get(tardisLevel).ifPresent(tardisLevelOperator -> { + tardisInfo.endShellView(player); + }); + } + } + }); + + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/DimensionalControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/DimensionalControl.java index 10bed7957..0f3268095 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/DimensionalControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/flight/DimensionalControl.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Predicate; import static net.minecraft.world.level.Level.OVERWORLD; @@ -33,15 +34,17 @@ public DimensionalControl(ResourceLocation id, String langId) { private List getAllowedDimensions(TardisLevelOperator tardisLevelOperator) { var filteredDimensions = new ArrayList(); + var filteredLevels = Platform.getServer().getAllLevels(); + filteredLevels.forEach(x -> { if (tardisLevelOperator.getProgressionManager().isLevelDiscovered(x.dimension())) { filteredDimensions.add(x); } }); - return filteredDimensions; + return filteredDimensions.stream().filter(serverLevel -> DimensionUtil.isAllowedDimension(serverLevel.dimension())).toList(); } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/common/util/DimensionUtil.java b/common/src/main/java/whocraft/tardis_refined/common/util/DimensionUtil.java index da4f0d847..f04548c0f 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/util/DimensionUtil.java +++ b/common/src/main/java/whocraft/tardis_refined/common/util/DimensionUtil.java @@ -6,6 +6,7 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import whocraft.tardis_refined.TRConfig; +import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.registry.TRDimensionTypes; import java.util.Set; @@ -13,10 +14,11 @@ public class DimensionUtil { public static boolean isAllowedDimension(ResourceKey level) { + String namespace = level.location().getNamespace(); + String location = level.location().toString(); var bannedDimensions = TRConfig.SERVER.BANNED_DIMENSIONS.get(); - return !level.location().getNamespace().toString().contains("tardis") && !bannedDimensions.contains(level.location().toString()); + return !namespace.contains("immersive_portals") && !namespace.contains(TardisRefined.MODID) && !bannedDimensions.contains(location); } - public static Set> getTardisLevels(MinecraftServer server) { Set> set = Sets.newHashSet(); for (ServerLevel level : server.getAllLevels()) { diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java index 8892d2474..72c829525 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/events/ModEvents.java @@ -1,6 +1,5 @@ package whocraft.tardis_refined.fabric.events; -import com.google.gson.JsonObject; import com.mojang.blaze3d.vertex.DefaultVertexFormat; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry; @@ -20,11 +19,9 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionResult; import net.minecraft.world.level.Level; -import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.client.TRItemColouring; import whocraft.tardis_refined.client.TRShaders; import whocraft.tardis_refined.client.TardisClientLogic; -import whocraft.tardis_refined.client.model.pallidium.BedrockModelUtil; import whocraft.tardis_refined.client.overlays.ExteriorViewOverlay; import whocraft.tardis_refined.client.overlays.GravityOverlay; import whocraft.tardis_refined.client.overlays.VortexOverlay; @@ -43,11 +40,6 @@ import whocraft.tardis_refined.registry.TRItemRegistry; import whocraft.tardis_refined.registry.TRPointOfInterestTypes; -import java.io.BufferedWriter; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Supplier; @@ -79,7 +71,7 @@ public static void addCommonEvents() { ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> { ServerPlayer player = handler.getPlayer(); TardisPlayerInfo.get(player).ifPresent(tardisPlayerInfo -> { - tardisPlayerInfo.endPlayerForInspection(player); + tardisPlayerInfo.endShellView(player); }); }); diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java index c2934759b..4942f248b 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java @@ -52,7 +52,7 @@ public static void onPlayerLoggedOut(PlayerEvent.PlayerLoggedOutEvent playerLogg Player player = playerLoggedOutEvent.getEntity(); if (player instanceof ServerPlayer serverPlayer) { TardisPlayerInfo.get(player).ifPresent(tardisPlayerInfo -> { - tardisPlayerInfo.endPlayerForInspection(serverPlayer); + tardisPlayerInfo.endShellView(serverPlayer); }); } }