diff --git a/common/src/main/java/whocraft/tardis_refined/TardisRefined.java b/common/src/main/java/whocraft/tardis_refined/TardisRefined.java index 1ca427958..34cc134d0 100644 --- a/common/src/main/java/whocraft/tardis_refined/TardisRefined.java +++ b/common/src/main/java/whocraft/tardis_refined/TardisRefined.java @@ -9,10 +9,12 @@ import org.slf4j.Logger; import whocraft.tardis_refined.client.TRParticles; import whocraft.tardis_refined.common.capability.upgrades.Upgrades; +import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.network.TardisNetwork; -import whocraft.tardis_refined.common.network.messages.SyncConsolePatternsMessage; -import whocraft.tardis_refined.common.network.messages.SyncDesktopsMessage; -import whocraft.tardis_refined.common.network.messages.SyncShellPatternsMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncConsolePatternsMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncDesktopsMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncHumsMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncShellPatternsMessage; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; @@ -58,10 +60,12 @@ public static void init() { TardisDesktops.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncDesktopsMessage::new); ConsolePatterns.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncConsolePatternsMessage::new); ShellPatterns.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncShellPatternsMessage::new); + TardisHums.getReloadListener().setSyncPacket(TardisNetwork.NETWORK, SyncHumsMessage::new); /* Need to register a default list of entries because on Fabric Cardinal Components classloads the TardisClientData class early on, before datapack entries have been added. We will use these as fallback values when looking up patterns. */ ConsolePatterns.registerDefaultPatterns(); ShellPatterns.registerDefaultPatterns(); + TardisHums.registerDefaultHums(); } } \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java b/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java index 61ee75717..6199443a8 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java +++ b/common/src/main/java/whocraft/tardis_refined/client/ScreenHandler.java @@ -5,9 +5,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.Level; import whocraft.tardis_refined.client.screen.CancelDesktopScreen; import whocraft.tardis_refined.client.screen.MonitorScreen; +import whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen; import whocraft.tardis_refined.client.screen.upgrades.UpgradesScreen; import whocraft.tardis_refined.client.screen.waypoints.CoordInputType; import whocraft.tardis_refined.client.screen.waypoints.WaypointListScreen; @@ -60,4 +62,8 @@ public static void displayUpgradesScreen(CompoundTag upgradeTag) { Minecraft.getInstance().setScreen(new UpgradesScreen(upgradeHandlerClient)); } } + + public static void openShellSelection(ResourceLocation currentShell) { + Minecraft.getInstance().setScreen(new ShellSelectionScreen(currentShell)); + } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/TardisClientData.java b/common/src/main/java/whocraft/tardis_refined/client/TardisClientData.java index 091efed29..49884da08 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/TardisClientData.java +++ b/common/src/main/java/whocraft/tardis_refined/client/TardisClientData.java @@ -3,23 +3,33 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import net.minecraft.Util; import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.sounds.SoundManager; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; import net.minecraft.util.RandomSource; import net.minecraft.world.entity.AnimationState; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import whocraft.tardis_refined.client.sounds.HumSoundManager; import whocraft.tardis_refined.client.sounds.LoopingSound; -import whocraft.tardis_refined.common.network.messages.SyncTardisClientDataMessage; +import whocraft.tardis_refined.client.sounds.QuickSimpleSound; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +import whocraft.tardis_refined.common.network.messages.sync.SyncTardisClientDataMessage; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; +import whocraft.tardis_refined.constants.NbtConstants; import whocraft.tardis_refined.patterns.ShellPatterns; import whocraft.tardis_refined.registry.DimensionTypes; +import java.util.List; import java.util.Map; import static whocraft.tardis_refined.common.util.TardisHelper.isInArsArea; @@ -51,13 +61,28 @@ public ResourceKey getLevelKey() { private boolean isCrashing = false; private boolean isOnCooldown = false; private float flightShakeScale = 0; + + //Not saved to disk, no real reason to be + private int nextAmbientNoiseCall = 40; + + private ResourceLocation shellTheme = ShellTheme.FACTORY.getId(); private ResourceLocation shellPattern = ShellPatterns.DEFAULT.id(); + private HumEntry humEntry = TardisHums.getDefaultHum(); + public ResourceLocation getShellTheme() { return shellTheme; } + public HumEntry getHumEntry() { + return humEntry; + } + + public void setHumEntry(HumEntry humEntry) { + this.humEntry = humEntry; + } + public void setShellTheme(ResourceLocation shellTheme) { this.shellTheme = shellTheme; } @@ -155,6 +180,8 @@ public CompoundTag serializeNBT() { compoundTag.putString("shellTheme", shellTheme.toString()); compoundTag.putString("shellPattern", shellPattern.toString()); + compoundTag.putString(NbtConstants.TARDIS_CURRENT_HUM, humEntry.getIdentifier().toString()); + return compoundTag; } @@ -176,6 +203,7 @@ public void deserializeNBT(CompoundTag compoundTag) { shellTheme = new ResourceLocation(compoundTag.getString("shellTheme")); shellPattern = new ResourceLocation(compoundTag.getString("shellPattern")); + setHumEntry(TardisHums.getHumById(new ResourceLocation(compoundTag.getString(NbtConstants.TARDIS_CURRENT_HUM)))); } /** @@ -204,6 +232,10 @@ public void tickClientside() { if (Minecraft.getInstance().player.level().dimensionTypeId() == DimensionTypes.TARDIS) { + + ClientLevel tardisLevel = Minecraft.getInstance().level; + boolean isThisTardis = levelKey == tardisLevel.dimension(); + createWorldAmbience(Minecraft.getInstance().player); @@ -218,26 +250,47 @@ public void tickClientside() { } } - if(!soundManager.isActive(LoopingSound.HUM_TEST)){ - soundManager.play(LoopingSound.HUM_TEST); + + if (isThisTardis && humEntry != null && !humEntry.getSound().toString().equals(HumSoundManager.getCurrentRawSound().getLocation().toString()) || !soundManager.isActive(HumSoundManager.getCurrentSound())) { + HumSoundManager.playHum(SoundEvent.createVariableRangeEvent(humEntry.getSound())); } - } + if (isThisTardis && tardisLevel.getGameTime() % nextAmbientNoiseCall == 0) { + nextAmbientNoiseCall = tardisLevel.random.nextInt(400, 2400); + List ambientSounds = humEntry.getAmbientSounds(); + if (!ambientSounds.isEmpty()) { + LocalPlayer player = Minecraft.getInstance().player; + RandomSource randomSource = tardisLevel.random; - if (LoopingSound.shouldMinecraftMusicStop(soundManager)) { - Minecraft.getInstance().getMusicManager().stopPlaying(); - } + ResourceLocation randomSoundLocation = ambientSounds.get(randomSource.nextInt(ambientSounds.size())); + SoundEvent randomSoundEvent = SoundEvent.createVariableRangeEvent(randomSoundLocation); + + QuickSimpleSound simpleSoundInstance = new QuickSimpleSound(randomSoundEvent, SoundSource.AMBIENT); + simpleSoundInstance.setVolume(0.3F); + double randomX = player.getX() + (randomSource.nextDouble() - 0.5) * 100; + double randomY = player.getY() + (randomSource.nextDouble() - 0.5) * 100; + double randomZ = player.getZ() + (randomSource.nextDouble() - 0.5) * 100; - // Responsible for screen-shake. Not sure of a better solution at this point in time. - if (isInDangerZone || isCrashing) { - if (Minecraft.getInstance().player.level().dimension() == levelKey) { - var player = Minecraft.getInstance().player; - player.setXRot(player.getXRot() + (player.getRandom().nextFloat() - 0.5f) * flightShakeScale); - player.setYHeadRot(player.getYHeadRot() + (player.getRandom().nextFloat() - 0.5f) * flightShakeScale); + simpleSoundInstance.setLocation(new Vec3(randomX, randomY, randomZ)); + Minecraft.getInstance().getSoundManager().play(simpleSoundInstance); + } } - } + if (LoopingSound.shouldMinecraftMusicStop(soundManager)) { + Minecraft.getInstance().getMusicManager().stopPlaying(); + } + + + // Responsible for screen-shake. Not sure of a better solution at this point in time. + if (isInDangerZone || isCrashing) { + if (Minecraft.getInstance().player.level().dimension() == levelKey) { + var player = Minecraft.getInstance().player; + player.setXRot(player.getXRot() + (player.getRandom().nextFloat() - 0.5f) * flightShakeScale); + player.setYHeadRot(player.getYHeadRot() + (player.getRandom().nextFloat() - 0.5f) * flightShakeScale); + } + } + } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java index 1233cb1cc..97a91773c 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/MonitorScreen.java @@ -11,11 +11,12 @@ import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; import whocraft.tardis_refined.client.screen.components.SelectionListEntry; import whocraft.tardis_refined.client.screen.selections.DesktopSelectionScreen; +import whocraft.tardis_refined.client.screen.selections.HumSelectionScreen; import whocraft.tardis_refined.client.screen.selections.SelectionScreen; -import whocraft.tardis_refined.client.screen.selections.ShellSelectionScreen; import whocraft.tardis_refined.client.screen.waypoints.CoordInputType; import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler; import whocraft.tardis_refined.common.capability.upgrades.Upgrades; +import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection; import whocraft.tardis_refined.common.network.messages.waypoints.C2SOpenCoordinatesDisplayMessage; import whocraft.tardis_refined.common.network.messages.waypoints.RequestWaypointsMessage; import whocraft.tardis_refined.common.tardis.TardisNavLocation; @@ -71,7 +72,7 @@ public GenericMonitorSelectionList createSelectionList() { selectionList.setRenderBackground(false); if(Upgrades.CHAMELEON_CIRCUIT_SYSTEM.get().isUnlocked(upgradeHandler)){ - selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_EXTERNAL_SHELL), entry -> Minecraft.getInstance().setScreen(new ShellSelectionScreen()), leftPos)); + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_EXTERNAL_SHELL), entry -> new C2SRequestShellSelection().send(), leftPos)); } if(Upgrades.INSIDE_ARCHITECTURE.get().isUnlocked(upgradeHandler)){ @@ -87,6 +88,9 @@ public GenericMonitorSelectionList createSelectionList() { selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_UPLOAD_COORDS), entry -> new C2SOpenCoordinatesDisplayMessage(CoordInputType.TRAVEL).send(), leftPos)); } + selectionList.children().add(new SelectionListEntry(Component.translatable(ModMessages.UI_MONITOR_SELECT_HUM), entry -> Minecraft.getInstance().setScreen(new HumSelectionScreen()), leftPos)); + + if(selectionList.children().isEmpty()){ noUpgrades = true; } diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java new file mode 100644 index 000000000..a10a67cee --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/HumSelectionScreen.java @@ -0,0 +1,140 @@ +package whocraft.tardis_refined.client.screen.selections; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.components.ObjectSelectionList; +import net.minecraft.client.renderer.GameRenderer; +import net.minecraft.client.resources.sounds.SimpleSoundInstance; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.client.screen.components.GenericMonitorSelectionList; +import whocraft.tardis_refined.client.screen.components.SelectionListEntry; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +import whocraft.tardis_refined.common.network.messages.hums.ChangeHumMessage; +import whocraft.tardis_refined.common.util.MiscHelper; +import whocraft.tardis_refined.registry.SoundRegistry; + +import java.io.StringReader; + +public class HumSelectionScreen extends SelectionScreen { + private HumEntry currentHumEntry; + + + protected int imageWidth = 256; + protected int imageHeight = 173; + private int leftPos, topPos; + + public static ResourceLocation MONITOR_TEXTURE = new ResourceLocation(TardisRefined.MODID, "textures/gui/monitor.png"); + + + public HumSelectionScreen() { + super(Component.translatable("")); + } + + @Override + public void addSubmitButton(int x, int y) { + super.addSubmitButton(x, y); + } + + @Override + public boolean isPauseScreen() { + return false; + } + + @Override + protected void init() { + this.setEvents(() -> { + HumSelectionScreen.selectHum(currentHumEntry); + }, () -> { + Minecraft.getInstance().setScreen(null); + }); + this.currentHumEntry = grabHum(); + + this.leftPos = (this.width - this.imageWidth) / 2; + this.topPos = (this.height - this.imageHeight) / 2; + + //Super method already creates the list, we don't need to create it a second time. + super.init(); + + addSubmitButton(width / 2 + 85, (height) / 2 + 35); + addCancelButton(width / 2 - 105, (height) / 2 + 35); + } + + @Override + public boolean mouseClicked(double d, double e, int i) { + return super.mouseClicked(d, e, i); + } + + private HumEntry grabHum() { + for (HumEntry humEntry : TardisHums.getRegistry().values()) { + return humEntry; + } + return null; + } + + @Override + public void render(GuiGraphics guiGraphics, int i, int j, float f) { + this.renderTransparentBackground(guiGraphics); + + + /*Render Back drop*/ + RenderSystem.setShader(GameRenderer::getPositionTexShader); + guiGraphics.blit(MONITOR_TEXTURE, leftPos, topPos, 0, 0, imageWidth, imageHeight); + + + super.render(guiGraphics, i, j, f); + + } + + public static void selectHum(HumEntry theme) { + new ChangeHumMessage(Minecraft.getInstance().player.level().dimension(), theme).send(); + Minecraft.getInstance().setScreen(null); + } + + @Override + public void renderBackground(GuiGraphics guiGraphics, int i, int j, float f) { + + } + + @Override + public Component getSelectedDisplayName() { + return Component.Serializer.fromJson(currentHumEntry.getName()); + } + + @Override + public ObjectSelectionList createSelectionList() { + int leftPos = this.width / 2 - 75; + GenericMonitorSelectionList selectionList = new GenericMonitorSelectionList<>(this.minecraft, 100, 80, leftPos, this.topPos + 30, this.topPos + this.imageHeight - 60, 12); + selectionList.setRenderBackground(false); + + for (HumEntry humEntry : TardisHums.getRegistry().values()) { + Component name = Component.literal(MiscHelper.getCleanName(humEntry.getIdentifier().getPath())); + + // Check for if the tellraw name is incomplete, or fails to pass. + try { + var json = Component.Serializer.fromJson(new StringReader(humEntry.getName()).toString()); + name = json; + } catch (Exception ex) { + TardisRefined.LOGGER.error("Could not process Name for datapack desktop " + humEntry.getIdentifier().toString()); + } + + selectionList.children().add(new SelectionListEntry(name, (entry) -> { + // previousImage = humEntry.getPreviewTexture(); + this.currentHumEntry = humEntry; + + for (Object child : selectionList.children()) { + if (child instanceof SelectionListEntry current) { + current.setChecked(false); + } + } + entry.setChecked(true); + }, leftPos)); + } + + return selectionList; + } + +} \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java index b1a159646..8775347d3 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/selections/ShellSelectionScreen.java @@ -55,10 +55,11 @@ public class ShellSelectionScreen extends SelectionScreen { private Button patternButton; public static GlobalShellBlockEntity globalShellBlockEntity; - public ShellSelectionScreen() { + public ShellSelectionScreen(ResourceLocation currentShellTheme) { super(Component.translatable(ModMessages.UI_SHELL_SELECTION)); this.themeList = ShellTheme.SHELL_THEME_REGISTRY.keySet().stream().toList(); generateDummyGlobalShell(); + this.currentShellTheme = currentShellTheme; } @@ -82,7 +83,9 @@ protected void init() { }, () -> { Minecraft.getInstance().setScreen(null); }); - this.currentShellTheme = this.themeList.get(0); + if (currentShellTheme == null) { + this.currentShellTheme = this.themeList.get(0); + } this.patternCollection = ShellPatterns.getPatternCollectionForTheme(this.currentShellTheme); this.pattern = this.patternCollection.get(0); @@ -189,7 +192,7 @@ public GenericMonitorSelectionList createSelectionList() { for (Holder.Reference shellTheme : ShellTheme.SHELL_THEME_REGISTRY.holders().toList()) { ShellTheme theme = shellTheme.value(); ResourceLocation shellThemeId = shellTheme.key().location(); - selectionList.children().add(new SelectionListEntry(theme.getDisplayName(), (entry) -> { + SelectionListEntry selectionListEntry = new SelectionListEntry(theme.getDisplayName(), (entry) -> { this.currentShellTheme = shellThemeId; for (Object child : selectionList.children()) { @@ -210,7 +213,13 @@ public GenericMonitorSelectionList createSelectionList() { age = 0; entry.setChecked(true); - }, leftPos)); + }, leftPos); + + if (currentShellTheme.toString().equals(shellThemeId.toString())) { + selectionListEntry.setChecked(true); + } + + selectionList.children().add(selectionListEntry); } return selectionList; diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/BuyUpgradeScreen.java b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/BuyUpgradeScreen.java index 1532c4e7e..a5fdbd730 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/BuyUpgradeScreen.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/BuyUpgradeScreen.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.screens.Screen; @@ -12,7 +11,6 @@ import net.minecraft.util.FormattedCharSequence; import whocraft.tardis_refined.client.screen.components.BackgroundlessButton; import whocraft.tardis_refined.common.capability.upgrades.Upgrade; -import whocraft.tardis_refined.common.network.messages.upgrades.C2SDisplayUpgradeScreen; import whocraft.tardis_refined.common.network.messages.upgrades.UnlockUpgradeMessage; import whocraft.tardis_refined.constants.ModMessages; @@ -47,7 +45,6 @@ protected void init() { new UnlockUpgradeMessage(this.upgrade).send(); this.parentScreen.closeOverlayScreen(); Objects.requireNonNull(Objects.requireNonNull(this.minecraft).player).playSound(SoundEvents.PLAYER_LEVELUP, 1F, 1F); - new C2SDisplayUpgradeScreen(Minecraft.getInstance().level.dimension()).send(); }).bounds(guiLeft + 23, guiTop + 33, 54, 20).build(); button.active = this.available; this.addRenderableWidget(button); diff --git a/common/src/main/java/whocraft/tardis_refined/client/sounds/HumSoundManager.java b/common/src/main/java/whocraft/tardis_refined/client/sounds/HumSoundManager.java new file mode 100644 index 000000000..c2d774b3b --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/sounds/HumSoundManager.java @@ -0,0 +1,48 @@ +package whocraft.tardis_refined.client.sounds; + +import net.minecraft.client.Minecraft; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; + +public class HumSoundManager { + private static final Minecraft MC = Minecraft.getInstance(); + + private static LoopingHumSound currentSound; + private static SoundEvent currentRawSound = SoundEvents.CAT_DEATH; + + public static void playHum(SoundEvent soundEvent) { + stopCurrentHum(); + LoopingHumSound newSound = createSound(soundEvent); + currentSound = newSound; + currentRawSound = soundEvent; + MC.getSoundManager().play(newSound); + } + + public static LoopingHumSound getCurrentSound() { + return currentSound; + } + + public static void setCurrentSound(LoopingHumSound currentSound) { + HumSoundManager.currentSound = currentSound; + } + + public static SoundEvent getCurrentRawSound() { + return currentRawSound; + } + + public static void setCurrentRawSound(SoundEvent currentRawSound) { + HumSoundManager.currentRawSound = currentRawSound; + } + + private static void stopCurrentHum() { + if (currentSound != null) { + MC.getSoundManager().stop(currentSound); + currentSound = null; + } + } + + private static LoopingHumSound createSound(SoundEvent soundEvent) { + return new LoopingHumSound(soundEvent, SoundSource.AMBIENT); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingHumSound.java b/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingHumSound.java new file mode 100644 index 000000000..6082eefce --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingHumSound.java @@ -0,0 +1,49 @@ +package whocraft.tardis_refined.client.sounds; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.sounds.SoundManager; +import net.minecraft.client.sounds.WeighedSoundEvents; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import org.jetbrains.annotations.NotNull; + +public class LoopingHumSound extends LoopingSound{ + private SoundEvent soundEvent; + + public LoopingHumSound(@NotNull SoundEvent soundEvent, SoundSource soundSource) { + super(soundEvent, soundSource); + this.soundEvent = soundEvent; + } + + public void setSoundEvent(SoundEvent soundEvent) { + this.soundEvent = soundEvent; + } + + @Override + public void tick() { + super.tick(); + volume = 0.10F; + if(Minecraft.getInstance().player != null){ + setLocation(Minecraft.getInstance().player.position()); + } + } + + // So, I don't like this. But it is necessary else we are making another Mixin, which isn't a bad thing but better to avoid + // You need to call setSoundEvent and then call resolve, it's...yeah ok there's no excusing this + @Override + public WeighedSoundEvents resolve(SoundManager soundManager) { + if (this.location.equals(SoundManager.INTENTIONALLY_EMPTY_SOUND_LOCATION)) { + this.sound = SoundManager.INTENTIONALLY_EMPTY_SOUND; + return SoundManager.INTENTIONALLY_EMPTY_SOUND_EVENT; + } else { + WeighedSoundEvents weighedSoundEvents = soundManager.getSoundEvent(soundEvent.getLocation()); + if (weighedSoundEvents == null) { + this.sound = SoundManager.EMPTY_SOUND; + } else { + this.sound = weighedSoundEvents.getSound(this.random); + } + + return weighedSoundEvents; + } + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingSound.java b/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingSound.java index 599d98f3b..8875a97f3 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingSound.java +++ b/common/src/main/java/whocraft/tardis_refined/client/sounds/LoopingSound.java @@ -3,6 +3,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.client.resources.sounds.Sound; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.SoundManager; import net.minecraft.sounds.SoundEvent; @@ -10,16 +11,12 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.client.TardisClientData; -import whocraft.tardis_refined.common.util.TardisHelper; -import whocraft.tardis_refined.registry.DimensionTypes; import whocraft.tardis_refined.registry.SoundRegistry; public class LoopingSound extends AbstractTickableSoundInstance { public static LoopingSound ARS_HUMMING = null; public static LoopingSound FLIGHT_LOOP = null; - public static LoopingSound HUM_TEST = null; - public LoopingSound(@NotNull SoundEvent soundEvent, SoundSource soundSource) { super(soundEvent, soundSource, SoundInstance.createUnseededRandom()); attenuation = Attenuation.NONE; @@ -83,26 +80,20 @@ public void tick() { } } - if(this == LoopingSound.HUM_TEST){ - delay = 40; - volume = TardisHelper.isInArsArea(player.blockPosition()) ? 0 : 0.2F; - if(DimensionTypes.TARDIS == player.level().dimensionTypeId()){ - volume = 0.2F; - } else { - volume = 0.0F; - } - } } + @Override + public Sound getSound() { + return super.getSound(); + } public static boolean shouldMinecraftMusicStop(SoundManager soundManager){ - return soundManager.isActive(FLIGHT_LOOP) || soundManager.isActive(ARS_HUMMING) || soundManager.isActive(HUM_TEST); + return soundManager.isActive(FLIGHT_LOOP) || soundManager.isActive(ARS_HUMMING) || soundManager.isActive(HumSoundManager.getCurrentSound()); } public static void setupSounds(){ LoopingSound.ARS_HUMMING = new LoopingSound(SoundRegistry.ARS_HUM.get(), SoundSource.AMBIENT); LoopingSound.FLIGHT_LOOP = new LoopingSound(SoundRegistry.TARDIS_SINGLE_FLY.get(), SoundSource.AMBIENT); - LoopingSound.HUM_TEST = new LoopingSound(SoundRegistry.TEST_HUM.get(), SoundSource.AMBIENT); } } diff --git a/common/src/main/java/whocraft/tardis_refined/client/sounds/QuickSimpleSound.java b/common/src/main/java/whocraft/tardis_refined/client/sounds/QuickSimpleSound.java new file mode 100644 index 000000000..b776feae8 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/client/sounds/QuickSimpleSound.java @@ -0,0 +1,62 @@ +package whocraft.tardis_refined.client.sounds; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.client.resources.sounds.Sound; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; + +public class QuickSimpleSound extends AbstractTickableSoundInstance { + + public QuickSimpleSound(@NotNull SoundEvent soundEvent, SoundSource soundSource) { + super(soundEvent, soundSource, SoundInstance.createUnseededRandom()); + attenuation = Attenuation.NONE; + looping = false; + delay = 0; + volume = 0.5f; + } + + public void setVolume(float volume) { + this.volume = volume; + } + + @Override + public float getVolume() { + return volume; + } + + public void setPitch(float pitch) { + this.pitch = pitch; + } + + @Override + public float getPitch() { + return pitch; + } + + public void setLocation(Vec3 location) { + x = location.x; + y = location.y; + z = location.z; + } + + public void stopSound() { + Minecraft.getInstance() + .getSoundManager() + .stop(this); + } + + @Override + public Sound getSound() { + return super.getSound(); + } + + + @Override + public void tick() { + + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/TardisLevelOperator.java b/common/src/main/java/whocraft/tardis_refined/common/capability/TardisLevelOperator.java index 2952f0262..8178c5f7e 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/TardisLevelOperator.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/TardisLevelOperator.java @@ -133,6 +133,7 @@ public void tick(ServerLevel level) { tardisClientData.setIsOnCooldown(pilotingManager.isOnCooldown()); tardisClientData.setShellTheme(aestheticHandler.getShellTheme()); tardisClientData.setShellPattern(aestheticHandler.shellPattern().id()); + tardisClientData.setHumEntry(interiorManager.getHumEntry()); tardisClientData.sync(); } diff --git a/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java b/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java new file mode 100644 index 000000000..e6ba1a6df --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/hum/HumEntry.java @@ -0,0 +1,73 @@ +package whocraft.tardis_refined.common.hum; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.Style; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.common.util.MiscHelper; + +import java.util.List; + +public class HumEntry { + + private static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + ResourceLocation.CODEC.fieldOf("id").forGetter(HumEntry::getIdentifier), + ResourceLocation.CODEC.fieldOf("hum_sound").forGetter(HumEntry::getSound), + Codec.list(ResourceLocation.CODEC).fieldOf("ambient_sounds").forGetter(HumEntry::getAmbientSounds), + Codec.STRING.orElse("Placeholder").fieldOf("name_component").forGetter(HumEntry::getName) + ).apply(instance, HumEntry::new)); + + private final ResourceLocation identifier; + private ResourceLocation sound; + private List ambientSounds; + private String name; + + public HumEntry(ResourceLocation identifier, ResourceLocation sound, List ambientSounds, String name) { + this.identifier = identifier; + this.sound = sound; + this.ambientSounds = ambientSounds; + this.name = name; + } + + public HumEntry(ResourceLocation identifier, ResourceLocation sound, List ambientSounds) { + this.identifier = identifier; + this.sound = sound; + this.ambientSounds = ambientSounds; + this.name = TardisRefined.GSON.toJson(Component.literal(MiscHelper.getCleanName(identifier.getPath())).setStyle(Style.EMPTY.withColor(ChatFormatting.GOLD))); + } + + public static Codec codec() { + return CODEC; + } + + public ResourceLocation getSound() { + return sound; + } + + public void setSound(ResourceLocation sound) { + this.sound = sound; + } + + public ResourceLocation getIdentifier() { + return identifier; + } + + public List getAmbientSounds() { + return ambientSounds; + } + + public void setAmbientSounds(List ambientSounds) { + this.ambientSounds = ambientSounds; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java b/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java new file mode 100644 index 000000000..bf40d9469 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/hum/TardisHums.java @@ -0,0 +1,69 @@ +package whocraft.tardis_refined.common.hum; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.sounds.SoundEvent; +import net.minecraft.sounds.SoundEvents; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.common.util.CodecJsonReloadListener; +import whocraft.tardis_refined.registry.SoundRegistry; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +public class TardisHums { + + private static final CodecJsonReloadListener RELOAD_LISTENER = createReloadListener(); + + private static final Map DEFAULT_HUMS = new HashMap<>(); + + /** + * A factory method to create the instance of our reload listener. + * + * @return + */ + private static CodecJsonReloadListener createReloadListener() { + return CodecJsonReloadListener.create(TardisRefined.MODID + "/hums", HumEntry.codec()); + } + + public static CodecJsonReloadListener getReloadListener() { + return RELOAD_LISTENER; + } + + public static Map getRegistry() { + return RELOAD_LISTENER.getData(); + } + + public static HumEntry getHumById(ResourceLocation location) { + return RELOAD_LISTENER.getData().getOrDefault(location, getDefaultHum()); + } + + /** + * Creates and adds the Tardis Refined default list of HumEntries to a standalone map. + * Can be used for datagenerators or as a fallback registry + * + * @return + */ + public static Map registerDefaultHums() { + DEFAULT_HUMS.clear(); + addDefaultHum(getDefaultHum()); + return DEFAULT_HUMS; + } + + private static void addDefaultHum(HumEntry hum) { + DEFAULT_HUMS.put(hum.getIdentifier(), hum); + } + + /** + * Gets a default HumEntry added by Tardis Refined. Useful as a fallback entry. + */ + public static HumEntry getDefaultHum() { + ArrayList arrayList = new ArrayList(); + arrayList.add(new ResourceLocation(TardisRefined.MODID, "interior_creaks")); + return new HumEntry(new ResourceLocation(TardisRefined.MODID, "coral_hum"), SoundRegistry.HUM_CORAL.getId(), arrayList); + } + + public static Map getDefaultHums() { + return DEFAULT_HUMS; + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java index 0e050b6a2..edbab5046 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/TardisNetwork.java @@ -2,8 +2,14 @@ import net.minecraft.resources.ResourceLocation; import whocraft.tardis_refined.TardisRefined; -import whocraft.tardis_refined.common.network.messages.*; -import whocraft.tardis_refined.common.network.messages.upgrades.C2SDisplayUpgradeScreen; +import whocraft.tardis_refined.common.network.messages.CancelDesktopChangeMessage; +import whocraft.tardis_refined.common.network.messages.ChangeDesktopMessage; +import whocraft.tardis_refined.common.network.messages.ChangeShellMessage; +import whocraft.tardis_refined.common.network.messages.hums.ChangeHumMessage; +import whocraft.tardis_refined.common.network.messages.screens.C2SRequestShellSelection; +import whocraft.tardis_refined.common.network.messages.screens.OpenMonitorMessage; +import whocraft.tardis_refined.common.network.messages.screens.OpenShellSelectionScreen; +import whocraft.tardis_refined.common.network.messages.sync.*; import whocraft.tardis_refined.common.network.messages.upgrades.S2CDisplayUpgradeScreen; import whocraft.tardis_refined.common.network.messages.upgrades.UnlockUpgradeMessage; import whocraft.tardis_refined.common.network.messages.waypoints.*; @@ -12,32 +18,37 @@ public class TardisNetwork { public static final NetworkManager NETWORK = NetworkManager.create(new ResourceLocation(TardisRefined.MODID, "channel")); - public static MessageType OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C, UPGRADE_SCREEN_C2S, CLIENT_OPEN_COORDS_SCREEN, SERVER_OPEN_COORDS_SCREEN, UPLOAD_WAYPOINT, SET_WAYPOINT, OPEN_WAYPOINTS_SCREEN, REQUEST_WAYPOINTS, SYNC_DESKTOPS, SYNC_CONSOLE_PATTERNS, SYNC_SHELL_PATTERNS, SYNC_LEVELS, INT_REACTION, OPEN_MONITOR, CHANGE_SHELL, CHANGE_DESKTOP, CANCEL_CHANGE_DESKTOP, UNLOCK_UPGRADE; + public static MessageType OPEN_SHELL_SELECT, SYNC_HUMS, OPEN_WAYPOINTS_DISPLAY, DEL_WAYPOINT, CLIENT_OPEN_COORDS_DISPLAY, SERVER_OPEN_COORDS_DISPLAY, UPGRADE_SCREEN_S2C, REQUEST_SHELL_C2S, CLIENT_OPEN_COORDS_SCREEN, SERVER_OPEN_COORDS_SCREEN, UPLOAD_WAYPOINT, SET_WAYPOINT, CHANGE_HUM, REQUEST_WAYPOINTS, SYNC_DESKTOPS, SYNC_CONSOLE_PATTERNS, SYNC_SHELL_PATTERNS, SYNC_LEVELS, INT_REACTION, OPEN_MONITOR, CHANGE_SHELL, CHANGE_DESKTOP, CANCEL_CHANGE_DESKTOP, UNLOCK_UPGRADE; public static void init() { + // S2C Messages SYNC_LEVELS = NETWORK.registerS2C("sync_levels", SyncLevelListMessage::new); INT_REACTION = NETWORK.registerS2C("int_reaction", SyncTardisClientDataMessage::new); OPEN_MONITOR = NETWORK.registerS2C("open_monitor", OpenMonitorMessage::new); + OPEN_SHELL_SELECT = NETWORK.registerS2C("open_shell_select", OpenShellSelectionScreen::new); SYNC_CONSOLE_PATTERNS = NETWORK.registerS2C("sync_console_patterns", SyncConsolePatternsMessage::new); SYNC_SHELL_PATTERNS = NETWORK.registerS2C("sync_shell_patterns", SyncShellPatternsMessage::new); + SYNC_DESKTOPS = NETWORK.registerS2C("sync_desktop", SyncDesktopsMessage::new); + SERVER_OPEN_COORDS_DISPLAY = NETWORK.registerS2C("server_open_coords_display", S2COpenCoordinatesDisplayMessage::new); + OPEN_WAYPOINTS_DISPLAY = NETWORK.registerS2C("open_waypoints_display", WaypointsListScreenMessage::new); + SERVER_OPEN_COORDS_SCREEN = NETWORK.registerS2C("server_open_coords_screen", S2COpenCoordinatesDisplayMessage::new); + SYNC_HUMS = NETWORK.registerS2C("sync_hums", SyncHumsMessage::new); + UPGRADE_SCREEN_S2C = NETWORK.registerS2C("upgrade_screen_s2c", S2CDisplayUpgradeScreen::new); + + // C2S Messages CHANGE_SHELL = NETWORK.registerC2S("change_shell", ChangeShellMessage::new); CHANGE_DESKTOP = NETWORK.registerC2S("change_desktop", ChangeDesktopMessage::new); - SYNC_DESKTOPS = NETWORK.registerS2C("sync_desktop", SyncDesktopsMessage::new); CANCEL_CHANGE_DESKTOP = NETWORK.registerC2S("cancel_change_desktop", CancelDesktopChangeMessage::new); REQUEST_WAYPOINTS = NETWORK.registerC2S("request_waypoints", RequestWaypointsMessage::new); - OPEN_WAYPOINTS_SCREEN = NETWORK.registerS2C("open_waypoints_screen", WaypointsListScreenMessage::new); SET_WAYPOINT = NETWORK.registerC2S("set_waypoint", TravelToWaypointMessage::new); UPLOAD_WAYPOINT = NETWORK.registerC2S("upload_waypoint", UploadWaypointMessage::new); - SERVER_OPEN_COORDS_DISPLAY = NETWORK.registerS2C("server_open_coords_display", S2COpenCoordinatesDisplayMessage::new); CLIENT_OPEN_COORDS_DISPLAY = NETWORK.registerC2S("client_open_coords_display", C2SOpenCoordinatesDisplayMessage::new); - OPEN_WAYPOINTS_DISPLAY = NETWORK.registerS2C("open_waypoints_display", WaypointsListScreenMessage::new); DEL_WAYPOINT = NETWORK.registerC2S("del_waypoint", RemoveWaypointEntryMessage::new); - SERVER_OPEN_COORDS_SCREEN = NETWORK.registerS2C("server_open_coords_screen", S2COpenCoordinatesDisplayMessage::new); CLIENT_OPEN_COORDS_SCREEN = NETWORK.registerC2S("client_open_coords_screen", C2SOpenCoordinatesDisplayMessage::new); UNLOCK_UPGRADE = NETWORK.registerC2S("unlock_upgrade", UnlockUpgradeMessage::new); - UPGRADE_SCREEN_C2S = NETWORK.registerC2S("upgrade_screen_c2s", C2SDisplayUpgradeScreen::new); - UPGRADE_SCREEN_S2C = NETWORK.registerS2C("upgrade_screen_s2c", S2CDisplayUpgradeScreen::new); - + REQUEST_SHELL_C2S = NETWORK.registerC2S("request_shell_c2s", C2SRequestShellSelection::new); + CHANGE_HUM = NETWORK.registerC2S("change_hum", ChangeHumMessage::new); } + } diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/hums/ChangeHumMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/hums/ChangeHumMessage.java new file mode 100644 index 000000000..bf879626e --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/hums/ChangeHumMessage.java @@ -0,0 +1,64 @@ +package whocraft.tardis_refined.common.network.messages.hums; + +import net.minecraft.core.registries.Registries; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.client.TardisClientData; +import whocraft.tardis_refined.common.capability.TardisLevelOperator; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +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.tardis.manager.TardisInteriorManager; + +import java.util.Optional; + +public class ChangeHumMessage extends MessageC2S { + + private final ResourceKey resourceKey; + private final HumEntry humEntry; + + public ChangeHumMessage(ResourceKey tardisLevel, HumEntry humEntry) { + this.resourceKey = tardisLevel; + this.humEntry = humEntry; + } + + public ChangeHumMessage(FriendlyByteBuf buffer) { + this.resourceKey = buffer.readResourceKey(Registries.DIMENSION); + this.humEntry = TardisHums.getHumById(buffer.readResourceLocation()); + } + + @NotNull + @Override + public MessageType getType() { + return TardisNetwork.CHANGE_HUM; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + buf.writeResourceKey(this.resourceKey); + buf.writeResourceLocation(this.humEntry.getIdentifier()); + } + + @Override + public void handle(MessageContext context) { + Optional level = Optional.ofNullable(context.getPlayer().getServer().levels.get(resourceKey)); + level.ifPresent(x -> { + TardisLevelOperator.get(x).ifPresent(operator -> { + TardisInteriorManager tardisInteriorManager = operator.getInteriorManager(); + TardisClientData tardisClientData = operator.tardisClientData(); + tardisInteriorManager.setHumEntry(humEntry); + tardisClientData.setHumEntry(humEntry); + tardisClientData.sync(); + }); + }); + + } + + +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/C2SRequestShellSelection.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/C2SRequestShellSelection.java new file mode 100644 index 000000000..e94c0492d --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/C2SRequestShellSelection.java @@ -0,0 +1,39 @@ +package whocraft.tardis_refined.common.network.messages.screens; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.common.capability.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; + +public class C2SRequestShellSelection extends MessageC2S { + + public C2SRequestShellSelection() { + } + + public C2SRequestShellSelection(FriendlyByteBuf friendlyByteBuf) { + } + + + @NotNull + @Override + public MessageType getType() { + return TardisNetwork.REQUEST_SHELL_C2S; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + + } + + @Override + public void handle(MessageContext context) { + ServerLevel serverLevel = context.getPlayer().serverLevel(); + TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> { + new OpenShellSelectionScreen(tardisLevelOperator.getAestheticHandler().getShellTheme()).send(context.getPlayer()); + }); + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/OpenMonitorMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenMonitorMessage.java similarity index 84% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/OpenMonitorMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenMonitorMessage.java index 9e88c5a0b..0dbdcff65 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/OpenMonitorMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenMonitorMessage.java @@ -1,18 +1,12 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.screens; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.nbt.CompoundTag; -import net.minecraft.client.Minecraft; -import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import org.jetbrains.annotations.NotNull; import whocraft.tardis_refined.client.ScreenHandler; import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler; -import whocraft.tardis_refined.client.screen.CancelDesktopScreen; -import whocraft.tardis_refined.client.screen.MonitorScreen; -import whocraft.tardis_refined.common.capability.TardisLevelOperator; -import whocraft.tardis_refined.common.capability.upgrades.UpgradeHandler; import whocraft.tardis_refined.common.network.MessageContext; import whocraft.tardis_refined.common.network.MessageS2C; import whocraft.tardis_refined.common.network.MessageType; diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenShellSelectionScreen.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenShellSelectionScreen.java new file mode 100644 index 000000000..f9a7aa945 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/screens/OpenShellSelectionScreen.java @@ -0,0 +1,50 @@ +package whocraft.tardis_refined.common.network.messages.screens; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; +import whocraft.tardis_refined.client.ScreenHandler; +import whocraft.tardis_refined.common.network.MessageContext; +import whocraft.tardis_refined.common.network.MessageS2C; +import whocraft.tardis_refined.common.network.MessageType; +import whocraft.tardis_refined.common.network.TardisNetwork; + + +public class OpenShellSelectionScreen extends MessageS2C { + + private ResourceLocation currentShell; + + public OpenShellSelectionScreen(ResourceLocation currentShell) { + this.currentShell = currentShell; + } + + public OpenShellSelectionScreen(FriendlyByteBuf friendlyByteBuf) { + this.currentShell = friendlyByteBuf.readResourceLocation(); + } + + @NotNull + @Override + public MessageType getType() { + return TardisNetwork.OPEN_SHELL_SELECT; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + buf.writeResourceLocation(this.currentShell); + } + + + @Override + public void handle(MessageContext context) { + handleScreens(); + } + + @Environment(EnvType.CLIENT) + private void handleScreens() { + // Open the monitor. + ScreenHandler.openShellSelection(currentShell); + } + +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncConsolePatternsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java similarity index 92% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncConsolePatternsMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java index 7ad770087..54d534d5b 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncConsolePatternsMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncConsolePatternsMessage.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.sync; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.UnboundedMapCodec; @@ -11,13 +11,11 @@ import whocraft.tardis_refined.common.network.MessageType; import whocraft.tardis_refined.common.network.TardisNetwork; import whocraft.tardis_refined.patterns.ConsolePattern; -import whocraft.tardis_refined.patterns.ConsolePatternCollection; import whocraft.tardis_refined.patterns.ConsolePatterns; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; public class SyncConsolePatternsMessage extends MessageS2C{ diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncDesktopsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java similarity index 95% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncDesktopsMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java index b7c1e448e..0e57359ae 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncDesktopsMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncDesktopsMessage.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.sync; import com.mojang.serialization.Codec; import net.minecraft.nbt.CompoundTag; @@ -12,9 +12,7 @@ import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.tardis.themes.DesktopTheme; -import java.util.ArrayList; import java.util.HashMap; -import java.util.List; import java.util.Map; public class SyncDesktopsMessage extends MessageS2C { diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncHumsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncHumsMessage.java new file mode 100644 index 000000000..b36fb1cd3 --- /dev/null +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncHumsMessage.java @@ -0,0 +1,52 @@ +package whocraft.tardis_refined.common.network.messages.sync; + +import com.mojang.serialization.Codec; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +import whocraft.tardis_refined.common.network.MessageContext; +import whocraft.tardis_refined.common.network.MessageS2C; +import whocraft.tardis_refined.common.network.MessageType; +import whocraft.tardis_refined.common.network.TardisNetwork; + +import java.util.HashMap; +import java.util.Map; + +public class SyncHumsMessage extends MessageS2C { + + //We use an unboundedMapCodec. However it is limited in that it can only parse objects whose keys can be serialised to a string, such as ResourceLocation + //E.g. If you used an int as a key, the unboundedMapCodec will not parse it and will error. + private static final Codec> MAPPER = Codec.unboundedMap(ResourceLocation.CODEC, HumEntry.codec()); + private Map tardisHums = new HashMap<>(); + + + public SyncHumsMessage(Map tardisHums) { + this.tardisHums = tardisHums; + } + + public SyncHumsMessage(FriendlyByteBuf buf) { + //Parse our Map Codec and send the nbt data over. If there's any errors, populate with default Tardis Refined console rooms + this.tardisHums = MAPPER.parse(NbtOps.INSTANCE, buf.readNbt()).result().orElse(TardisHums.registerDefaultHums()); + } + + @Override + public MessageType getType() { + return TardisNetwork.SYNC_HUMS; + } + + @Override + public void toBytes(FriendlyByteBuf buf) { + buf.writeNbt((CompoundTag) (MAPPER.encodeStart(NbtOps.INSTANCE, this.tardisHums).result().orElse(new CompoundTag()))); + } + + @Override + public void handle(MessageContext context) { + TardisHums.getRegistry().clear(); + for (Map.Entry entry : this.tardisHums.entrySet()) { + TardisHums.getRegistry().put(entry.getKey(), entry.getValue()); + } + } +} diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncLevelListMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncLevelListMessage.java similarity index 95% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncLevelListMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncLevelListMessage.java index 9fea96cef..970fb41f3 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncLevelListMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncLevelListMessage.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.sync; import net.minecraft.core.registries.Registries; import net.minecraft.network.FriendlyByteBuf; diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncShellPatternsMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncShellPatternsMessage.java similarity index 89% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncShellPatternsMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncShellPatternsMessage.java index 91f02c9c7..11403b923 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncShellPatternsMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncShellPatternsMessage.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.sync; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.UnboundedMapCodec; @@ -10,15 +10,12 @@ import whocraft.tardis_refined.common.network.MessageS2C; import whocraft.tardis_refined.common.network.MessageType; import whocraft.tardis_refined.common.network.TardisNetwork; -import whocraft.tardis_refined.patterns.ConsolePattern; import whocraft.tardis_refined.patterns.ShellPattern; -import whocraft.tardis_refined.patterns.ShellPatternCollection; import whocraft.tardis_refined.patterns.ShellPatterns; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; public class SyncShellPatternsMessage extends MessageS2C { diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncTardisClientDataMessage.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncTardisClientDataMessage.java similarity index 96% rename from common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncTardisClientDataMessage.java rename to common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncTardisClientDataMessage.java index 24791ff1d..9ab36450b 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/SyncTardisClientDataMessage.java +++ b/common/src/main/java/whocraft/tardis_refined/common/network/messages/sync/SyncTardisClientDataMessage.java @@ -1,4 +1,4 @@ -package whocraft.tardis_refined.common.network.messages; +package whocraft.tardis_refined.common.network.messages.sync; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; diff --git a/common/src/main/java/whocraft/tardis_refined/common/network/messages/upgrades/C2SDisplayUpgradeScreen.java b/common/src/main/java/whocraft/tardis_refined/common/network/messages/upgrades/C2SDisplayUpgradeScreen.java deleted file mode 100644 index 11885cc02..000000000 --- a/common/src/main/java/whocraft/tardis_refined/common/network/messages/upgrades/C2SDisplayUpgradeScreen.java +++ /dev/null @@ -1,47 +0,0 @@ -package whocraft.tardis_refined.common.network.messages.upgrades; - -import net.minecraft.core.registries.Registries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; -import whocraft.tardis_refined.common.capability.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; - -public class C2SDisplayUpgradeScreen extends MessageC2S { - - public ResourceKey levelResourceKey; - - public C2SDisplayUpgradeScreen(ResourceKey levelResourceKey) { - this.levelResourceKey = levelResourceKey; - } - - public C2SDisplayUpgradeScreen(FriendlyByteBuf friendlyByteBuf){ - levelResourceKey = friendlyByteBuf.readResourceKey(Registries.DIMENSION); - } - - - @NotNull - @Override - public MessageType getType() { - return TardisNetwork.UPGRADE_SCREEN_C2S; - } - - @Override - public void toBytes(FriendlyByteBuf buf) { - buf.writeResourceKey(levelResourceKey); - } - - @Override - public void handle(MessageContext context) { - ServerLevel serverLevel = context.getPlayer().serverLevel(); - TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> { - new S2CDisplayUpgradeScreen(tardisLevelOperator.getUpgradeHandler().saveData(new CompoundTag())).send(context.getPlayer()); - }); - } -} diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java index 723ea9a6d..2f668eb46 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/control/ship/MonitorControl.java @@ -5,7 +5,7 @@ import whocraft.tardis_refined.common.capability.TardisLevelOperator; import whocraft.tardis_refined.common.entity.ControlEntity; import whocraft.tardis_refined.common.items.KeyItem; -import whocraft.tardis_refined.common.network.messages.OpenMonitorMessage; +import whocraft.tardis_refined.common.network.messages.screens.OpenMonitorMessage; import whocraft.tardis_refined.common.tardis.control.Control; import whocraft.tardis_refined.common.tardis.themes.ConsoleTheme; import whocraft.tardis_refined.common.util.PlayerUtil; diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/AestheticHandler.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/AestheticHandler.java index f7dd82301..f83f3edad 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/AestheticHandler.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/AestheticHandler.java @@ -14,6 +14,8 @@ import whocraft.tardis_refined.common.blockentity.door.GlobalDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity; import whocraft.tardis_refined.common.capability.TardisLevelOperator; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.tardis.TardisNavLocation; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; import whocraft.tardis_refined.constants.NbtConstants; @@ -29,12 +31,14 @@ public class AestheticHandler extends BaseHandler { // Shell private ResourceLocation shellTheme = ShellTheme.FACTORY.getId(); private ShellPattern shellPattern = ShellPatterns.DEFAULT; + private HumEntry currentHum = TardisHums.getDefaultHum(); public AestheticHandler(TardisLevelOperator tardisLevelOperator) { super(); this.tardisOperator = tardisLevelOperator; } + public ShellPattern shellPattern() { return shellPattern; } diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisInteriorManager.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisInteriorManager.java index 97c5b1289..1632b2276 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisInteriorManager.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisInteriorManager.java @@ -18,6 +18,8 @@ import whocraft.tardis_refined.common.blockentity.door.BulkHeadDoorBlockEntity; import whocraft.tardis_refined.common.blockentity.door.TardisInternalDoor; import whocraft.tardis_refined.common.capability.TardisLevelOperator; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.protection.ProtectedZone; import whocraft.tardis_refined.common.tardis.TardisArchitectureHandler; import whocraft.tardis_refined.common.tardis.TardisDesktops; @@ -45,6 +47,8 @@ public class TardisInteriorManager extends BaseHandler { private int airlockCountdownSeconds = 3; private int airlockTimerSeconds = 5; + private HumEntry humEntry = TardisHums.getDefaultHum(); + public static final BlockPos STATIC_CORRIDOR_POSITION = new BlockPos(1000, 100, 0); public DesktopTheme preparedTheme() { @@ -96,6 +100,7 @@ public void tick() { } + @Override public CompoundTag saveData(CompoundTag tag) { tag.putBoolean(NbtConstants.TARDIS_IM_IS_WAITING_TO_GENERATE, this.isWaitingToGenerate); tag.putBoolean(NbtConstants.TARDIS_IM_GENERATING_DESKTOP, this.isGeneratingDesktop); @@ -109,6 +114,7 @@ public CompoundTag saveData(CompoundTag tag) { tag.putString(NbtConstants.TARDIS_IM_PREPARED_THEME, this.preparedTheme != null ? this.preparedTheme.getIdentifier().toString() : ""); tag.putString(NbtConstants.TARDIS_IM_CURRENT_THEME, this.currentTheme.getIdentifier().toString()); + tag.putString(NbtConstants.TARDIS_CURRENT_HUM, this.humEntry.getIdentifier().toString()); return tag; } @Override @@ -120,8 +126,17 @@ public void loadData(CompoundTag tag) { this.preparedTheme = TardisDesktops.getDesktopById(new ResourceLocation(tag.getString(NbtConstants.TARDIS_IM_PREPARED_THEME))); this.currentTheme = tag.contains(NbtConstants.TARDIS_IM_CURRENT_THEME) ? TardisDesktops.getDesktopById(new ResourceLocation((NbtConstants.TARDIS_IM_CURRENT_THEME))) : preparedTheme; this.corridorAirlockCenter = NbtUtils.readBlockPos(tag.getCompound(NbtConstants.TARDIS_IM_AIRLOCK_CENTER)); + this.humEntry = TardisHums.getHumById(new ResourceLocation(tag.getString(NbtConstants.TARDIS_CURRENT_HUM))); + } + + + public HumEntry getHumEntry() { + return humEntry; } + public void setHumEntry(HumEntry humEntry) { + this.humEntry = humEntry; + } public void tick(ServerLevel level) { diff --git a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java index 6f745b528..48b99edd6 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/ModMessages.java @@ -36,6 +36,7 @@ public class ModMessages { public static final String UI_MONITOR_WAYPOINTS = ui("monitor.waypoints"); public static final String UI_MONITOR_UPLOAD_WAYPOINTS = ui("monitor.upload.waypoints"); public static final String UI_MONITOR_UPLOAD_COORDS = ui("monitor.upload.coords"); + public static final String UI_MONITOR_SELECT_HUM = ui("monitor.select.hum"); public static final String UI_MONITOR_NO_WAYPOINTS = ui("monitor.no.waypoints"); public static final String UI_MONITOR_WAYPOINT_UPLOAD = ui("monitor.waypoints.upload"); public static final String UI_MONITOR_WAYPOINT_SUBMIT = ui("monitor.waypoints.submit"); diff --git a/common/src/main/java/whocraft/tardis_refined/constants/NbtConstants.java b/common/src/main/java/whocraft/tardis_refined/constants/NbtConstants.java index 3ea0302ce..c79897b99 100644 --- a/common/src/main/java/whocraft/tardis_refined/constants/NbtConstants.java +++ b/common/src/main/java/whocraft/tardis_refined/constants/NbtConstants.java @@ -35,6 +35,7 @@ public class NbtConstants { public static final String TARDIS_IM_GENERATION_COOLDOWN = "im_generation_cooldown"; public static final String TARDIS_IM_GENERATED_CORRIDORS = "im_generated_corridors"; public static final String TARDIS_IM_AIRLOCK_CENTER = "im_generated_airlock_center"; + public static final String TARDIS_CURRENT_HUM = "tardis_current_hum"; // External Readings Data public static final String TARDIS_EXT_CURRENT_THEME = "terd_current_theme"; diff --git a/common/src/main/java/whocraft/tardis_refined/registry/CustomRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/CustomRegistry.java deleted file mode 100644 index 1063ae3b0..000000000 --- a/common/src/main/java/whocraft/tardis_refined/registry/CustomRegistry.java +++ /dev/null @@ -1,80 +0,0 @@ -//package whocraft.tardis_refined.registry; -// -//import dev.architectury.injectables.annotations.ExpectPlatform; -//import net.minecraft.core.Registry; -//import net.minecraft.resources.ResourceKey; -//import net.minecraft.resources.ResourceLocation; -//import org.jetbrains.annotations.NotNull; -//import org.jetbrains.annotations.Nullable; -// -//import java.util.Collection; -//import java.util.Iterator; -//import java.util.Set; -// -///** -// * this is all my own work -// */ -//public abstract class CustomRegistry implements Iterable { -// -// /** -// * Creates a new {@link CustomRegistry} with the given class type and the registry id -// * -// * @param clazz Class of type of the registry -// * @param id ID for the registry -// * @param Generic type of the registry -// * @return A new {@link CustomRegistry} instance -// */ -// public static CustomRegistry create(Class clazz, ResourceLocation id) { -// return createInternal(clazz, id); -// } -// -// @ExpectPlatform -// private static CustomRegistry createInternal(Class clazz, ResourceLocation id) { -// throw new AssertionError(); -// } -// -// /** -// * @return {@link ResourceKey} associated with the registry -// */ -// public abstract ResourceKey> getRegistryKey(); -// -// /** -// * Gets the object from the registry with the given key. Might be null if no such object has been registered -// * -// * @param key ID/Key of the wanted registered object -// * @return Either the wanted object or null -// */ -// @Nullable -// public abstract T get(ResourceLocation key); -// -// /** -// * Gets the key of the given object. Might be null if the object has never been registered -// * -// * @param object The object which is used to find a key for -// * @return Either a {@link ResourceLocation} or null -// */ -// @Nullable -// public abstract ResourceLocation getKey(T object); -// -// /** -// * @param key Key of a potentially registered object -// * @return True if something was registerd with that key -// */ -// public abstract boolean containsKey(ResourceLocation key); -// -// /** -// * @return All keys registered in this registry -// */ -// public abstract Set getKeys(); -// -// /** -// * @return All values registered in this registry -// */ -// public abstract Collection getValues(); -// -// @NotNull -// @Override -// public Iterator iterator() { -// return this.getValues().iterator(); -// } -//} \ No newline at end of file diff --git a/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java index 46931e122..a4dd5c7e0 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java @@ -19,7 +19,8 @@ public class SoundRegistry { public static final RegistrySupplier DESTINATION_DING = setUpSound("destination_ding"); public static final RegistrySupplier ARS_HUM = setUpSound("ars_hum"); public static final RegistrySupplier BULKHEAD_LOCKED = setUpSound("bulkhead_locked"); - public static final RegistrySupplier TEST_HUM = setUpSound("test_hum"); + public static final RegistrySupplier HUM_CORAL = setUpSound("hum_coral"); + public static final RegistrySupplier INTERIOR_CREAKS = setUpSound("interior_creaks"); private static RegistrySupplier setUpSound(String soundName) { SoundEvent sound = SoundEvent.createVariableRangeEvent(new ResourceLocation(TardisRefined.MODID, soundName)); diff --git a/common/src/main/resources/assets/tardis_refined/sounds/blocks/bulkhead_locked.ogg b/common/src/main/resources/assets/tardis_refined/sounds/blocks/bulkhead_locked.ogg index 848100ec1..9216562fa 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/blocks/bulkhead_locked.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/blocks/bulkhead_locked.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/gadgets/pattern_manipulator.ogg b/common/src/main/resources/assets/tardis_refined/sounds/gadgets/pattern_manipulator.ogg index 26043e7cd..778dcc270 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/gadgets/pattern_manipulator.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/gadgets/pattern_manipulator.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_1.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_1.ogg new file mode 100644 index 000000000..8522eaca0 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_1.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_2.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_2.ogg new file mode 100644 index 000000000..bb6f09629 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_2.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_3.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_3.ogg new file mode 100644 index 000000000..b68418fe9 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ambience/interior_creaks_3.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/ars/ars_hum.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ars/ars_hum.ogg index a1349ecfa..2da291b90 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/ars/ars_hum.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/ars/ars_hum.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/destination_ding.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/destination_ding.ogg index 1906304d0..b71d33ddb 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/destination_ding.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/destination_ding.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/hum1996.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/hum1996.ogg new file mode 100644 index 000000000..0a53f8ebd Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/hum1996.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humclassic.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humclassic.ogg new file mode 100644 index 000000000..2ad1495bf Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humclassic.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humcoral.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humcoral.ogg new file mode 100644 index 000000000..03f7b9953 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humcoral.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humtoyota.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humtoyota.ogg new file mode 100644 index 000000000..931fbfddc Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/interior_hums/humtoyota.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_crash_land.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_crash_land.ogg index 40ea4c9fa..5cd844eee 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_crash_land.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_crash_land.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_land.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_land.ogg index 40a14cf05..aa83782f7 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_land.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_land.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_misc_sparkle.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_misc_sparkle.ogg index bd4f04edf..3e3dfb8b7 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_misc_sparkle.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_misc_sparkle.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_single_fly.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_single_fly.ogg index 5f1d97ee2..045b5ca04 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_single_fly.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_single_fly.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_takeoff.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_takeoff.ogg index fe941c0db..89173f194 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_takeoff.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/tardis_takeoff.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/test_hum.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/test_hum.ogg deleted file mode 100644 index 22b2abf6b..000000000 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/test_hum.ogg and /dev/null differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/tardis/time_blast.ogg b/common/src/main/resources/assets/tardis_refined/sounds/tardis/time_blast.ogg index 8f35fefd3..c6ab67a46 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/tardis/time_blast.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/tardis/time_blast.ogg differ diff --git a/common/src/main/resources/assets/tardis_refined/sounds/ui/static.ogg b/common/src/main/resources/assets/tardis_refined/sounds/ui/static.ogg index aae6f8d8f..8a534b2a1 100644 Binary files a/common/src/main/resources/assets/tardis_refined/sounds/ui/static.ogg and b/common/src/main/resources/assets/tardis_refined/sounds/ui/static.ogg differ diff --git a/common/src/main/resources/data/tardis_refined/structures/rooms/ars/room_ars_stage_one.nbt b/common/src/main/resources/data/tardis_refined/structures/rooms/ars/room_ars_stage_one.nbt index 20c33b7e0..6e7a349e4 100644 Binary files a/common/src/main/resources/data/tardis_refined/structures/rooms/ars/room_ars_stage_one.nbt and b/common/src/main/resources/data/tardis_refined/structures/rooms/ars/room_ars_stage_one.nbt differ diff --git a/fabric/build.gradle b/fabric/build.gradle index f2ff8e192..3f65b0b15 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -82,9 +82,9 @@ dependencies { // Immersive Portals Start - modCompileOnly ("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.0.3-mc1.20.2") - modCompileOnly ("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v4.0.3-mc1.20.2") - modCompileOnly ("com.github.iPortalTeam.ImmersivePortalsMod:build:v4.0.3-mc1.20.2") + modImplementation ("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v4.0.3-mc1.20.2") + modImplementation ("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:v4.0.3-mc1.20.2") + modImplementation ("com.github.iPortalTeam.ImmersivePortalsMod:build:v4.0.3-mc1.20.2") /* // If working on Immersive Portals, change modCompileOnlyApi to modImplementation for the following two entries, this will enable Immersive Portals in Dev modCompileOnlyApi("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${rootProject.immersive_portals_version}") { diff --git a/fabric/src/main/java/whocraft/tardis_refined/common/dimension/fabric/DimensionHandlerImpl.java b/fabric/src/main/java/whocraft/tardis_refined/common/dimension/fabric/DimensionHandlerImpl.java index c80cfd87f..daeef7901 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/common/dimension/fabric/DimensionHandlerImpl.java +++ b/fabric/src/main/java/whocraft/tardis_refined/common/dimension/fabric/DimensionHandlerImpl.java @@ -24,7 +24,7 @@ import net.minecraft.world.level.storage.WorldData; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.common.dimension.DimensionHandler; -import whocraft.tardis_refined.common.network.messages.SyncLevelListMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncLevelListMessage; import whocraft.tardis_refined.compat.ModCompatChecker; import whocraft.tardis_refined.compat.portals.ImmersivePortals; diff --git a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java index f824a5b82..2a4a6a88d 100644 --- a/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java +++ b/fabric/src/main/java/whocraft/tardis_refined/fabric/TardisRefinedFabric.java @@ -15,6 +15,7 @@ import whocraft.tardis_refined.TRConfig; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.command.arguments.UpgradeArgumentType; +import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.util.fabric.PlatformImpl; import whocraft.tardis_refined.common.world.fabric.TRFabricBiomeModifiers; @@ -74,6 +75,7 @@ public void onInitialize() { register(SERVER_DATA, new ResourceLocation(TardisRefined.MODID, TardisRefined.MODID + "/" + "desktops"), TardisDesktops.getReloadListener()); register(SERVER_DATA, new ResourceLocation(TardisRefined.MODID, TardisRefined.MODID + "/" + "shell_patterns"), ShellPatterns.getReloadListener()); + register(SERVER_DATA, new ResourceLocation(TardisRefined.MODID, TardisRefined.MODID + "/" + "hums"), TardisHums.getReloadListener()); if (ModCompatChecker.immersivePortals()) { if (TRConfig.COMMON.COMPATIBILITY_IP.get()) { diff --git a/forge/src/generated/resources/.cache/0533c97ce5395f38717098a1ca49d72068853e57 b/forge/src/generated/resources/.cache/0533c97ce5395f38717098a1ca49d72068853e57 index cdfa629ac..224efd4c7 100644 --- a/forge/src/generated/resources/.cache/0533c97ce5395f38717098a1ca49d72068853e57 +++ b/forge/src/generated/resources/.cache/0533c97ce5395f38717098a1ca49d72068853e57 @@ -1,2 +1,3 @@ -// 1.20.2 2023-12-09T00:48:51.7779441 Tags for minecraft:entity_type mod id tardis_refined +// 1.20.2 2024-01-01T17:33:21.0652964 Tags for minecraft:entity_type mod id tardis_refined 9c7849fe44abd1038764fb53dff5f0c10322170c data/carryon/tags/entity_types/entity_blacklist.json +23f068816583cf8b34247dec032eff463ce9a299 data/tardis_refined/tags/entity_types/tardis_teleport_blacklist.json diff --git a/forge/src/generated/resources/.cache/07cdbcdc6e4f4553ae9ccc48cd1ff0a5be53a01c b/forge/src/generated/resources/.cache/07cdbcdc6e4f4553ae9ccc48cd1ff0a5be53a01c index f2f2a6325..7d28fdae6 100644 --- a/forge/src/generated/resources/.cache/07cdbcdc6e4f4553ae9ccc48cd1ff0a5be53a01c +++ b/forge/src/generated/resources/.cache/07cdbcdc6e4f4553ae9ccc48cd1ff0a5be53a01c @@ -1,3 +1,3 @@ -// 1.20.2 2023-12-13T15:41:19.7516606 Particles +// 1.20.2 2024-01-01T17:33:21.0587864 Particles 8cb6f3514bfe24e046149cf8e8442f7ed5315b8f assets/tardis_refined/particles/ars_leaves.json c035f460beb41b955ecff7b545f92f0ac78c4663 assets/tardis_refined/particles/gallifrey.json diff --git a/forge/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 b/forge/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 index 57189c9bd..2795281da 100644 --- a/forge/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 +++ b/forge/src/generated/resources/.cache/103d9f3f36b01595f1aa5172191e60eff02e6924 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-09T00:48:51.7754985 Registries +// 1.20.2 2024-01-01T17:33:21.0627898 Registries d9483eb301ed4a4fd91b5f042909997a1bc3085c data/tardis_refined/neoforge/biome_modifier/tardis_root_cluster.json b3353cf92cff570f9c4ac799f23045aa94b34968 data/tardis_refined/worldgen/configured_feature/tardis_root_cluster.json 0694927b6b3eb72bf137510f370a1d6133dc7795 data/tardis_refined/worldgen/placed_feature/tardis_root_cluster.json diff --git a/forge/src/generated/resources/.cache/1605092b5c78c792538553a3583c4f114827efd2 b/forge/src/generated/resources/.cache/1605092b5c78c792538553a3583c4f114827efd2 index 99588f5b0..2b4977d0a 100644 --- a/forge/src/generated/resources/.cache/1605092b5c78c792538553a3583c4f114827efd2 +++ b/forge/src/generated/resources/.cache/1605092b5c78c792538553a3583c4f114827efd2 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-09T00:48:51.7769417 Item Models: tardis_refined +// 1.20.2 2024-01-01T17:33:21.0637909 Item Models: tardis_refined ce4f5ab23d604af7306a4aa1c128e8e308263554 assets/tardis_refined/models/item/air_lock_generator.json 961ce6420a6ff1952ba49ee162d130a3e8134815 assets/tardis_refined/models/item/ars_egg.json 436ee865aed07b4b30a5fb30ffd3c96ce04bd050 assets/tardis_refined/models/item/ars_leaves.json diff --git a/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 b/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 index 306031f8f..f7d224902 100644 --- a/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 +++ b/forge/src/generated/resources/.cache/3fcdc37ad136e2a9e4d043224d2db5bc1dee2659 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-18T17:52:51.3188952 Shell Patterns +// 1.20.2 2024-01-01T17:33:21.0597871 Shell Patterns 24c3b07d5ebcb921f1a4014c0c7b7ce1db66d291 data/tardis_refined/tardis_refined/patterns/shell/big_ben.json c023593375b56bf2ba50df33b355f0f99d062227 data/tardis_refined/tardis_refined/patterns/shell/briefcase.json 0c683f48298e8e97709fa8f659a659440e35dc61 data/tardis_refined/tardis_refined/patterns/shell/castle.json diff --git a/forge/src/generated/resources/.cache/4dd1d6c274bb02a1ca04c043cc3e81adc6abd533 b/forge/src/generated/resources/.cache/4dd1d6c274bb02a1ca04c043cc3e81adc6abd533 index e9c05d4a7..8ada0b056 100644 --- a/forge/src/generated/resources/.cache/4dd1d6c274bb02a1ca04c043cc3e81adc6abd533 +++ b/forge/src/generated/resources/.cache/4dd1d6c274bb02a1ca04c043cc3e81adc6abd533 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-13T15:41:19.7541757 Block States: tardis_refined +// 1.20.2 2024-01-01T17:33:21.0607882 Block States: tardis_refined b8a00271e10524036c2c321dc80eb8a392301f6c assets/tardis_refined/blockstates/air_lock_generator.json 1ec70f6d41be20660fe5a60a94426a85150e5e48 assets/tardis_refined/blockstates/ars_egg.json 734a9a861a8cf9ce47f1daee3e848263e9810457 assets/tardis_refined/blockstates/ars_leaves.json @@ -9,7 +9,6 @@ e3b9d3e5657ce05ec9ad52a8ca863f65b8d94550 assets/tardis_refined/blockstates/bulk_ d3b60531f8edf549fc2f9a2fdd5a9580f7ac800f assets/tardis_refined/blockstates/flight_detector.json b00562c84855d8fa18e656882af1bd9f6d71df65 assets/tardis_refined/blockstates/growth_stone.json c3c5ee52d1573fd9db6fdc72e08f80bc2f869458 assets/tardis_refined/blockstates/hardened_growth_stone.json -766604e205dde1ee1031a0fc73b8f18455659cae assets/tardis_refined/blockstates/internal_door_block.json 30a33a2955de44814048c09c7e8066909fcddc08 assets/tardis_refined/blockstates/landing_pad.json 5d3e1c7764aaff70e3769b36f95206b7c5d02ae9 assets/tardis_refined/blockstates/root_plant.json 39ad0e8fbe71f8dcd2877502ca080122539d22fe assets/tardis_refined/blockstates/root_shell.json diff --git a/forge/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d b/forge/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d index 2bc1c28e3..4e163f663 100644 --- a/forge/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d +++ b/forge/src/generated/resources/.cache/59eb3dbb5f86130e09b3c62d89b9525ee01cf52d @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-08T14:05:02.0928809 Loot Tables +// 1.20.2 2024-01-01T17:33:21.0557849 Loot Tables 84db98a0dc5acd311a33c78da97d0f550b5a6b99 data/tardis_refined/loot_tables/blocks/air_lock_generator.json 44f9a22dab47fde18e68a272e5432a2ea1896f8f data/tardis_refined/loot_tables/blocks/ars_egg.json 4252a1599ca37433695f202fd304bf55237ed1dd data/tardis_refined/loot_tables/blocks/ars_leaves.json @@ -9,7 +9,6 @@ fde1a46c75c8414fdf331b7390bd594226bfaba4 data/tardis_refined/loot_tables/blocks/ 69b9ccd0fdff14479cf3d7097975f13ebfd5dcdd data/tardis_refined/loot_tables/blocks/flight_detector.json 466527300d1234e7fe66380ab0cba584eae6febc data/tardis_refined/loot_tables/blocks/growth_stone.json b1113885068e3fd57d082d4049c2d0cdd157c43e data/tardis_refined/loot_tables/blocks/hardened_growth_stone.json -1e62945dfd20d73829b7ca345f38047f303cc2f0 data/tardis_refined/loot_tables/blocks/internal_door_block.json 81ded436d38a9cf26bd58d10162ac494951f24e1 data/tardis_refined/loot_tables/blocks/landing_pad.json 30a30314f2504439b04d07ec51ce03b1ab1c5cd3 data/tardis_refined/loot_tables/blocks/root_plant.json c2ee9e06adc9cc276ca618d76e1406cc60a25ddc data/tardis_refined/loot_tables/blocks/root_shell.json diff --git a/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e b/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e index 996febf04..f880b0844 100644 --- a/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e +++ b/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e @@ -1,2 +1,2 @@ -// 1.20.2 2023-12-22T14:44:08.8631383 Sound Definitions -4875e9832141aea2449ebba45177460bb6eed8a0 assets/tardis_refined/sounds.json +// 1.20.2 2024-01-01T18:05:11.0396802 Sound Definitions +44723d3e77878f1275af20b8fce6eb2001cb64ee assets/tardis_refined/sounds.json diff --git a/forge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e b/forge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e index 01e355213..98e8dbb41 100644 --- a/forge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e +++ b/forge/src/generated/resources/.cache/9fb1092f32d4fcbf9e061ffd718d4ec689c6c95e @@ -1,8 +1,8 @@ -// 1.20.2 2023-12-09T00:48:51.7754985 Recipes +// 1.20.2 2024-01-01T17:33:21.0627898 Recipes 8719cd0f4220434f5c4e19b250d9baf0b7962d26 data/tardis_refined/advancements/recipes/misc/bulk_head_door.json 8269c68dc027027860af7f3e0ffac15e933a3fe7 data/tardis_refined/advancements/recipes/misc/console_configuration.json d920b09dc43fa8d136406e6e132abfb8f6edcacc data/tardis_refined/advancements/recipes/misc/drill.json -550c3b58da6896b2547f1285e429c9ecd5c9f3c3 data/tardis_refined/advancements/recipes/misc/flight_detector.json +9ec080eb7996f790d97817418ce0ee1600744ad9 data/tardis_refined/advancements/recipes/misc/flight_detector.json 3517c6c5d953a58d80a1fb7b27b107811b494061 data/tardis_refined/advancements/recipes/misc/landing_pad.json c4dd71075e63198517197c864403feb215e88940 data/tardis_refined/advancements/recipes/misc/pattern_manipulator.json ab9e449cb689e170d95e6e715310a87d6ab4a3cb data/tardis_refined/advancements/recipes/misc/tardis_door.json diff --git a/forge/src/generated/resources/.cache/c14544f10aa63695e9dcd27172a53ff49784fbb6 b/forge/src/generated/resources/.cache/c14544f10aa63695e9dcd27172a53ff49784fbb6 new file mode 100644 index 000000000..6995c3045 --- /dev/null +++ b/forge/src/generated/resources/.cache/c14544f10aa63695e9dcd27172a53ff49784fbb6 @@ -0,0 +1,2 @@ +// 1.20.2 2024-01-04T14:24:42.8730737 Hums +3d7ceb4ed74a4a7aee53fb9ee43ace87bd30830f data/tardis_refined/tardis_refined/hums/coral_hum.json diff --git a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index 9b6e0698d..b23cf3133 100644 --- a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.20.2 2023-12-22T14:44:08.8611045 Languages: en_us -0afdb1f9c0785ed6cce4beba2ed9d9e69890bb98 assets/tardis_refined/lang/en_us.json +// 1.20.2 2024-01-04T14:11:23.4542146 Languages: en_us +915e4cb02a088556cc10e98579c2d3af6b233d85 assets/tardis_refined/lang/en_us.json diff --git a/forge/src/generated/resources/.cache/c8f6ff9084a307ea1af670e22b8331798da837dd b/forge/src/generated/resources/.cache/c8f6ff9084a307ea1af670e22b8331798da837dd index d7aa2bfd3..ff56c5ab5 100644 --- a/forge/src/generated/resources/.cache/c8f6ff9084a307ea1af670e22b8331798da837dd +++ b/forge/src/generated/resources/.cache/c8f6ff9084a307ea1af670e22b8331798da837dd @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-16T01:02:27.210493 Desktops +// 1.20.2 2024-01-01T17:33:21.0577851 Desktops 8e290467b025585e036665aeea036bf64ce4d426 data/tardis_refined/tardis_refined/desktops/copper.json 0cb37ac84ef411b9f87e44982707c19b2d472ea4 data/tardis_refined/tardis_refined/desktops/coral.json c5455603c085cc04066d5f1e978cfebb9e49c77f data/tardis_refined/tardis_refined/desktops/crystal.json diff --git a/forge/src/generated/resources/.cache/e7bc600dadd489865d6fbbde8c1c01bd136d8060 b/forge/src/generated/resources/.cache/e7bc600dadd489865d6fbbde8c1c01bd136d8060 index a580b1d6b..c2f221a27 100644 --- a/forge/src/generated/resources/.cache/e7bc600dadd489865d6fbbde8c1c01bd136d8060 +++ b/forge/src/generated/resources/.cache/e7bc600dadd489865d6fbbde8c1c01bd136d8060 @@ -1,3 +1,3 @@ -// 1.20.2 2023-12-09T00:48:51.7744808 Tags for minecraft:worldgen/biome mod id tardis_refined +// 1.20.2 2024-01-01T17:33:21.061789 Tags for minecraft:worldgen/biome mod id tardis_refined daa082500631e40fc8cc0cbb30f66a6f937a9471 data/tardis_refined/tags/worldgen/biome/collections/is_mountain_or_ocean.json 545a86cfeda00b9ec3a93f53755d7d212e4f18b2 data/tardis_refined/tags/worldgen/biome/has_structure/tardis_root_cluster.json diff --git a/forge/src/generated/resources/.cache/f681b33583ec37ab445ac361e38402e069dc01f6 b/forge/src/generated/resources/.cache/f681b33583ec37ab445ac361e38402e069dc01f6 index ebde07062..fbe779d7d 100644 --- a/forge/src/generated/resources/.cache/f681b33583ec37ab445ac361e38402e069dc01f6 +++ b/forge/src/generated/resources/.cache/f681b33583ec37ab445ac361e38402e069dc01f6 @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-09T00:48:51.7769417 Tags for minecraft:block mod id tardis_refined +// 1.20.2 2024-01-01T17:33:21.0642942 Tags for minecraft:block mod id tardis_refined 0e47996afffcdda5ea92f1f1147ef01691440a6e data/minecraft/tags/blocks/dragon_immune.json 870aa664161fb6f022473fecdd8e1e1105b476ac data/minecraft/tags/blocks/fences.json 1be1c1975b768bb05f7b50c206454433f0d615d1 data/minecraft/tags/blocks/leaves.json diff --git a/forge/src/generated/resources/.cache/fb1d1450e45f24c16ff9548196e396cd1616c0aa b/forge/src/generated/resources/.cache/fb1d1450e45f24c16ff9548196e396cd1616c0aa index 49527c5d5..84573e4ea 100644 --- a/forge/src/generated/resources/.cache/fb1d1450e45f24c16ff9548196e396cd1616c0aa +++ b/forge/src/generated/resources/.cache/fb1d1450e45f24c16ff9548196e396cd1616c0aa @@ -1,4 +1,4 @@ -// 1.20.2 2023-12-13T11:27:51.6000874 Console Patterns +// 1.20.2 2024-01-01T17:33:21.0587864 Console Patterns 2f482aa36f9bc5c30c7906230e20e11bb5cdb3c6 data/tardis_refined/tardis_refined/patterns/console/copper.json 80cef81ade3d59acf7c629be03ca07ceb29b4e45 data/tardis_refined/tardis_refined/patterns/console/coral.json 51ac36a16e84686df192a41a2c1dc966e266c836 data/tardis_refined/tardis_refined/patterns/console/crystal.json diff --git a/forge/src/generated/resources/assets/tardis_refined/blockstates/internal_door_block.json b/forge/src/generated/resources/assets/tardis_refined/blockstates/internal_door_block.json deleted file mode 100644 index 42b06251d..000000000 --- a/forge/src/generated/resources/assets/tardis_refined/blockstates/internal_door_block.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "variants": { - "facing=east,open=false": { - "model": "tardis_refined:block/terraformer" - }, - "facing=east,open=true": { - "model": "tardis_refined:block/terraformer" - }, - "facing=north,open=false": { - "model": "tardis_refined:block/terraformer" - }, - "facing=north,open=true": { - "model": "tardis_refined:block/terraformer" - }, - "facing=south,open=false": { - "model": "tardis_refined:block/terraformer" - }, - "facing=south,open=true": { - "model": "tardis_refined:block/terraformer" - }, - "facing=west,open=false": { - "model": "tardis_refined:block/terraformer" - }, - "facing=west,open=true": { - "model": "tardis_refined:block/terraformer" - } - } -} \ No newline at end of file diff --git a/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json b/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json index bfd62e9ec..80d88b5c7 100644 --- a/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json +++ b/forge/src/generated/resources/assets/tardis_refined/lang/en_us.json @@ -12,7 +12,6 @@ "block.tardis_refined.flight_detector": "Flight Detector", "block.tardis_refined.growth_stone": "Growth Stone", "block.tardis_refined.hardened_growth_stone": "Hardened Growth Stone", - "block.tardis_refined.internal_door_block": "Internal Door", "block.tardis_refined.landing_pad": "Landing Pad", "block.tardis_refined.root_plant": "Root Plant", "block.tardis_refined.root_shell": "Root Shell", @@ -103,6 +102,7 @@ "ui.tardis_refined.monitor.main.gps": "GPS", "ui.tardis_refined.monitor.main_title": "COMPUTER BANK", "ui.tardis_refined.monitor.no.waypoints": "No Waypoints Saved!", + "ui.tardis_refined.monitor.select.hum": "SOUNDSCAPE", "ui.tardis_refined.monitor.upload.coords": "COORD NAVIGATION", "ui.tardis_refined.monitor.upload.waypoints": "WAYPOINT NAVIGATION", "ui.tardis_refined.monitor.waypoint_name": "Waypoint Name:", diff --git a/forge/src/generated/resources/assets/tardis_refined/sounds.json b/forge/src/generated/resources/assets/tardis_refined/sounds.json index 9c79cdebd..9292c9336 100644 --- a/forge/src/generated/resources/assets/tardis_refined/sounds.json +++ b/forge/src/generated/resources/assets/tardis_refined/sounds.json @@ -17,6 +17,20 @@ ], "subtitle": "sound.destination_ding.subtitle" }, + "hum_coral": { + "sounds": [ + "tardis_refined:tardis/interior_hums/humcoral" + ], + "subtitle": "sound.hum_coral.subtitle" + }, + "interior_creaks": { + "sounds": [ + "tardis_refined:tardis/ambience/interior_creaks_1", + "tardis_refined:tardis/ambience/interior_creaks_2", + "tardis_refined:tardis/ambience/interior_creaks_3" + ], + "subtitle": "sound.interior_creaks.subtitle" + }, "pattern_manipulator": { "sounds": [ "tardis_refined:gadgets/pattern_manipulator" @@ -59,12 +73,6 @@ ], "subtitle": "sound.tardis_takeoff.subtitle" }, - "test_hum": { - "sounds": [ - "tardis_refined:tardis/test_hum" - ], - "subtitle": "sound.test_hum.subtitle" - }, "time_blast": { "sounds": [ "tardis_refined:tardis/time_blast" diff --git a/forge/src/generated/resources/data/tardis_refined/advancements/recipes/misc/flight_detector.json b/forge/src/generated/resources/data/tardis_refined/advancements/recipes/misc/flight_detector.json index f840f8364..d7559eabf 100644 --- a/forge/src/generated/resources/data/tardis_refined/advancements/recipes/misc/flight_detector.json +++ b/forge/src/generated/resources/data/tardis_refined/advancements/recipes/misc/flight_detector.json @@ -1,7 +1,7 @@ { "parent": "minecraft:recipes/root", "criteria": { - "has_dalight_detector": { + "has_daylight_detector": { "conditions": { "items": [ { @@ -23,7 +23,7 @@ "requirements": [ [ "has_the_recipe", - "has_dalight_detector" + "has_daylight_detector" ] ], "rewards": { diff --git a/forge/src/generated/resources/data/tardis_refined/loot_tables/blocks/internal_door_block.json b/forge/src/generated/resources/data/tardis_refined/loot_tables/blocks/internal_door_block.json deleted file mode 100644 index 85870c586..000000000 --- a/forge/src/generated/resources/data/tardis_refined/loot_tables/blocks/internal_door_block.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "type": "minecraft:block", - "pools": [ - { - "bonus_rolls": 0.0, - "conditions": [ - { - "condition": "minecraft:survives_explosion" - } - ], - "entries": [ - { - "type": "minecraft:item", - "name": "minecraft:air" - } - ], - "rolls": 1.0 - } - ], - "random_sequence": "tardis_refined:blocks/internal_door_block" -} \ No newline at end of file diff --git a/forge/src/generated/resources/data/tardis_refined/tags/entity_types/tardis_teleport_blacklist.json b/forge/src/generated/resources/data/tardis_refined/tags/entity_types/tardis_teleport_blacklist.json new file mode 100644 index 000000000..b975c40eb --- /dev/null +++ b/forge/src/generated/resources/data/tardis_refined/tags/entity_types/tardis_teleport_blacklist.json @@ -0,0 +1,7 @@ +{ + "values": [ + "tardis_refined:console_control", + "minecraft:ender_dragon", + "minecraft:wither" + ] +} \ No newline at end of file diff --git a/forge/src/generated/resources/data/tardis_refined/tardis_refined/hums/coral_hum.json b/forge/src/generated/resources/data/tardis_refined/tardis_refined/hums/coral_hum.json new file mode 100644 index 000000000..6fb0d6811 --- /dev/null +++ b/forge/src/generated/resources/data/tardis_refined/tardis_refined/hums/coral_hum.json @@ -0,0 +1,8 @@ +{ + "ambient_sounds": [ + "tardis_refined:interior_creaks" + ], + "hum_sound": "tardis_refined:hum_coral", + "id": "tardis_refined:coral_hum", + "name_component": "{\"color\":\"gold\",\"text\":\"Coral Hum\"}" +} \ No newline at end of file diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/HumProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/HumProvider.java new file mode 100644 index 000000000..2eca53896 --- /dev/null +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/HumProvider.java @@ -0,0 +1,82 @@ +package whocraft.tardis_refined.common.data; + +import com.google.common.base.Preconditions; +import com.google.gson.JsonObject; +import com.mojang.serialization.JsonOps; +import net.minecraft.data.CachedOutput; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.DataProvider; +import net.minecraft.resources.ResourceLocation; +import whocraft.tardis_refined.TardisRefined; +import whocraft.tardis_refined.common.hum.HumEntry; +import whocraft.tardis_refined.common.hum.TardisHums; +import whocraft.tardis_refined.registry.SoundRegistry; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +public class HumProvider implements DataProvider { + + protected final DataGenerator generator; + private final boolean addDefaults; + protected Map data = new HashMap<>(); + + public HumProvider(DataGenerator generator) { + this(generator, true); + } + + public HumProvider(DataGenerator generator, boolean addDefaults) { + Preconditions.checkNotNull(generator); + this.generator = generator; + this.addDefaults = addDefaults; + } + + protected void addHums() { + } + + @Override + public CompletableFuture run(CachedOutput arg) { + this.data.clear(); + + final List> futures = new ArrayList<>(); + + if (this.addDefaults) { + TardisHums.registerDefaultHums(); + data.putAll(TardisHums.getDefaultHums()); + data.put(TardisHums.getDefaultHum().getIdentifier(), TardisHums.getDefaultHum()); + } + + this.addHums(); + + if (!data.isEmpty()) { + data.forEach((key, hum) -> { + TardisRefined.LOGGER.debug("Writing Hum {}", key); + try { + JsonObject currentHum = HumEntry.codec().encodeStart(JsonOps.INSTANCE, hum).get() + .ifRight(right -> { + TardisRefined.LOGGER.error(right.message()); + }).orThrow().getAsJsonObject(); + String outputPath = "data/" + hum.getIdentifier().getNamespace() + "/" + TardisHums.getReloadListener().getFolderName() + "/" + hum.getIdentifier().getPath().replace("/", "_") + ".json"; + futures.add(DataProvider.saveStable(arg, currentHum, generator.getPackOutput().getOutputFolder().resolve(outputPath))); + } catch (Exception exception) { + TardisRefined.LOGGER.debug("Issue writing Hum {}! Error: {}", hum.getIdentifier(), exception.getMessage()); + } + }); + } + return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)); + } + + @Override + public String getName() { + return "Hums"; + } + + protected void addHum(HumEntry hum) { + TardisRefined.LOGGER.info("Adding Hum to datagen {}", hum.getIdentifier()); + data.put(hum.getIdentifier(), hum); + } + +} diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java index 1e71a48a6..9eefe4972 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/LangProviderEnglish.java @@ -121,6 +121,7 @@ protected void addTranslations() { add(ModMessages.UI_MONITOR_WAYPOINTS, "WAYPOINTS"); add(ModMessages.UI_MONITOR_UPLOAD_WAYPOINTS, "WAYPOINT NAVIGATION"); add(ModMessages.UI_MONITOR_UPLOAD_COORDS, "COORD NAVIGATION"); + add(ModMessages.UI_MONITOR_SELECT_HUM, "SOUNDSCAPE"); add(ModMessages.UI_MONITOR_GPS, "GPS"); add(ModMessages.UI_MONITOR_DESTINATION, "Destination"); add(ModMessages.UI_LIST_SELECTION, "Currently selected: &s"); diff --git a/forge/src/main/java/whocraft/tardis_refined/common/data/SoundProvider.java b/forge/src/main/java/whocraft/tardis_refined/common/data/SoundProvider.java index c4cff58d0..902db564d 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/data/SoundProvider.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/data/SoundProvider.java @@ -31,7 +31,8 @@ public void registerSounds() { add(SoundRegistry.DESTINATION_DING.get(), basicSound("destination_ding", new ResourceLocation(TardisRefined.MODID, "tardis/destination_ding"))); add(SoundRegistry.ARS_HUM.get(), basicSound("ars_hum", new ResourceLocation(TardisRefined.MODID, "tardis/ars/ars_hum"))); add(SoundRegistry.BULKHEAD_LOCKED.get(), basicSound("bulkhead_locked", new ResourceLocation(TardisRefined.MODID, "blocks/bulkhead_locked"))); - add(SoundRegistry.TEST_HUM.get(), basicSound("test_hum", new ResourceLocation(TardisRefined.MODID, "tardis/test_hum"))); + add(SoundRegistry.HUM_CORAL.get(), basicSound("hum_coral", new ResourceLocation(TardisRefined.MODID, "tardis/interior_hums/humcoral"))); + add(SoundRegistry.INTERIOR_CREAKS.get(), basicSound("interior_creaks", new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_1"), new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_2"), new ResourceLocation(TardisRefined.MODID, "tardis/ambience/interior_creaks_3"))); } diff --git a/forge/src/main/java/whocraft/tardis_refined/common/dimension/neoforge/DimensionHandlerImpl.java b/forge/src/main/java/whocraft/tardis_refined/common/dimension/neoforge/DimensionHandlerImpl.java index 44be3b6f1..f495341bf 100644 --- a/forge/src/main/java/whocraft/tardis_refined/common/dimension/neoforge/DimensionHandlerImpl.java +++ b/forge/src/main/java/whocraft/tardis_refined/common/dimension/neoforge/DimensionHandlerImpl.java @@ -23,7 +23,7 @@ import net.minecraft.world.level.storage.WorldData; import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.common.dimension.DimensionHandler; -import whocraft.tardis_refined.common.network.messages.SyncLevelListMessage; +import whocraft.tardis_refined.common.network.messages.sync.SyncLevelListMessage; import java.io.File; import java.io.FileWriter; 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 b6e115cac..b0b8010c8 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/CommonBus.java @@ -13,6 +13,7 @@ import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.command.TardisRefinedCommand; import whocraft.tardis_refined.common.dimension.TardisTeleportData; +import whocraft.tardis_refined.common.hum.TardisHums; import whocraft.tardis_refined.common.tardis.TardisDesktops; import whocraft.tardis_refined.common.util.MiscHelper; import whocraft.tardis_refined.patterns.ConsolePatterns; @@ -37,6 +38,7 @@ public static void onDatapack(AddReloadListenerEvent addReloadListenerEvent) { addReloadListenerEvent.addListener(TardisDesktops.getReloadListener()); addReloadListenerEvent.addListener(ShellPatterns.getReloadListener()); + addReloadListenerEvent.addListener(TardisHums.getReloadListener()); } diff --git a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java index e055c739b..16a20f4d0 100644 --- a/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java +++ b/forge/src/main/java/whocraft/tardis_refined/neoforge/TardisRefinedForge.java @@ -51,6 +51,7 @@ public void onGatherData(GatherDataEvent e) { generator.addProvider(e.includeServer(), new RecipeProvider(generator, e.getLookupProvider())); generator.addProvider(e.includeServer(), new ConsolePatternProvider(generator)); generator.addProvider(e.includeServer(), new DesktopProvider(generator)); + generator.addProvider(e.includeServer(), new HumProvider(generator)); generator.addProvider(e.includeServer(), new ShellPatternProvider(generator, TardisRefined.MODID)); //Tags