diff --git a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradeTab.java b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradeTab.java index cc00b2e60..859b6cba2 100644 --- a/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradeTab.java +++ b/common/src/main/java/whocraft/tardis_refined/client/screen/upgrades/UpgradeTab.java @@ -5,6 +5,7 @@ import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; @@ -28,7 +29,6 @@ public class UpgradeTab { private final UpgradeTabType type; private final int index; public final UpgradeHandler upgradeHandler; - private final ItemStack icon; private final Component title; private final List entries = new ArrayList<>(); private final List connections = new ArrayList<>(); @@ -47,7 +47,6 @@ public UpgradeTab(Minecraft minecraft, UpgradesScreen UpgradesScreen, UpgradeTab this.type = tabType; this.index = i; this.upgradeHandler = powerHolder; - this.icon = new ItemStack(Items.COOKED_PORKCHOP); this.title = Component.literal(""); this.populate(powerHolder); } @@ -55,6 +54,8 @@ public UpgradeTab(Minecraft minecraft, UpgradesScreen UpgradesScreen, UpgradeTab public void populate(UpgradeHandler upgradeHandlerClient) { this.entries.clear(); this.connections.clear(); + CompoundTag newData = upgradeHandlerClient.saveData(new CompoundTag()); + this.upgradeHandler.loadData(newData); List root = new LinkedList<>(); // Create entry for each ability diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/BulkHeadDoorBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/BulkHeadDoorBlockEntity.java index 224d9f77b..e5f94ac82 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/BulkHeadDoorBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/door/BulkHeadDoorBlockEntity.java @@ -1,6 +1,7 @@ package whocraft.tardis_refined.common.blockentity.door; import net.minecraft.core.BlockPos; +import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.player.Player; @@ -11,6 +12,10 @@ import net.minecraft.world.level.block.state.BlockState; import whocraft.tardis_refined.common.block.door.BulkHeadDoorBlock; import whocraft.tardis_refined.registry.BlockEntityRegistry; +import whocraft.tardis_refined.registry.SoundRegistry; + +import static whocraft.tardis_refined.common.block.door.BulkHeadDoorBlock.LOCKED; +import static whocraft.tardis_refined.common.block.door.BulkHeadDoorBlock.OPEN; public class BulkHeadDoorBlockEntity extends BlockEntity implements BlockEntityTicker { @@ -21,12 +26,8 @@ public BulkHeadDoorBlockEntity(BlockPos blockPos, BlockState blockState) { @Override public void tick(Level level, BlockPos blockPos, BlockState blockState, BulkHeadDoorBlockEntity blockEntity) { - if (!blockState.getValue(BulkHeadDoorBlock.LOCKED) && blockState.canSurvive(level, blockPos)) { - Player player = level.getNearestPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 2.5f, false); - if (player != null) { - toggleDoor(level, blockPos, blockState, blockState.getValue(BulkHeadDoorBlock.OPEN)); - } - } + Player player = level.getNearestPlayer(blockPos.getX(), blockPos.getY(), blockPos.getZ(), 2.5f, false); toggleDoor(level, blockPos, blockState, player != null); + toggleDoor(level, blockPos, blockState, player != null); } /** @@ -38,8 +39,16 @@ public void tick(Level level, BlockPos blockPos, BlockState blockState, BulkHead * @param isOpen The current open state of the door. */ public void toggleDoor(Level level, BlockPos blockPos, BlockState blockState, boolean isOpen) { - level.playSound(null, blockPos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 1, 1); - level.setBlock(blockPos, blockState.setValue(BulkHeadDoorBlock.OPEN, isOpen), Block.UPDATE_CLIENTS); + + /* if(blockState.getValue(LOCKED) && !blockState.getValue(OPEN)){ + level.playSound(null, blockPos, SoundRegistry.BULKHEAD_LOCKED.get(), SoundSource.BLOCKS, 1, 1); + return; + }*/ + + if(level.getBlockState(blockPos).hasProperty(OPEN) && level.getBlockState(blockPos).getValue(OPEN) != isOpen) { + level.playSound(null, blockPos, !isOpen ? SoundEvents.PISTON_EXTEND : SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 1, 1); + } + level.setBlock(blockPos, blockState.setValue(OPEN, isOpen), Block.UPDATE_CLIENTS); } } diff --git a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/UpgradeHandler.java b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/UpgradeHandler.java index 3f23dde43..c2b0b0a77 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/UpgradeHandler.java +++ b/common/src/main/java/whocraft/tardis_refined/common/capability/upgrades/UpgradeHandler.java @@ -157,7 +157,7 @@ public void unlockUpgrade(Upgrade upgrade) { upgrade.onUnlocked(this.tardisLevelOperator, this); if(this.tardisLevelOperator.getLevel() instanceof ServerLevel serverLevel) { - generateArsTree(serverLevel); + generateArsTree(tardisLevelOperator, serverLevel); } TardisEvents.UPGRADE_UNLOCKED.invoker().onUpgradeUnlock(this.tardisLevelOperator, upgrade); diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisArchitectureHandler.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisArchitectureHandler.java index 402129f7c..fb0e18a15 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisArchitectureHandler.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/TardisArchitectureHandler.java @@ -16,7 +16,9 @@ import whocraft.tardis_refined.registry.BlockRegistry; import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.function.Consumer; // Responsible for all the tedious generation of the desktop; public class TardisArchitectureHandler { @@ -25,12 +27,14 @@ public class TardisArchitectureHandler { public static final BlockPos CORRIDOR_ENTRY_POS = new BlockPos(1000, 100, 0); public static final int INTERIOR_SIZE = 150; + public static String currentArsStage = "one"; + public static void generateDesktop(ServerLevel operator, DesktopTheme theme) { TardisRefined.LOGGER.debug(String.format("Attempting to generate desktop theme: %s for TARDIS.", theme.getIdentifier())); // Fill the area out. BlockPos corner = new BlockPos(DESKTOP_CENTER_POS.getX() - INTERIOR_SIZE, operator.getMinBuildHeight() + 75, DESKTOP_CENTER_POS.getZ() - INTERIOR_SIZE); - BlockPos farCorner = new BlockPos(DESKTOP_CENTER_POS.getX() + INTERIOR_SIZE, operator.getMaxBuildHeight() -75, DESKTOP_CENTER_POS.getZ() + INTERIOR_SIZE); + BlockPos farCorner = new BlockPos(DESKTOP_CENTER_POS.getX() + INTERIOR_SIZE, operator.getMaxBuildHeight() - 75, DESKTOP_CENTER_POS.getZ() + INTERIOR_SIZE); for (BlockPos pos : BlockPos.betweenClosed(corner, farCorner)) { operator.removeBlock(pos, false); @@ -65,8 +69,8 @@ public static void buildAirlockEntranceFromStructure(StructureTemplate template, TardisLevelOperator.get(level).ifPresent(cap -> { Optional structureNBT = level.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "corridors/airlock_entrance")); structureNBT.ifPresent(structure -> { - BlockPos offsetPosition = new BlockPos(3,2,0); - structure.placeInWorld(level.getLevel(), pos.subtract(offsetPosition) , pos.subtract(offsetPosition) , new StructurePlaceSettings(), level.getLevel().random, 3); + BlockPos offsetPosition = new BlockPos(3, 2, 0); + structure.placeInWorld(level.getLevel(), pos.subtract(offsetPosition), pos.subtract(offsetPosition), new StructurePlaceSettings(), level.getLevel().random, 3); cap.getInteriorManager().setCorridorAirlockCenter(pos.south(2)); level.setBlock(pos, level.getBlockState(pos).setValue(BulkHeadDoorBlock.LOCKED, false), 2); @@ -78,34 +82,38 @@ public static void buildAirlockEntranceFromStructure(StructureTemplate template, } } - public static void generateEssentialCorridors(ServerLevel operator) { + public static void generateEssentialCorridors(ServerLevel serverLevel) { // Generate corridor hub - Optional structureNBT = operator.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "corridors/corridor_hub_roomless")); + Optional structureNBT = serverLevel.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "corridors/corridor_hub_roomless")); structureNBT.ifPresent(structure -> { BlockPos offsetPosition = new BlockPos(13, 28, 5); - structure.placeInWorld(operator.getLevel(), CORRIDOR_ENTRY_POS.subtract(offsetPosition), CORRIDOR_ENTRY_POS.subtract(offsetPosition), new StructurePlaceSettings(), operator.getLevel().random, 3); + structure.placeInWorld(serverLevel.getLevel(), CORRIDOR_ENTRY_POS.subtract(offsetPosition), CORRIDOR_ENTRY_POS.subtract(offsetPosition), new StructurePlaceSettings(), serverLevel.getLevel().random, 3); }); - generateArsTree(operator); + TardisLevelOperator.get(serverLevel).ifPresent(tardisLevelOperator -> generateArsTree(tardisLevelOperator, serverLevel)); // Generate workshop. - structureNBT = operator.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "rooms/workshop")); + structureNBT = serverLevel.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "rooms/workshop")); structureNBT.ifPresent(structure -> { - BlockPos position = new BlockPos(977,99,9); - structure.placeInWorld(operator.getLevel(), position, position, new StructurePlaceSettings(), operator.getLevel().random, Block.UPDATE_ALL); + BlockPos position = new BlockPos(977, 99, 9); + structure.placeInWorld(serverLevel.getLevel(), position, position, new StructurePlaceSettings(), serverLevel.getLevel().random, Block.UPDATE_ALL); }); } - public static void generateArsTree(ServerLevel level) { - TardisLevelOperator.get(level).ifPresent(tardisLevelOperator -> { - Optional structureNBT = level.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "rooms/ars/room_ars_stage_" + tardisLevelOperator.getUpgradeHandler().getProgressLevel())); - structureNBT.ifPresent(structure -> { - BlockPos position = new BlockPos(1011,97,3); - structure.placeInWorld(level.getLevel(), position, position, new StructurePlaceSettings(), level.getLevel().random, Block.UPDATE_ALL); - }); + public static void generateArsTree(TardisLevelOperator tardisLevelOperator, ServerLevel level) { + if (!currentArsStage.equals("one") && Objects.equals(tardisLevelOperator.getUpgradeHandler().getProgressLevel(), currentArsStage)) + return; + + currentArsStage = tardisLevelOperator.getUpgradeHandler().getProgressLevel(); + + Optional structureNBT = level.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "rooms/ars/room_ars_stage_" + currentArsStage)); + structureNBT.ifPresent(structure -> { + BlockPos position = new BlockPos(1011, 97, 3); + structure.placeInWorld(level.getLevel(), position, position, new StructurePlaceSettings(), level.getLevel().random, Block.UPDATE_ALL); }); + } public static boolean setInteriorDoorFromStructure(StructureTemplate template, ServerLevel level) { @@ -114,7 +122,7 @@ public static boolean setInteriorDoorFromStructure(StructureTemplate template, S BlockPos maxPos = new BlockPos(minPos.getX() + template.getSize().getX(), minPos.getY() + template.getSize().getY(), minPos.getZ() + template.getSize().getZ() - ); + ); //First set the internal door to null so that we aren't caching the previous desktop's internal door TardisLevelOperator.get(level).ifPresent(cap -> cap.setInternalDoor(null)); @@ -129,7 +137,7 @@ public static boolean setInteriorDoorFromStructure(StructureTemplate template, S } public static BlockPos calculateArcOffset(StructureTemplate structureTemplate, BlockPos centerPos) { - return new BlockPos(centerPos.getX() - structureTemplate.getSize().getX() / 2, centerPos.getY() - structureTemplate.getSize().getY() / 2,centerPos.getZ() - structureTemplate.getSize().getZ() / 2); + return new BlockPos(centerPos.getX() - structureTemplate.getSize().getX() / 2, centerPos.getY() - structureTemplate.getSize().getY() / 2, centerPos.getZ() - structureTemplate.getSize().getZ() / 2); } - + } 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 67bf412e4..46931e122 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/SoundRegistry.java @@ -18,6 +18,7 @@ public class SoundRegistry { public static final RegistrySupplier STATIC = setUpSound("static"); 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"); private static RegistrySupplier setUpSound(String 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 new file mode 100644 index 000000000..848100ec1 Binary files /dev/null and b/common/src/main/resources/assets/tardis_refined/sounds/blocks/bulkhead_locked.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 27b9761ce..20c33b7e0 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/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e b/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e index 015bf9536..996febf04 100644 --- a/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e +++ b/forge/src/generated/resources/.cache/735031f3addf80804addae5e3f53249900116f1e @@ -1,2 +1,2 @@ -// 1.20.2 2023-12-15T23:31:01.2684 Sound Definitions -af46e2a431d190adcb7142234979fa721ca75855 assets/tardis_refined/sounds.json +// 1.20.2 2023-12-22T14:44:08.8631383 Sound Definitions +4875e9832141aea2449ebba45177460bb6eed8a0 assets/tardis_refined/sounds.json diff --git a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 index 3d66067d1..9b6e0698d 100644 --- a/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 +++ b/forge/src/generated/resources/.cache/c622617f6fabf890a00b9275cd5f643584a8a2c8 @@ -1,2 +1,2 @@ -// 1.20.2 2023-12-21T01:13:46.4354098 Languages: en_us -b3b6b26fd2fb1d1a118a3fda307b43f323efaf3b assets/tardis_refined/lang/en_us.json +// 1.20.2 2023-12-22T14:44:08.8611045 Languages: en_us +0afdb1f9c0785ed6cce4beba2ed9d9e69890bb98 assets/tardis_refined/lang/en_us.json diff --git a/forge/src/generated/resources/assets/tardis_refined/sounds.json b/forge/src/generated/resources/assets/tardis_refined/sounds.json index cda29666e..9c79cdebd 100644 --- a/forge/src/generated/resources/assets/tardis_refined/sounds.json +++ b/forge/src/generated/resources/assets/tardis_refined/sounds.json @@ -5,6 +5,12 @@ ], "subtitle": "sound.ars_hum.subtitle" }, + "bulkhead_locked": { + "sounds": [ + "tardis_refined:blocks/bulkhead_locked" + ], + "subtitle": "sound.bulkhead_locked.subtitle" + }, "destination_ding": { "sounds": [ "tardis_refined:tardis/destination_ding" 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 a3f6c880a..c4cff58d0 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 @@ -30,6 +30,7 @@ public void registerSounds() { add(SoundRegistry.STATIC.get(), basicSound("static", new ResourceLocation(TardisRefined.MODID, "ui/static"))); 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"))); }