Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ReclipseTheOne committed Dec 21, 2024
2 parents bec3045 + 4ec61bd commit ef9acf1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(FACING));
super.createBlockStateDefinition(builder.add(FACING, Multiblock.FORMED, BioReactorMultiblock.BIO_REACTOR_PART));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
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 {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;

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<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(FACING));
super.createBlockStateDefinition(builder.add(Multiblock.FORMED, BioReactorMultiblock.BIO_REACTOR_PART));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ public void appendHoverText(ItemStack stack, TooltipContext context, List<Compon
if (bacteriaType != NTBacterias.EMPTY) {
MutableComponent statsCaption = Component.literal("Stats: ");
if (Boolean.TRUE.equals(stack.get(NTDataComponents.ANALYZED))) {
tooltipComponents.add(statsCaption.withStyle(ChatFormatting.WHITE));
for (Component tooltipComponent : bacteria.initialStats().statsTooltip()) {
tooltipComponents.add(Component.literal(" ".repeat(2)).append(tooltipComponent).withStyle(ChatFormatting.GRAY));
if (!tooltipFlag.hasShiftDown()) {
statsCaption.append("<Shift>");
}
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("???");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -61,10 +64,10 @@ public BlockEntityType<? extends MultiblockEntity> 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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit ef9acf1

Please sign in to comment.