reactor room, meta pain

This commit is contained in:
Vaern 2023-06-08 23:29:25 -07:00
parent 7ed32a6c7f
commit 3ecc74f6db
2 changed files with 243 additions and 7 deletions

View File

@ -35,6 +35,7 @@ public class BunkerComponents {
new Weight(10, 3, FunJunction::findValidPlacement),
new Weight(5, 2, BathroomL::findValidPlacement),
new Weight(7, 2, Laboratory::findValidPlacement),
new Weight(5, 1, PowerRoom::findValidPlacement),
};
StructureComponent starter = new StartingHub(rand, x, z);
@ -53,6 +54,7 @@ public class BunkerComponents {
MapGenStructureIO.func_143031_a(FunJunction.class, "NTMBFunJunction");
MapGenStructureIO.func_143031_a(BathroomL.class, "NTMBBathroomL");
MapGenStructureIO.func_143031_a(Laboratory.class, "NTMBLaboratory");
MapGenStructureIO.func_143031_a(PowerRoom.class, "NTMBPowerRoom");
//TODO more rooms for more variety
}
@ -483,7 +485,7 @@ public class BunkerComponents {
placeBlockAtCurrentPosition(world, ModBlocks.deco_tungsten, 0, 6, 1, 9, box);
placeBlockAtCurrentPosition(world, ModBlocks.tape_recorder, getDecoMeta(4), 6, 2, 9, box);
fillWithBlocks(world, box, 6, 3, 8, 6, 3, 9, ModBlocks.concrete_slab);
placeBlockAtCurrentPosition(world, Blocks.lever, getDecoMeta(2), 5, 1, 9, box); //double-check meta
placeLever(world, box, 2, rand.nextBoolean(), 5, 1, 9);
//doors
placeDoor(world, box, ModBlocks.door_bunker, 1, true, rand.nextBoolean(), 4, 1, 0);
placeDoor(world, box, ModBlocks.door_bunker, 1, false, rand.nextBoolean(), 5, 1, 0);
@ -565,10 +567,10 @@ public class BunkerComponents {
//hand-dryers (industrial-strength)
placeBlockAtCurrentPosition(world, ModBlocks.steel_beam, 3, 4, 1, 9, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, getDecoMeta(2), 4, 2, 9, box);
placeBlockAtCurrentPosition(world, Blocks.stone_button, 2, 3, 2, 9, box); //TODO button meta
placeBlockAtCurrentPosition(world, Blocks.stone_button, getButtonMeta(2), 3, 2, 9, box); //TODO button meta
placeBlockAtCurrentPosition(world, ModBlocks.steel_beam, 3, 6, 1, 9, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, getDecoMeta(2), 6, 2, 9, box);
placeBlockAtCurrentPosition(world, Blocks.stone_button, 1, 7, 2, 9, box);
placeBlockAtCurrentPosition(world, Blocks.stone_button, getButtonMeta(1), 7, 2, 9, box);
//stalls w/ toilets
for(int i = 1; i <= 5; i += 2) {
placeDoor(world, box, ModBlocks.door_metal, 0, false, rand.nextBoolean(), 5, 1, i);
@ -689,7 +691,7 @@ public class BunkerComponents {
placeBlockAtCurrentPosition(world, ModBlocks.concrete_smooth_stairs, stairMetaW | 4, 7, 1, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_red_copper, 0, 7, 2, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.concrete_smooth_stairs, stairMetaW, 7, 3, 3, box);
placeBlockAtCurrentPosition(world, Blocks.lever, 2, 6, 2, 3, box); //TODO lever meta
placeLever(world, box, 2, rand.nextBoolean(), 6, 2, 3);
fillWithMetadataBlocks(world, box, 7, 1, 4, 7, 2, 4, ModBlocks.steel_poles, decoMetaE);
placeBlockAtCurrentPosition(world, ModBlocks.deco_steel, 0, 7, 3, 4, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_tungsten, 0, 7, 1, 5, box);
@ -715,4 +717,206 @@ public class BunkerComponents {
return box.minY > 10 && StructureComponent.findIntersecting(components, box) == null ? new Laboratory(type, box, coordMode) : null;
}
}
public static class PowerRoom extends Component implements ProceduralComponent {
private boolean path;
private int powerType;
public PowerRoom() { }
public PowerRoom(int componentType, StructureBoundingBox box, int coordMode, Random rand) {
super(componentType);
this.boundingBox = box;
this.coordBaseMode = coordMode;
float chance = rand.nextFloat();
powerType = chance < 0.2 ? 2 : chance < 0.6 ? 1 : 0;
}
/** write to nbt */
@Override
protected void func_143012_a(NBTTagCompound nbt) {
super.func_143012_a(nbt);
nbt.setBoolean("p", path);
}
/** read from nbt */
@Override
protected void func_143011_b(NBTTagCompound nbt) {
super.func_143011_b(nbt);
path = nbt.getBoolean("p");
}
@Override
public void buildComponent(ProceduralStructureStart start, Random rand) {
path = this.getNextComponentEast(start, this, coordBaseMode, rand, 4, 1) != null;
}
@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) {
fillWithAir(world, box, 1, 1, 1, 10, 3, 10);
//floor
fillWithMetadataBlocks(world, box, 1, 0, 1, 10, 0, 10, ModBlocks.vinyl_tile, 1);
//ceiling
fillWithBlocks(world, box, 1, 4, 1, 10, 4, 10, ModBlocks.vinyl_tile);
//upper shield
fillWithBlocks(world, box, 0, 5, 0, 11, 5, 11, ModBlocks.reinforced_stone);
//walls
fillWithRandomizedBlocks(world, box, 0, 0, 0, 11, 4, 0, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 0, 0, 1, 0, 4, 10, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 0, 0, 11, 11, 4, 11, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 11, 0, 1, 11, 4, 10, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 5, 1, 1, 5, 3, 6, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 6, 1, 6, 10, 3, 6, rand, ConcreteBricks);
/* DECO */
//lamps
placeBlockAtCurrentPosition(world, ModBlocks.reinforced_lamp_off, 0, 3, 5, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.reinforced_lamp_off, 0, 3, 5, 5, box);
placeBlockAtCurrentPosition(world, ModBlocks.reinforced_lamp_off, 0, 3, 5, 8, box);
placeBlockAtCurrentPosition(world, ModBlocks.reinforced_lamp_off, 0, 6, 5, 8, box);
placeBlockAtCurrentPosition(world, ModBlocks.reinforced_lamp_off, 0, 9, 5, 8, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, 0, 3, 4, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, 0, 3, 4, 5, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, 0, 3, 4, 8, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, 0, 6, 4, 8, box);
placeBlockAtCurrentPosition(world, ModBlocks.fan, 0, 9, 4, 8, box);
//power room stuff
fillWithBlocks(world, box, 7, 2, 6, 9, 2, 6, ModBlocks.reinforced_glass);
int decoMetaE = getDecoMeta(5);
int decoMetaW = getDecoMeta(4);
int decoMetaN = getDecoMeta(3);
int decoMetaS = getDecoMeta(2);
int stairMetaS = getStairMeta(3);
int stairMetaN = getStairMeta(2);
int stairMetaW = getStairMeta(1);
int stairMetaE = getStairMeta(0);
switch(this.powerType) {
default:
fillWithBlocks(world, box, 6, 1, 1, 6, 3, 1, ModBlocks.deco_pipe_framed_rusted);
for(int i = 7; i <= 9; i += 2) {
placeBlockAtCurrentPosition(world, ModBlocks.machine_coal_off, decoMetaN, i, 1, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.steel_beam, 2, i, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.machine_coal_off, decoMetaN, i, 3, 1, box);
}
placeBlockAtCurrentPosition(world, ModBlocks.deco_red_copper, 0, 8, 1, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.concrete_colored_ext, 5, 8, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_red_copper, 0, 8, 3, 1, box);
placeLever(world, box, 3, rand.nextBoolean(), 8, 2, 2);
for(int i = 1; i <= 3; i += 2) {
placeBlockAtCurrentPosition(world, ModBlocks.deco_steel, 0, 10, i, 1, box);
fillWithMetadataBlocks(world, box, 10, i, 2, 10, i, 4, ModBlocks.deco_pipe_quad_rusted, getPillarMeta(8));
placeBlockAtCurrentPosition(world, ModBlocks.deco_steel, 0, 10, i, 5, box);
}
placeBlockAtCurrentPosition(world, ModBlocks.deco_pipe_framed_rusted, 0, 10, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.fluid_duct_gauge, decoMetaW, 10, 2, 5, box);
placeBlockAtCurrentPosition(world, ModBlocks.barrel_plastic, 0, 6, 1, 5, box);
//chests
generateInvContents(world, box, rand, Blocks.chest, decoMetaS, 7, 1, 5, HbmChestContents.antenna, 4); //WIP
generateInvContents(world, box, rand, Blocks.chest, decoMetaS, 9, 1, 5, HbmChestContents.antenna, 4);
break;
case 1:
placeBlockAtCurrentPosition(world, ModBlocks.concrete_colored_ext, 5, 6, 1, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.cable_detector, 0, 6, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.concrete_colored_ext, 5, 6, 3, 1, box);
placeLever(world, box, 3, false, 6, 2, 2);
for(int i = 7; i <= 9; i += 2) {
placeBlockAtCurrentPosition(world, ModBlocks.steel_scaffold, 8, i, 1, 1, box); //i'm not making another fucking meta method
placeBlockAtCurrentPosition(world, ModBlocks.machine_diesel, decoMetaE, i, 2, 1, box);
}
placeBlockAtCurrentPosition(world, ModBlocks.deco_pipe_rim_rusted, getPillarMeta(4), 8, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_pipe_rim_rusted, getPillarMeta(4), 8, 2, 1, box);
fillWithMetadataBlocks(world, box, 7, 3, 1, 9, 3, 1, ModBlocks.concrete_smooth_stairs, stairMetaS);
fillWithBlocks(world, box, 10, 1, 1, 10, 1, 3, ModBlocks.deco_steel);
placeBlockAtCurrentPosition(world, ModBlocks.deco_red_copper, 0, 10, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_steel, 0, 10, 3, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.steel_grate, 7, 10, 2, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(2), 10, 3, 2, box);
fillWithMetadataBlocks(world, box, 10, 2, 3, 10, 3, 3, ModBlocks.tape_recorder, decoMetaW);
fillWithMetadataBlocks(world, box, 9, 1, 2, 9, 1, 3, ModBlocks.steel_grate, 7);
fillWithBlocks(world, box, 9, 1, 5, 10, 1, 5, ModBlocks.barrel_iron);
placeBlockAtCurrentPosition(world, ModBlocks.barrel_iron, 0, 10, 2, 5, box);
fillWithBlocks(world, box, 6, 1, 5, 6, 2, 5, ModBlocks.barrel_iron);
placeBlockAtCurrentPosition(world, ModBlocks.barrel_iron, 0, 6, 1, 2, box);
break;
case 2:
for(int i = 7; i <= 9; i += 2) {
fillWithBlocks(world, box, i, 1, 2, i, 1, 4, ModBlocks.deco_lead);
fillWithBlocks(world, box, i, 2, 2, i, 2, 4, ModBlocks.block_lead);
fillWithBlocks(world, box, i, 3, 2, i, 3, 4, ModBlocks.deco_lead);
}
placeBlockAtCurrentPosition(world, ModBlocks.concrete_colored_ext, 5, 8, 1, 4, box);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_computer, 0, 8, 2, 4, box);
placeBlockAtCurrentPosition(world, ModBlocks.concrete_colored_ext, 5, 8, 3, 4, box);
placeLever(world, box, 3, rand.nextBoolean(), 8, 2, 5);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_element, 0, 8, 1, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_control, 0, 8, 2, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_element, 0, 8, 3, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.block_copper, 0, 8, 1, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.block_lead, 0, 8, 2, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.block_copper, 0, 8, 3, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_conductor, 0, 8, 1, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.machine_turbine, 0, 8, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.reactor_conductor, 0, 8, 3, 1, box);
fillWithBlocks(world, box, 9, 1, 1, 9, 3, 1, ModBlocks.deco_steel);
placeBlockAtCurrentPosition(world, ModBlocks.steel_grate, 7, 10, 1, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(1), 10, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.tape_recorder, decoMetaN, 10, 3, 1, box);
fillWithMetadataBlocks(world, box, 6, 1, 1, 7, 1, 1, ModBlocks.deco_pipe_quad_rusted, getPillarMeta(4));
placeBlockAtCurrentPosition(world, ModBlocks.deco_pipe_quad_rusted, getPillarMeta(4), 7, 3, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.fluid_duct_gauge, decoMetaN, 6, 3, 1, box);
//chest
generateInvContents(world, box, rand, Blocks.chest, decoMetaN, 6, 1, 2, HbmChestContents.antenna, 4); //WIP
break;
}
//transformer
fillWithMetadataBlocks(world, box, 1, 1, 1, 1, 1, 5, ModBlocks.concrete_smooth_stairs, stairMetaW | 4);
fillWithBlocks(world, box, 1, 1, 6, 1, 3, 6, ModBlocks.concrete_pillar);
fillWithMetadataBlocks(world, box, 1, 3, 1, 1, 3, 5, ModBlocks.concrete_smooth_stairs, stairMetaW);
placeBlockAtCurrentPosition(world, ModBlocks.machine_transformer_20, 0, 1, 2, 1, box);
placeBlockAtCurrentPosition(world, ModBlocks.cable_diode, decoMetaN, 1, 2, 2, box);
placeBlockAtCurrentPosition(world, ModBlocks.machine_battery, decoMetaE, 1, 2, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_red_copper, 0, 1, 2, 4, box);
placeBlockAtCurrentPosition(world, ModBlocks.cable_switch, 0, 1, 2, 5, box);
//machine
for(int i = 1; i <= 5; i += 4) {
placeBlockAtCurrentPosition(world, ModBlocks.deco_beryllium, 0, i, 1, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.steel_scaffold, 0, i, 2, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_beryllium, 0, i, 3, 10, box);
}
placeBlockAtCurrentPosition(world, ModBlocks.steel_scaffold, 0, 2, 1, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_tungsten, 0, 3, 1, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.steel_scaffold, 0, 4, 1, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.tape_recorder, decoMetaS, 2, 2, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(0), 3, 2, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.tape_recorder, decoMetaS, 4, 2, 10, box);
fillWithMetadataBlocks(world, box, 2, 3, 10, 4, 3, 10, ModBlocks.tape_recorder, decoMetaS);
//desk
fillWithMetadataBlocks(world, box, 8, 1, 10, 10, 1, 10, ModBlocks.concrete_smooth_stairs, stairMetaN | 4);
placeBlockAtCurrentPosition(world, ModBlocks.concrete_smooth_stairs, stairMetaE | 4, 10, 1, 9, box);
placeBlockAtCurrentPosition(world, Blocks.oak_stairs,stairMetaS, 9, 1, 9, box);
placeBlockAtCurrentPosition(world, Blocks.flower_pot, 0, 8, 2, 10, box);
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(0), 9, 2, 10, box);
//loot
generateInvContents(world, box, rand, Blocks.chest, decoMetaE, 1, 1, 7, HbmChestContents.antenna, 4); //WIP
generateInvContents(world, box, rand, ModBlocks.filing_cabinet, getDecoModelMeta(0), 7, 1, 10, HbmChestContents.antenna, 4);
//doors
placeDoor(world, box, ModBlocks.door_bunker, 1, true, rand.nextBoolean(), 3, 1, 0);
placeDoor(world, box, ModBlocks.door_bunker, 1, false, rand.nextBoolean(), 4, 1, 0);
placeDoor(world, box, ModBlocks.door_bunker, 0, false, false, 5, 1, 3);
if(path) fillWithAir(world, box, 11, 1, 7, 11, 2, 8);
return true;
}
public static StructureComponent findValidPlacement(List components, Random rand, int x, int y, int z, int coordMode, int type) {
StructureBoundingBox box = ProceduralStructureStart.getComponentToAddBoundingBox(x, y, z, -4, -1, 0, 12, 6, 12, coordMode);
return box.minY > 10 && StructureComponent.findIntersecting(components, box) == null ? new PowerRoom(type, box, coordMode, rand) : null;
}
}
}

