From f8357a059c3a1d834f60a1d29422035729661b94 Mon Sep 17 00:00:00 2001 From: Craig Date: Mon, 19 Aug 2024 16:39:24 +0100 Subject: [PATCH] - Fixes 50s unfinished commit - Fixes Forge Rendering being weird at certain angles - Bumped Version --- changelog.md | 65 +++++++++++++++++-- .../console/GlobalConsoleRenderer.java | 5 +- .../device/ConsoleConfigurationRenderer.java | 6 +- .../door/GlobalDoorBlockEntity.java | 23 ++++--- .../control/ship/ToggleDoorControl.java | 3 +- .../tardis/manager/TardisPilotingManager.java | 6 +- .../mixin/forge/ClientHooksMixin.java | 20 ++++++ .../main/resources/tardis_refined.mixins.json | 1 + gradle.properties | 2 +- 9 files changed, 108 insertions(+), 23 deletions(-) create mode 100644 forge/src/main/java/whocraft/tardis_refined/mixin/forge/ClientHooksMixin.java diff --git a/changelog.md b/changelog.md index d670eca72..831213650 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,64 @@ -# Version 2.0.6 +# Version 2.0.7 ![TARDIS Refined](https://wiki.tardisrefined.net/TARDIS-Refined-Wiki/tardis_refined_v2.png) -## Changes -- Added 50x speed upgrade +## New Features + +- Datapack Console Patterns and Shell Patterns can now define the sounds used by the Tardis. + - Console Patterns can define Left Click and Right Click sounds for Generic interactions, as well as Throttle and + Handbrake specific sounds + - Shell Patterns can define Door Unlock/Lock, Door Open/Close sounds. + +**Note:** These additions are optional fields, meaning all existing Pattern datapacks will not need to be updated. + +## Gameplay Fixes + +- Fixes left clicking controls during flight dance activating the control's function unexpectedly. E.g. Left clicking X + Coordinate control actually changing the X coordinate when re-aligning a control +- Fixed blocks causing player's hand to swing twice in every interaction. Caused by the wrong InteractionResult being + used on the serverside. +- Fixes Dimensions not being registered to the server, causing the world to not exist upon reloading the save. This also + increases performance for world loading as it means the server doesn't need to create a new world everytime a player + enters a Tardis after server restart (for multiplayer) or logging out then reopening a save file (singleplayer). +- Comprehensive fix for Root Shell not updating its `OPEN` state during terraforming (#299). This has been achieved by + cleaning up and unifying door update logic as well as patching the desktop regeneration logic. +- Attempting to land a Tardis on a block where there are no valid positions caused an infinite crash loop #309 +- Fixes issue where (Neo) Forge rendering would cause Consoles and Shells to stop rendering at certain angles + +## Technical Debt +- Cleaned up all Tardis manager classes and implemented common methods stuch as ``tick(ServerLevel level)``, + ``saveData`` and ``loadData`` +- Unified door closing and door locking logic by implementing the ``TardisInternalDoor`` interface on + ``AbstractDoorBlockEntity`` instead of some classes sometimes using the Blockstate property, and other classes + sometimes using the BlockState properties directly. + - Before this cleanup the codebase logic would continue to become even more inconsistent, difficult to maintain, test, + debug and enable poor practices to slip in. + - Example: Forgetting to update the exterior shell but not the internal door, and vice versa. +- Unified shell open and locking logic by using ``ExteriorShell`` interface which was introduced early on in the 1.19,2 + development but was hidden in a random package and never referenced again. +- Relocated ``ExteriorShell`` interface to another package so that it's more noticeable +- Moved desktop generation logic into a method for ease of viewing +- Reordered some getter and setter methods in classes for ease of viewing +- Fixed teleportation via Tardis doors not using the correct facing, requiring us to call `Direction#getOpposite` in + many places to compensate. Previously it created great difficulty to debug teleportation issues. +- Removed `AbstractDoorBlockEntity#isLocked` in favour of a Blockstate Property. This allows the locking logic to use + the BlockState Property to be consistent with the Exterior Shell. +- Enhanced ``TardisExteriorManager#setOrUpdateExteriorBlock`` to not be as verbose with the parameters. Removed the + boolean field, and added a default method called ``TardisExteriorManager.placeExteriorBlockForLanding`` which + implements the correct logic for when the Tardis is landing, and thus requires a new Shell blockstate instance to be + created. +- Exterior Shell updates using duplicate implementations across multiple classes, include `AestheticHandler`, + `TardisExteriorManager` and `TardisInteriorManager`. This is now unified in `TardisLevelOperator` for ease of + maintenance. + +## API Changes + +- Added new events for addon mods - `LockDoor` and `UnlockDoor`, which are fired after the internal door and exterior + shell blocks are locked/unlocked +- Made `OpenDoor` and `CloseDoor` events fire after doors have been updated. Previously it fired after the internal door + updates, but before the exterior shell updated. This would have caused some issues when addon mods subscribe to these + events because it would mean addon mods are applying logic before the exterior shell door has closed, which can have + unintended consequences. +- Added `ShellChangeSource`, an object to identify why a Shell was updated. This provides additional data to use for + differentiate logic between updating shell from landing the Tardis to when the shell is updated during terraforming -## Fixes -- Fixed Speed Upgrades not correctly applying \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java index 53e8ebb10..c02038d0e 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/console/GlobalConsoleRenderer.java @@ -20,8 +20,6 @@ import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatterns; -import java.util.Objects; - public class GlobalConsoleRenderer implements BlockEntityRenderer, BlockEntityRendererProvider { private static final Vec3 crystalHolo = new Vec3(0.3f, -1.725, 0.655); @@ -105,5 +103,6 @@ public boolean shouldRenderOffScreen(GlobalConsoleBlockEntity blockEntity) { public BlockEntityRenderer create(BlockEntityRendererProvider.Context context) { return new GlobalConsoleRenderer(context); } - + + } diff --git a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java index fd8bc6ec8..69ec8a5c3 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java +++ b/common/src/main/java/whocraft/tardis_refined/client/renderer/blockentity/device/ConsoleConfigurationRenderer.java @@ -15,7 +15,6 @@ import whocraft.tardis_refined.common.block.door.GlobalDoorBlock; import whocraft.tardis_refined.common.blockentity.console.GlobalConsoleBlockEntity; import whocraft.tardis_refined.common.blockentity.device.ConsoleConfigurationBlockEntity; -import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; public class ConsoleConfigurationRenderer implements BlockEntityRenderer, BlockEntityRendererProvider { @@ -59,4 +58,9 @@ public void render(ConsoleConfigurationBlockEntity blockEntity, float partialTic poseStack.popPose(); } + + @Override + public boolean shouldRenderOffScreen(ConsoleConfigurationBlockEntity blockEntity) { + return true; + } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/GlobalDoorBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/GlobalDoorBlockEntity.java index 919ac5d3b..248996ea5 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/GlobalDoorBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/GlobalDoorBlockEntity.java @@ -14,11 +14,11 @@ import net.minecraft.world.level.block.state.BlockState; import org.jetbrains.annotations.Nullable; import whocraft.tardis_refined.common.capability.TardisLevelOperator; -import whocraft.tardis_refined.patterns.sound.ConfiguredSound; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; import whocraft.tardis_refined.constants.NbtConstants; import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatterns; +import whocraft.tardis_refined.patterns.sound.ConfiguredSound; import whocraft.tardis_refined.registry.TRBlockEntityRegistry; public class GlobalDoorBlockEntity extends InternalDoorBlockEntity { @@ -138,10 +138,13 @@ public void playDoorCloseSound(boolean closeDoor) { ShellPattern pattern = this.pattern(); if (pattern != null){ Level currentLevel = this.getLevel(); - ConfiguredSound configuredSound = pattern.soundProfile().getDoorClose(); - if (configuredSound != null){ - currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume()); - } + + pattern.soundProfile().ifPresent(shellSoundProfile -> { + ConfiguredSound configuredSound = shellSoundProfile.getDoorClose(); + if (configuredSound != null) { + currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume()); + } + }); } } @@ -150,10 +153,12 @@ public void playDoorLockedSound(boolean lockDoor) { ShellPattern pattern = this.pattern(); if (pattern != null){ Level currentLevel = this.getLevel(); - ConfiguredSound configuredSound = pattern.soundProfile().getDoorLocked(); - if (configuredSound != null){ - currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume()); - } + pattern.soundProfile().ifPresent(shellSoundProfile -> { + ConfiguredSound configuredSound = shellSoundProfile.getDoorClose(); + if (configuredSound != null) { + currentLevel.playSound(null, this.getBlockPos(), configuredSound.getSoundEvent(), SoundSource.BLOCKS, configuredSound.getPitch(), configuredSound.getVolume()); + } + }); } } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/ToggleDoorControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/ToggleDoorControl.java index e78e9d4e0..57a970078 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/ToggleDoorControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/ToggleDoorControl.java @@ -11,10 +11,9 @@ import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; -import whocraft.tardis_refined.patterns.sound.ConfiguredSound; -import whocraft.tardis_refined.common.tardis.themes.console.sound.PitchedSound; import whocraft.tardis_refined.common.util.PlayerUtil; import whocraft.tardis_refined.constants.ModMessages; +import whocraft.tardis_refined.patterns.sound.ConfiguredSound; public class ToggleDoorControl extends Control { public ToggleDoorControl(ResourceLocation id) { diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java index e2bf3f0e2..eb76cb1fc 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisPilotingManager.java @@ -27,10 +27,9 @@ import whocraft.tardis_refined.common.capability.upgrades.SpeedUpgrade; import whocraft.tardis_refined.common.capability.upgrades.Upgrade; import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler; -import whocraft.tardis_refined.common.util.LevelHelper; -import whocraft.tardis_refined.registry.TRUpgrades; import whocraft.tardis_refined.common.tardis.TardisArchitectureHandler; import whocraft.tardis_refined.common.tardis.TardisNavLocation; +import whocraft.tardis_refined.common.util.LevelHelper; import whocraft.tardis_refined.common.util.PlayerUtil; import whocraft.tardis_refined.common.util.TardisHelper; import whocraft.tardis_refined.constants.ModMessages; @@ -301,7 +300,9 @@ private void checkThrottleStatesForFlight() { } private void onCrashCooldownTick() { + ticksSinceCrash++; + // After 10 minutes if (ticksSinceCrash >= TICKS_COOLDOWN_MAX) { this.canUseControls = true; @@ -310,6 +311,7 @@ private void onCrashCooldownTick() { } } + /** * Load the fast return into the target location. * diff --git a/forge/src/main/java/whocraft/tardis_refined/mixin/forge/ClientHooksMixin.java b/forge/src/main/java/whocraft/tardis_refined/mixin/forge/ClientHooksMixin.java new file mode 100644 index 000000000..adae5cc45 --- /dev/null +++ b/forge/src/main/java/whocraft/tardis_refined/mixin/forge/ClientHooksMixin.java @@ -0,0 +1,20 @@ +package whocraft.tardis_refined.mixin.forge; + +import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.neoforged.neoforge.client.ClientHooks; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(ClientHooks.class) +public class ClientHooksMixin { + + @Inject(method = "isBlockEntityRendererVisible(Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/client/renderer/culling/Frustum;)Z", at = @At("HEAD"), cancellable = true) + private static void getRenderBoundingBox(BlockEntityRenderDispatcher dispatcher, BlockEntity blockEntity, Frustum frustum, CallbackInfoReturnable cir) { + cir.setReturnValue(blockEntity.getClass().getPackageName().contains("whocraft.tardis_refined")); + } + +} diff --git a/forge/src/main/resources/tardis_refined.mixins.json b/forge/src/main/resources/tardis_refined.mixins.json index 9a81f5a1c..085d1ac46 100644 --- a/forge/src/main/resources/tardis_refined.mixins.json +++ b/forge/src/main/resources/tardis_refined.mixins.json @@ -4,6 +4,7 @@ "package": "whocraft.tardis_refined.mixin.forge", "compatibilityLevel": "JAVA_17", "mixins": [ + "ClientHooksMixin" ], "client": [ ], diff --git a/gradle.properties b/gradle.properties index 192dfeeef..dcb740f70 100644 --- a/gradle.properties +++ b/gradle.properties @@ -46,7 +46,7 @@ neoforge_data_pack_format=18 ##Mod Information #Common Mod Information -mod_version=2.0.6 +mod_version=2.0.7 license=https://github.com/Whocraft/TardisRefined/blob/minecraft/1.20/LICENSE.MD credits=Commoble, Lucraft, starray1000000, Monsterwaill, TheJudge, LoxiGoose mod_authors=CommandrMoose / River, Jeryn99, Magic Man, ILikePandas, Jacob K, 50ap5ud5