2020-07-19 19:12:39 +00:00
|
|
|
package com.thebrokenrail.energonrelics.structure.researchcomplex;
|
|
|
|
|
|
|
|
import com.thebrokenrail.energonrelics.EnergonRelics;
|
|
|
|
import com.thebrokenrail.energonrelics.block.entity.reactor.ReactorControllerBlockEntity;
|
|
|
|
import com.thebrokenrail.energonrelics.config.HardcodedConfig;
|
|
|
|
import com.thebrokenrail.energonrelics.structure.StructureContext;
|
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.Blocks;
|
|
|
|
import net.minecraft.block.LeverBlock;
|
|
|
|
import net.minecraft.block.StairsBlock;
|
|
|
|
import net.minecraft.block.entity.BlockEntity;
|
|
|
|
import net.minecraft.block.enums.BlockHalf;
|
|
|
|
import net.minecraft.block.enums.StairShape;
|
|
|
|
import net.minecraft.block.enums.WallMountLocation;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.Direction;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class ResearchComplexStartPart extends BaseResearchComplexPart {
|
|
|
|
public ResearchComplexStartPart(ResearchComplexState state, List<Transformation> list) {
|
|
|
|
super(state, list);
|
|
|
|
}
|
|
|
|
|
2020-07-20 21:03:17 +00:00
|
|
|
private void setBlockOrAir(BlockPos pos, BlockState state) {
|
|
|
|
if (pos.getY() == 1 || pos.getY() == 4) {
|
|
|
|
set(pos, state);
|
2020-07-19 19:12:39 +00:00
|
|
|
} else {
|
|
|
|
BlockState air = Blocks.AIR.getDefaultState();
|
2020-07-20 21:03:17 +00:00
|
|
|
set(pos, air);
|
2020-07-19 19:12:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void buildBase(int yOffset) {
|
|
|
|
BlockState bricks = Blocks.QUARTZ_BRICKS.getDefaultState();
|
|
|
|
BlockState air = Blocks.AIR.getDefaultState();
|
|
|
|
|
|
|
|
BlockState state = yOffset == 0 || yOffset == 5 ? bricks : air;
|
|
|
|
|
2020-07-20 21:03:17 +00:00
|
|
|
rect(new BlockPos(0, yOffset, 0), 2, 1, 6, state);
|
|
|
|
rect(new BlockPos(0, yOffset, 0), 6, 1, 2, state);
|
2020-07-19 19:12:39 +00:00
|
|
|
|
2020-07-20 21:03:17 +00:00
|
|
|
set(new BlockPos(2, yOffset, 3), state);
|
|
|
|
set(new BlockPos(3, yOffset, 2), state);
|
|
|
|
set(new BlockPos(2, yOffset, 2), state);
|
2020-07-19 19:12:39 +00:00
|
|
|
|
|
|
|
if (yOffset != 0 && yOffset != 5) {
|
|
|
|
BlockState stairs = Blocks.QUARTZ_STAIRS.getDefaultState();
|
|
|
|
|
|
|
|
BlockHalf half = yOffset == 1 ? BlockHalf.BOTTOM : BlockHalf.TOP;
|
|
|
|
stairs = stairs.with(StairsBlock.HALF, half);
|
|
|
|
|
2020-07-20 21:03:17 +00:00
|
|
|
BlockState eastStairs = stairs.with(StairsBlock.FACING, Direction.EAST);
|
|
|
|
BlockState southStairs = stairs.with(StairsBlock.FACING, Direction.SOUTH);
|
|
|
|
BlockState outerLeftStairs = southStairs.with(StairsBlock.SHAPE, StairShape.OUTER_LEFT);
|
|
|
|
BlockState innerLeftStairs = southStairs.with(StairsBlock.SHAPE, StairShape.INNER_LEFT);
|
|
|
|
BlockState innerRightStairs = eastStairs.with(StairsBlock.SHAPE, StairShape.INNER_RIGHT);
|
|
|
|
BlockState outerRightStairs = eastStairs.with(StairsBlock.SHAPE, StairShape.OUTER_RIGHT);
|
|
|
|
|
|
|
|
setBlockOrAir(new BlockPos(2, yOffset, 5), eastStairs);
|
|
|
|
setBlockOrAir(new BlockPos(2, yOffset, 4), outerLeftStairs);
|
|
|
|
setBlockOrAir(new BlockPos(3, yOffset, 4), innerRightStairs);
|
|
|
|
setBlockOrAir(new BlockPos(3, yOffset, 3), outerLeftStairs);
|
|
|
|
setBlockOrAir(new BlockPos(4, yOffset, 3), innerLeftStairs);
|
|
|
|
setBlockOrAir(new BlockPos(4, yOffset, 2), outerRightStairs);
|
|
|
|
setBlockOrAir(new BlockPos(5, yOffset, 2), southStairs);
|
2020-07-19 19:12:39 +00:00
|
|
|
|
|
|
|
if (yOffset != 1 && yOffset != 4) {
|
2020-07-20 21:03:17 +00:00
|
|
|
set(new BlockPos(3, yOffset, 5), bricks);
|
|
|
|
set(new BlockPos(4, yOffset, 4), bricks);
|
|
|
|
set(new BlockPos(5, yOffset, 3), bricks);
|
2020-07-19 19:12:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (yOffset == 5) {
|
2020-07-20 21:03:17 +00:00
|
|
|
set(new BlockPos(2, yOffset, 2), EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState());
|
2020-07-19 19:12:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void buildReactor() {
|
2020-07-20 21:03:17 +00:00
|
|
|
set(new BlockPos(0, 1, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(0, 2, 0), EnergonRelics.REACTOR_CORE_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(-1, 2, 0), EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(0, 3, 0), EnergonRelics.REACTOR_INPUT_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(0, 2, -1), EnergonRelics.REACTOR_CONTROLLER_BLOCK.getDefaultState());
|
|
|
|
set(new BlockPos(0, 1, -1), Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, WallMountLocation.FLOOR));
|
|
|
|
set(new BlockPos(0, 2, 1), EnergonRelics.THERMAL_GLASS_BLOCK.getDefaultState());
|
2020-07-19 19:12:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void build(StructureContext context) {
|
2020-07-20 21:03:17 +00:00
|
|
|
if (getState().hasEnergy(HardcodedConfig.ENERGON_LIGHT_ENERGY_REQUIRED * 4, new BlockPos(0, 2, 0))) {
|
|
|
|
rotate(() -> {
|
2020-07-19 19:12:39 +00:00
|
|
|
for (int i = 0; i < 6; i++) {
|
|
|
|
buildBase(i);
|
|
|
|
}
|
2020-07-20 21:03:17 +00:00
|
|
|
part(context, new BlockPos(-3, 0, 6), new ResearchComplexHallwayPart(getState(), getTransformations(), true, 1, 1));
|
2020-07-19 19:12:39 +00:00
|
|
|
});
|
|
|
|
buildReactor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void handleBlockPlace(World world, BlockPos pos, BlockState state) {
|
|
|
|
super.handleBlockPlace(world, pos, state);
|
|
|
|
if (state.getBlock() == EnergonRelics.REACTOR_CONTROLLER_BLOCK) {
|
|
|
|
BlockEntity entity = world.getBlockEntity(pos);
|
|
|
|
if (entity instanceof ReactorControllerBlockEntity) {
|
|
|
|
((ReactorControllerBlockEntity) entity).placeStack(EnergonRelics.NETWORK_CHIP_ITEM.create(getState().getMainNetwork()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|