Skip to content

Commit

Permalink
Potentially fixed issue where terraformer sometimes did not operate
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeryn99 committed Dec 26, 2023
1 parent a7c6db5 commit 93cfcb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
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
Expand Up @@ -67,6 +67,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 @@ -81,10 +82,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 @@ -284,7 +284,6 @@ public boolean isInAirlock(LivingEntity livingEntity) {
}

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

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

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

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

}
}
Expand Down

0 comments on commit 93cfcb1

Please sign in to comment.