From 4ec61bdb7ddd0d44a642762d66bad68f65109808 Mon Sep 17 00:00:00 2001 From: thepigcat Date: Sat, 21 Dec 2024 14:22:25 +0100 Subject: [PATCH] more work on bio reactor multiblock --- .../controller/BioReactorBlockEntity.java | 1 + .../controller}/BioReactorBlock.java | 11 +++++++--- .../part}/BioReactorPartBlock.java | 21 ++++++++----------- .../nautec/content/items/PetriDishItem.java | 11 +++++++--- .../multiblocks/BioReactorMultiblock.java | 11 ++++++---- .../nautec/registries/NTBlocks.java | 2 ++ 6 files changed, 35 insertions(+), 22 deletions(-) rename src/main/java/com/portingdeadmods/nautec/content/blocks/{ => multiblock/controller}/BioReactorBlock.java (81%) rename src/main/java/com/portingdeadmods/nautec/content/blocks/{ => multiblock/part}/BioReactorPartBlock.java (70%) diff --git a/src/main/java/com/portingdeadmods/nautec/content/blockentities/multiblock/controller/BioReactorBlockEntity.java b/src/main/java/com/portingdeadmods/nautec/content/blockentities/multiblock/controller/BioReactorBlockEntity.java index d3a14dea..9d3e66e4 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/blockentities/multiblock/controller/BioReactorBlockEntity.java +++ b/src/main/java/com/portingdeadmods/nautec/content/blockentities/multiblock/controller/BioReactorBlockEntity.java @@ -30,6 +30,7 @@ public class BioReactorBlockEntity extends LaserBlockEntity implements MenuProvi public BioReactorBlockEntity(BlockPos blockPos, BlockState blockState) { super(NTBlockEntityTypes.BIO_REACTOR.get(), blockPos, blockState); addItemHandler(2); + this.multiblockData = MultiblockData.EMPTY; } @Override diff --git a/src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorBlock.java b/src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/controller/BioReactorBlock.java similarity index 81% rename from src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorBlock.java rename to src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/controller/BioReactorBlock.java index 6860ea6f..a60bfbe1 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorBlock.java +++ b/src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/controller/BioReactorBlock.java @@ -1,8 +1,10 @@ -package com.portingdeadmods.nautec.content.blocks; +package com.portingdeadmods.nautec.content.blocks.multiblock.controller; import com.mojang.serialization.MapCodec; import com.portingdeadmods.nautec.api.blockentities.ContainerBlockEntity; import com.portingdeadmods.nautec.api.blocks.blockentities.LaserBlock; +import com.portingdeadmods.nautec.api.multiblocks.Multiblock; +import com.portingdeadmods.nautec.content.multiblocks.BioReactorMultiblock; import com.portingdeadmods.nautec.registries.NTBlockEntityTypes; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -26,12 +28,15 @@ public class BioReactorBlock extends LaserBlock { public BioReactorBlock(Properties properties) { super(properties); - registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH)); + registerDefaultState(defaultBlockState() + .setValue(FACING, Direction.NORTH) + .setValue(Multiblock.FORMED, false) + ); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - super.createBlockStateDefinition(builder.add(FACING)); + super.createBlockStateDefinition(builder.add(FACING, Multiblock.FORMED, BioReactorMultiblock.BIO_REACTOR_PART)); } @Override diff --git a/src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorPartBlock.java b/src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/part/BioReactorPartBlock.java similarity index 70% rename from src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorPartBlock.java rename to src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/part/BioReactorPartBlock.java index 11921e36..137a6755 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/blocks/BioReactorPartBlock.java +++ b/src/main/java/com/portingdeadmods/nautec/content/blocks/multiblock/part/BioReactorPartBlock.java @@ -1,26 +1,20 @@ -package com.portingdeadmods.nautec.content.blocks; +package com.portingdeadmods.nautec.content.blocks.multiblock.part; import com.mojang.serialization.MapCodec; -import com.portingdeadmods.nautec.api.blockentities.ContainerBlockEntity; -import com.portingdeadmods.nautec.api.blocks.blockentities.LaserBlock; +import com.portingdeadmods.nautec.api.multiblocks.Multiblock; import com.portingdeadmods.nautec.content.blockentities.multiblock.part.BioReactorPartBlockEntity; -import com.portingdeadmods.nautec.registries.NTBlockEntityTypes; +import com.portingdeadmods.nautec.content.blocks.multiblock.controller.BioReactorBlock; +import com.portingdeadmods.nautec.content.multiblocks.BioReactorMultiblock; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.context.BlockPlaceContext; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.BaseEntityBlock; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; -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.BlockStateProperties; import net.minecraft.world.level.block.state.properties.DirectionProperty; -import net.minecraft.world.phys.BlockHitResult; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class BioReactorPartBlock extends BaseEntityBlock { @@ -28,12 +22,15 @@ public class BioReactorPartBlock extends BaseEntityBlock { public BioReactorPartBlock(Properties properties) { super(properties); - registerDefaultState(defaultBlockState().setValue(FACING, Direction.NORTH)); + registerDefaultState(defaultBlockState() + .setValue(FACING, Direction.NORTH) + .setValue(Multiblock.FORMED, false) + ); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { - super.createBlockStateDefinition(builder.add(FACING)); + super.createBlockStateDefinition(builder.add(Multiblock.FORMED, BioReactorMultiblock.BIO_REACTOR_PART)); } @Override diff --git a/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java b/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java index f10d7146..be574919 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java +++ b/src/main/java/com/portingdeadmods/nautec/content/items/PetriDishItem.java @@ -30,9 +30,14 @@ public void appendHoverText(ItemStack stack, TooltipContext context, List"); + } + tooltipComponents.add(statsCaption.withStyle(ChatFormatting.GRAY)); + if (tooltipFlag.hasShiftDown()) { + for (Component tooltipComponent : bacteria.initialStats().statsTooltip()) { + tooltipComponents.add(Component.literal(" ".repeat(2)).append(tooltipComponent).withStyle(ChatFormatting.GRAY)); + } } } else { statsCaption.append("???"); diff --git a/src/main/java/com/portingdeadmods/nautec/content/multiblocks/BioReactorMultiblock.java b/src/main/java/com/portingdeadmods/nautec/content/multiblocks/BioReactorMultiblock.java index 3fd8a467..ee3e8cf7 100644 --- a/src/main/java/com/portingdeadmods/nautec/content/multiblocks/BioReactorMultiblock.java +++ b/src/main/java/com/portingdeadmods/nautec/content/multiblocks/BioReactorMultiblock.java @@ -13,11 +13,14 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; import org.jetbrains.annotations.Nullable; import java.util.Map; public class BioReactorMultiblock implements Multiblock { + public static final IntegerProperty BIO_REACTOR_PART = IntegerProperty.create("bio_reactor_part", 0, 8); + @Override public Block getUnformedController() { return NTBlocks.BIO_REACTOR.get(); @@ -61,10 +64,10 @@ public BlockEntityType getMultiBlockEntityType() { @Override public @Nullable BlockState formBlock(Level level, BlockPos blockPos, BlockPos controllerPos, int layerIndex, int layoutIndex, MultiblockData multiblockData, @Nullable Player player) { - return switch (layerIndex) { - case 4 -> Blocks.BARREL.defaultBlockState(); - default -> Blocks.BAMBOO_PLANKS.defaultBlockState(); - }; + if (layerIndex == 4) { + return getFormedController().defaultBlockState().setValue(BIO_REACTOR_PART, layerIndex).setValue(FORMED, true); + } + return NTBlocks.BIO_REACTOR_PART.get().defaultBlockState().setValue(BIO_REACTOR_PART, layerIndex).setValue(FORMED, true); } @Override diff --git a/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java b/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java index 42f6cb0e..707b1d1a 100644 --- a/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java +++ b/src/main/java/com/portingdeadmods/nautec/registries/NTBlocks.java @@ -1,6 +1,8 @@ package com.portingdeadmods.nautec.registries; import com.portingdeadmods.nautec.Nautec; +import com.portingdeadmods.nautec.content.blocks.multiblock.controller.BioReactorBlock; +import com.portingdeadmods.nautec.content.blocks.multiblock.part.BioReactorPartBlock; import com.portingdeadmods.nautec.content.items.blocks.PrismarineCrystalItem; import com.portingdeadmods.nautec.content.blocks.*; import com.portingdeadmods.nautec.content.blocks.multiblock.controller.AugmentationStationBlock;