diff --git a/common/src/main/java/whocraft/tardis_refined/common/block/shell/GlobalShellBlock.java b/common/src/main/java/whocraft/tardis_refined/common/block/shell/GlobalShellBlock.java index 9d1f05340..9f46bdfb1 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/block/shell/GlobalShellBlock.java +++ b/common/src/main/java/whocraft/tardis_refined/common/block/shell/GlobalShellBlock.java @@ -6,11 +6,9 @@ import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -18,6 +16,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition; +import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; @@ -25,25 +24,21 @@ import org.jetbrains.annotations.Nullable; import whocraft.tardis_refined.common.blockentity.shell.GlobalShellBlockEntity; import whocraft.tardis_refined.common.blockentity.shell.ShellBaseBlockEntity; -import whocraft.tardis_refined.common.capability.TardisLevelOperator; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; public class GlobalShellBlock extends ShellBaseBlock{ + public static final BooleanProperty LIT = BooleanProperty.create("lit"); public GlobalShellBlock(Properties properties) { super(properties); - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPEN, false).setValue(WATERLOGGED, false).setValue(LOCKED, false)); - } - - @Override - public int getLightBlock(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos) { - return super.getLightBlock(blockState, blockGetter, blockPos); + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(OPEN, false).setValue(WATERLOGGED, false).setValue(LOCKED, false).setValue(LIT, false)); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { super.createBlockStateDefinition(builder); + builder.add(LIT); } @Override diff --git a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/GlobalShellBlockEntity.java b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/GlobalShellBlockEntity.java index f263dd43b..b00bc5ff8 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/GlobalShellBlockEntity.java +++ b/common/src/main/java/whocraft/tardis_refined/common/blockentity/shell/GlobalShellBlockEntity.java @@ -1,7 +1,6 @@ package whocraft.tardis_refined.common.blockentity.shell; import net.minecraft.core.BlockPos; -import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; @@ -9,18 +8,14 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; -import whocraft.tardis_refined.TardisRefined; import whocraft.tardis_refined.common.block.shell.GlobalShellBlock; import whocraft.tardis_refined.common.block.shell.ShellBaseBlock; import whocraft.tardis_refined.common.capability.TardisLevelOperator; import whocraft.tardis_refined.common.dimension.DimensionHandler; import whocraft.tardis_refined.common.items.KeyItem; import whocraft.tardis_refined.common.tardis.themes.ShellTheme; -import whocraft.tardis_refined.common.util.RegistryHelper; import whocraft.tardis_refined.constants.NbtConstants; -import whocraft.tardis_refined.constants.ResourceConstants; import whocraft.tardis_refined.patterns.ShellPattern; import whocraft.tardis_refined.patterns.ShellPatterns; import whocraft.tardis_refined.registry.BlockEntityRegistry; @@ -30,7 +25,6 @@ public class GlobalShellBlockEntity extends ShellBaseBlockEntity { private ResourceLocation shellTheme; - private ShellPattern basePattern; 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 8380f6b05..89678bfe5 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 @@ -98,7 +98,11 @@ public void setShellTheme(ResourceLocation theme, boolean setupTardis, TardisNav // Check if its our default global shell. if (state.getBlock() instanceof GlobalShellBlock globalShellBlock) { - lastKnownLocationLevel.setBlock(lastKnownLocationPosition, state.setValue(GlobalShellBlock.REGEN, false), Block.UPDATE_CLIENTS); + + ShellTheme shellTheme = ShellTheme.getShellTheme(theme); + boolean shouldProduceLight = shellTheme.producesLight(); + + lastKnownLocationLevel.setBlock(lastKnownLocationPosition, state.setValue(GlobalShellBlock.REGEN, false).setValue(GlobalShellBlock.LIT, shouldProduceLight), Block.UPDATE_CLIENTS); // Update Exterior (We should make this a method tbh) updateShellBlock(theme, lastKnownLocationLevel, lastKnownLocationPosition); diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisExteriorManager.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisExteriorManager.java index fe240877e..81b6e5170 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisExteriorManager.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/manager/TardisExteriorManager.java @@ -174,10 +174,13 @@ public void removeExteriorBlock() { public void placeExteriorBlock(TardisLevelOperator operator, TardisNavLocation location) { AestheticHandler aestheticHandler = operator.getAestheticHandler(); ResourceLocation theme = (aestheticHandler.getShellTheme() != null) ? aestheticHandler.getShellTheme() : ShellTheme.FACTORY.getId(); + ShellTheme shellTheme = ShellTheme.getShellTheme(theme); + BlockState targetBlockState = BlockRegistry.GLOBAL_SHELL_BLOCK.get().defaultBlockState() .setValue(GlobalShellBlock.FACING, location.getDirection()) .setValue(GlobalShellBlock.REGEN, false) .setValue(LOCKED, operator.getExteriorManager().locked) + .setValue(GlobalShellBlock.LIT, shellTheme.producesLight()) .setValue(GlobalShellBlock.WATERLOGGED, location.getLevel().getBlockState(location.getPosition()).getFluidState().getType() == Fluids.WATER); ServerLevel targetLevel = location.getLevel(); diff --git a/common/src/main/java/whocraft/tardis_refined/common/tardis/themes/ShellTheme.java b/common/src/main/java/whocraft/tardis_refined/common/tardis/themes/ShellTheme.java index 60bfbe10a..8d3e142b2 100644 --- a/common/src/main/java/whocraft/tardis_refined/common/tardis/themes/ShellTheme.java +++ b/common/src/main/java/whocraft/tardis_refined/common/tardis/themes/ShellTheme.java @@ -21,20 +21,20 @@ public class ShellTheme implements Theme { public static final Registry SHELL_THEME_REGISTRY = SHELL_THEMES.getRegistry(); public static final RegistrySupplierHolder FACTORY = registerShellTheme("factory"); - public static final RegistrySupplierHolder POLICE_BOX = registerShellTheme("police_box"); - public static final RegistrySupplierHolder PHONE_BOOTH = registerShellTheme("phone_booth"); - public static final RegistrySupplierHolder MYSTIC = registerShellTheme("mystic"); + public static final RegistrySupplierHolder POLICE_BOX = registerShellTheme("police_box", true); + public static final RegistrySupplierHolder PHONE_BOOTH = registerShellTheme("phone_booth", true); + public static final RegistrySupplierHolder MYSTIC = registerShellTheme("mystic", true); public static final RegistrySupplierHolder PRESENT = registerShellTheme("present"); public static final RegistrySupplierHolder DRIFTER = registerShellTheme("drifter"); - public static final RegistrySupplierHolder VENDING = registerShellTheme("vending"); + public static final RegistrySupplierHolder VENDING = registerShellTheme("vending", true); public static final RegistrySupplierHolder BRIEFCASE = registerShellTheme("briefcase"); - public static final RegistrySupplierHolder GROENING = registerShellTheme("groening"); - public static final RegistrySupplierHolder BIG_BEN = registerShellTheme("big_ben"); - public static final RegistrySupplierHolder NUKA = registerShellTheme("nuka"); + public static final RegistrySupplierHolder GROENING = registerShellTheme("groening", true); + public static final RegistrySupplierHolder BIG_BEN = registerShellTheme("big_ben", true); + public static final RegistrySupplierHolder NUKA = registerShellTheme("nuka", true); public static final RegistrySupplierHolder GROWTH = registerShellTheme("growth"); public static final RegistrySupplierHolder PORTALOO = registerShellTheme("portaloo"); public static final RegistrySupplierHolder PAGODA = registerShellTheme("pagoda"); - public static final RegistrySupplierHolder LIFT = registerShellTheme("lift"); + public static final RegistrySupplierHolder LIFT = registerShellTheme("lift", true); public static final RegistrySupplierHolder HIEROGLYPH = registerShellTheme("hieroglyph"); public static final RegistrySupplierHolder CASTLE = registerShellTheme("castle"); public static final RegistrySupplierHolder PATHFINDER = registerShellTheme("pathfinder"); @@ -53,13 +53,24 @@ public static ResourceLocation getKey(ShellTheme shellTheme){ } private ResourceLocation translationKey; + private boolean producesLight; - public ShellTheme(ResourceLocation translationKey){ this.translationKey = translationKey;} + public ShellTheme(ResourceLocation translationKey) { + this.translationKey = translationKey; + } + public ShellTheme(ResourceLocation translationKey, boolean producesLight) { + this.translationKey = translationKey; + this.producesLight = producesLight; + } private static RegistrySupplierHolder registerShellTheme(String id){ return SHELL_THEMES.registerHolder(id, () -> new ShellTheme(new ResourceLocation(TardisRefined.MODID, id))); } + private static RegistrySupplierHolder registerShellTheme(String id, boolean producesLight){ + return SHELL_THEMES.registerHolder(id, () -> new ShellTheme(new ResourceLocation(TardisRefined.MODID, id), producesLight)); + } + @Override public String getTranslationKey() { return Util.makeDescriptionId("shell", this.translationKey); @@ -70,4 +81,8 @@ public Component getDisplayName() { return Component.translatable(this.getTranslationKey()); } + public boolean producesLight() { + return producesLight; + } + } diff --git a/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java b/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java index 31fbf6b6a..46c9f677b 100644 --- a/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java +++ b/common/src/main/java/whocraft/tardis_refined/registry/BlockRegistry.java @@ -44,7 +44,9 @@ private static RegistrySupplier register(String id, Supplie // Shell Blocks public static final RegistrySupplier ROOT_SHELL_BLOCK = register("root_shell", () -> new RootedShellBlock(BlockBehaviour.Properties.of().noOcclusion().strength(1000, 1000).sound(SoundType.CORAL_BLOCK)), true, true); - public static final RegistrySupplier GLOBAL_SHELL_BLOCK = register("tardis_shell", () -> new GlobalShellBlock(BlockBehaviour.Properties.of().noOcclusion().strength(1000, 1000).sound(SoundType.STONE)), false, false); + public static final RegistrySupplier GLOBAL_SHELL_BLOCK = register("tardis_shell", () -> new GlobalShellBlock(BlockBehaviour.Properties.of().noOcclusion().strength(1000, 1000).sound(SoundType.STONE).lightLevel((blocksState) -> { + return blocksState.getValue(GlobalShellBlock.LIT) ? 13 : 0; + })), false, false); // Interior public static final RegistrySupplier GLOBAL_DOOR_BLOCK = register("tardis_door", () -> new GlobalDoorBlock(BlockBehaviour.Properties.of().noOcclusion().strength(10, 10).sound(SoundType.STONE)), true, true);