This repository has been archived on 2023-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
EnergonRelics/src/main/java/com/thebrokenrail/energonrelics/structure/researchcomplex/ResearchComplexStartPart.java

116 lines
4.8 KiB
Java

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);
}
private void setBlockOrAir(int x, int y, int z, BlockState stairs) {
if (y == 1 || y == 4) {
set(x, y, z, stairs);
} else {
BlockState air = Blocks.AIR.getDefaultState();
set(x, y, z, air);
}
}
private void buildBase(int yOffset) {
BlockState bricks = Blocks.QUARTZ_BRICKS.getDefaultState();
BlockState air = Blocks.AIR.getDefaultState();
BlockState state = yOffset == 0 || yOffset == 5 ? bricks : air;
rect(0, yOffset, 0, 2, 1, 6, state);
rect(0, yOffset, 0, 6, 1, 2, state);
set(2, yOffset, 3, state);
set(3, yOffset, 2, state);
set(3, yOffset, 3, state);
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);
BlockState westStairs = stairs.with(StairsBlock.FACING, Direction.WEST);
BlockState northStairs = stairs.with(StairsBlock.FACING, Direction.NORTH);
BlockState outerLeftStairs = northStairs.with(StairsBlock.SHAPE, StairShape.OUTER_LEFT);
BlockState innerLeftStairs = northStairs.with(StairsBlock.SHAPE, StairShape.INNER_LEFT);
BlockState innerRightStairs = westStairs.with(StairsBlock.SHAPE, StairShape.INNER_RIGHT);
BlockState outerRightStairs = westStairs.with(StairsBlock.SHAPE, StairShape.OUTER_RIGHT);
setBlockOrAir(3, yOffset, 0, westStairs);
setBlockOrAir(3, yOffset, 1, outerLeftStairs);
setBlockOrAir(2, yOffset, 1, innerRightStairs);
setBlockOrAir(2, yOffset, 2, outerLeftStairs);
setBlockOrAir(1, yOffset, 2, innerLeftStairs);
setBlockOrAir(1, yOffset, 3, outerRightStairs);
setBlockOrAir(0, yOffset, 3, northStairs);
if (yOffset != 1 && yOffset != 4) {
set(2, yOffset, 0, bricks);
set(1, yOffset, 1, bricks);
set(0, yOffset, 2, bricks);
}
}
if (yOffset == 5) {
set(3, yOffset, 3, EnergonRelics.ENERGON_LIGHT_BLOCK.getDefaultState());
}
}
private void buildReactor() {
set(0, 1, 0, EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(1, 2, 0, EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(0, 2, 0, EnergonRelics.REACTOR_CORE_BLOCK.getDefaultState());
set(-1, 2, 0, EnergonRelics.THERMAL_CASING_BLOCK.getDefaultState());
set(0, 3, 0, EnergonRelics.REACTOR_INPUT_BLOCK.getDefaultState());
set(0, 2, 1, EnergonRelics.REACTOR_CONTROLLER_BLOCK.getDefaultState());
set(0, 1, 1, Blocks.LEVER.getDefaultState().with(LeverBlock.FACE, WallMountLocation.FLOOR));
set(0, 2, -1, EnergonRelics.THERMAL_GLASS_BLOCK.getDefaultState());
}
@Override
protected void build(StructureContext context) {
if (getState().hasEnergy(HardcodedConfig.ENERGON_LIGHT_ENERGY_REQUIRED * 4)) {
repeat(() -> {
for (int i = 0; i < 6; i++) {
buildBase(i);
}
//part(context, 1, 0, getWidth() / 2, new ResearchComplexHallwayPart(getState(), getTransformations()));
});
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()));
}
}
}
}