Skip to content

Commit

Permalink
Allow creative console unit breaking if its not in the TARDIS (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
CommandrMoose authored Apr 25, 2024
1 parent 77696e8 commit 57ad8f8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import whocraft.tardis_refined.common.util.PlayerUtil;
import whocraft.tardis_refined.constants.ModMessages;
import whocraft.tardis_refined.patterns.ConsolePatterns;
import whocraft.tardis_refined.registry.TRDimensionTypes;


public class GlobalConsoleBlock extends BaseEntityBlock {
Expand Down Expand Up @@ -107,6 +108,8 @@ public void destroy(LevelAccessor levelAccessor, BlockPos blockPos, BlockState b
globalConsoleBlock.killControls();
}

levelAccessor.playSound(null, blockPos, SoundEvents.ANVIL_BREAK, SoundSource.BLOCKS, 1, 1);

super.destroy(levelAccessor, blockPos, blockState);
}

Expand Down Expand Up @@ -157,8 +160,8 @@ public void animateTick(BlockState blockState, Level level, BlockPos blockPos, R
@Override
public InteractionResult use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult) {

// Creative only: Quickly complete the cooldown.
if (level instanceof ServerLevel serverLevel) {

if (level instanceof ServerLevel serverLevel && level.dimensionTypeId() == TRDimensionTypes.TARDIS) {

TardisLevelOperator.get(serverLevel).ifPresent(operator -> {
TardisPilotingManager pilotingManager = operator.getPilotingManager();
Expand All @@ -183,7 +186,7 @@ public InteractionResult use(BlockState blockState, Level level, BlockPos blockP

});


// Creative only: Quickly complete the cooldown.
if (player.isCreative() && player.getItemInHand(interactionHand).getItem() == Items.ICE) {
var operatorOptional = TardisLevelOperator.get(serverLevel);
if (operatorOptional.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import whocraft.tardis_refined.common.util.MiscHelper;
import whocraft.tardis_refined.constants.NbtConstants;
import whocraft.tardis_refined.registry.TRControlRegistry;
import whocraft.tardis_refined.registry.TRDimensionTypes;
import whocraft.tardis_refined.registry.TREntityRegistry;

public class ControlEntity extends Entity {
Expand Down Expand Up @@ -310,6 +311,10 @@ public void tick() {
onClientTick(this.level());
}

if (level().dimensionTypeId() != TRDimensionTypes.TARDIS) {
discard();
}

}

private void onServerTick(ServerLevel serverLevel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static boolean shouldCancelBreaking(Level world, Entity entity, BlockPos
}
}

return state.getBlock() instanceof GlobalConsoleBlock || state.getBlock() instanceof ShellBaseBlock;
return (state.getBlock() instanceof GlobalConsoleBlock && world.dimensionTypeId() == TRDimensionTypes.TARDIS) || state.getBlock() instanceof ShellBaseBlock;
}

public static String getCleanDimensionName(ResourceKey<Level> dimensionKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ protected void addTranslations() {
add(ModMessages.DESCEND_KEY, "Descend: %s");

/*Upgrades*/
addUpgrade(Upgrades.COORDINATE_INPUT.get(), "Coordinate Input", "Allows the Pilot to input coordinates with the monitor");
addUpgrade(Upgrades.CHAMELEON_CIRCUIT_SYSTEM.get(), "Chameleon Circuit", "Allows the TARDIS to change it's shape");
addUpgrade(Upgrades.DEFENSE_SYSTEM.get(), "Defense System", "Enables Defense Protocols");
addUpgrade(Upgrades.WAYPOINTS.get(), "Waypoints", "Allows the Pilot to create saved locations");
Expand Down

0 comments on commit 57ad8f8

Please sign in to comment.