Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/minecraft/1.20' into minecraft/1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
50ap5ud5 committed Dec 26, 2023
2 parents f65da2e + 93cfcb1 commit ab66408
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<UpgradeWidget> entries = new ArrayList<>();
private final List<Connection> connections = new ArrayList<>();
Expand All @@ -47,14 +47,15 @@ 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);
}

public void populate(UpgradeHandler upgradeHandlerClient) {
this.entries.clear();
this.connections.clear();
CompoundTag newData = upgradeHandlerClient.saveData(new CompoundTag());
this.upgradeHandler.loadData(newData);
List<UpgradeWidget> root = new LinkedList<>();

// Create entry for each ability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.jetbrains.annotations.NotNull;
import whocraft.tardis_refined.common.capability.TardisLevelOperator;
import whocraft.tardis_refined.common.tardis.TardisDesktops;
import whocraft.tardis_refined.common.tardis.manager.TardisInteriorManager;
import whocraft.tardis_refined.registry.DimensionTypes;

import java.util.stream.Stream;
Expand Down Expand Up @@ -85,13 +86,14 @@ public void onPlace(BlockState blockState, Level level, BlockPos blockPos, Block
if (level instanceof ServerLevel serverLevel) {
if (checkIfStructure(serverLevel, blockPos)) {
TardisLevelOperator.get(serverLevel).ifPresent(cap -> {
if (cap.getInteriorManager().isWaitingToGenerate()) {
TardisInteriorManager interiorManager = cap.getInteriorManager();
if (interiorManager.isWaitingToGenerate()) {
level.destroyBlock(blockPos, true);
} else {
if (cap.getInteriorManager().isCave()) {
cap.getInteriorManager().prepareDesktop(TardisDesktops.FACTORY_THEME);
if (interiorManager.isCave()) {
interiorManager.prepareDesktop(TardisDesktops.FACTORY_THEME);
destroyStructure(serverLevel, blockPos);
serverLevel.setBlock(blockPos, blockState.setValue(ACTIVE, true), 3);
serverLevel.setBlock(blockPos, blockState.setValue(ACTIVE, true), Block.UPDATE_ALL);
}
}
});
Expand Down Expand Up @@ -121,8 +123,9 @@ public void onRemove(BlockState blockState, Level level, BlockPos blockPos, Bloc
if (level instanceof ServerLevel serverLevel) {
if (blockState.getValue(ACTIVE)) {
TardisLevelOperator.get(serverLevel).ifPresent(cap -> {
if (cap.getInteriorManager().isWaitingToGenerate()) {
cap.getInteriorManager().cancelDesktopChange();
TardisInteriorManager interiorManager = cap.getInteriorManager();
if (interiorManager.isWaitingToGenerate()) {
interiorManager.cancelDesktopChange();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<BulkHeadDoorBlockEntity> {

Expand All @@ -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);
}

/**
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public CompoundTag getUpdateTag() {
protected void saveAdditional(CompoundTag pTag) {
if (this.TARDIS_ID == null) {
TardisRefined.LOGGER.error("Error in saveAdditional: null Tardis ID (could this be an invalid block?) [" + this.getBlockPos().toShortString() + "]");
return;
}

super.saveAdditional(pTag);
Expand All @@ -83,10 +84,7 @@ public ClientboundBlockEntityDataPacket getUpdatePacket() {

public boolean shouldSetup() {
if (!this.level.isClientSide()) {
if (this.TARDIS_ID != null) {
return false;
}
return true;
return this.TARDIS_ID == null;
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down Expand Up @@ -65,8 +69,8 @@ public static void buildAirlockEntranceFromStructure(StructureTemplate template,
TardisLevelOperator.get(level).ifPresent(cap -> {
Optional<StructureTemplate> 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);
Expand All @@ -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<StructureTemplate> structureNBT = operator.getLevel().getStructureManager().get(new ResourceLocation(TardisRefined.MODID, "corridors/corridor_hub_roomless"));
Optional<StructureTemplate> 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<StructureTemplate> 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<StructureTemplate> 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) {
Expand All @@ -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));
Expand All @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ public boolean isInAirlock(LivingEntity livingEntity) {
}

public void generateDesktop(DesktopTheme theme) {
setCurrentTheme(theme);

if (operator.getLevel() instanceof ServerLevel serverLevel) {

Expand All @@ -303,6 +302,7 @@ public void generateDesktop(DesktopTheme theme) {

// Generate Desktop Interior
TardisArchitectureHandler.generateDesktop(serverLevel, theme);
setCurrentTheme(theme);

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SoundRegistry {
public static final RegistrySupplier<SoundEvent> STATIC = setUpSound("static");
public static final RegistrySupplier<SoundEvent> DESTINATION_DING = setUpSound("destination_ding");
public static final RegistrySupplier<SoundEvent> ARS_HUM = setUpSound("ars_hum");
public static final RegistrySupplier<SoundEvent> BULKHEAD_LOCKED = setUpSound("bulkhead_locked");
public static final RegistrySupplier<SoundEvent> TEST_HUM = setUpSound("test_hum");

private static RegistrySupplier<SoundEvent> setUpSound(String soundName) {
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}

Expand Down

0 comments on commit ab66408

Please sign in to comment.