View File

@ -268,7 +268,7 @@ abstract public class Component extends StructureComponent {
case 2: //North
dirMeta ^= 2; break; //Flip second bit
case 3: //East
dirMeta = (dirMeta - 1) % 4; break;
dirMeta = Math.abs(dirMeta - 1) % 4; break; //fuck you modulo
}
//hee hoo
@ -280,7 +280,7 @@ abstract public class Component extends StructureComponent {
world.setBlock(posX, posY + 1, posZ, door, metaTop, 2);
}
}
/** 1 for west face, 2 for east face, 3 for north, 4 for south*/
protected void placeLever(World world, StructureBoundingBox box, int dirMeta, boolean on, int featureX, int featureY, int featureZ) {
int posX = this.getXWithOffset(featureX, featureZ);
int posY = this.getYWithOffset(featureY);
@ -288,7 +288,39 @@ abstract public class Component extends StructureComponent {
if(!box.isVecInside(posX, posY, posZ)) return;
//levers suck ass
if(dirMeta <= 0 || dirMeta >= 7) { //levers suck ass
switch(this.coordBaseMode) {
case 1: case 3: //west / east
dirMeta ^= 0b111;
}
} else if(dirMeta >= 5) {
switch(this.coordBaseMode) {
case 1: case 3: //west / east
dirMeta = (dirMeta + 1) % 2 + 5;
}
} else {
dirMeta = getButtonMeta(dirMeta);
}
world.setBlock(posX, posY, posZ, Blocks.lever, on ? dirMeta | 8 : dirMeta, 2);
}
/** pain. works for side-facing levers as well */
protected int getButtonMeta(int dirMeta) {
switch(this.coordBaseMode) { //are you ready for the pain?
case 1: //West
if(dirMeta <= 2) return dirMeta + 2;
else if(dirMeta < 4) return dirMeta - 1;
else return dirMeta - 3;// this shit sucks ass
case 2: //North
return dirMeta + (dirMeta % 2 == 0 ? -1 : 1);
case 3: //East
if(dirMeta <= 1) return dirMeta + 3;
else if(dirMeta <= 2) return dirMeta + 1;
else return dirMeta - 2;
default: //South
return dirMeta;
}
}
/**N:0 W:1 S:2 E:3 */