big office building

This commit is contained in:
Vaern 2022-09-05 20:52:23 -07:00
parent 4e111e968a
commit bf385c831d
3 changed files with 275 additions and 1 deletions

View File

@ -335,4 +335,19 @@ public class HbmChestContents {
new WeightedRandomChestContent(ModItems.warhead_mirv, 0, 1, 1, 1),
new WeightedRandomChestContent(ModItems.battery_schrabidium_cell, 0, 1, 1, 1),
new WeightedRandomChestContent(ModItems.powder_nitan_mix, 0, 16, 32, 1) };
public static WeightedRandomChestContent[] officeTrash = new WeightedRandomChestContent[] {
//Meta, Min amount, Max amount, Weight
new WeightedRandomChestContent(Items.paper, 0, 1, 12, 10),
new WeightedRandomChestContent(Items.book, 0, 1, 3, 4),
new WeightedRandomChestContent(ModItems.twinkie, 0, 1, 2, 6),
new WeightedRandomChestContent(ModItems.coffee, 0, 1, 1, 4),
new WeightedRandomChestContent(ModItems.flame_politics, 0, 1, 1, 2),
new WeightedRandomChestContent(ModItems.ring_pull, 0, 1, 1, 4),
new WeightedRandomChestContent(ModItems.can_empty, 0, 1, 1, 2),
new WeightedRandomChestContent(ModItems.can_creature, 0, 1, 2, 2),
new WeightedRandomChestContent(ModItems.can_smart, 0, 1, 3, 2),
new WeightedRandomChestContent(ModItems.can_mrsugar, 0, 1, 2, 2),
new WeightedRandomChestContent(ModItems.book_guide, 3, 1, 1, 1),
new WeightedRandomChestContent(Item.getItemFromBlock(ModBlocks.deco_computer), 0, 1, 1, 1)};
}

View File

@ -6,6 +6,7 @@ import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockBobble.BobbleType;
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
import com.hbm.config.StructureConfig;
import com.hbm.tileentity.machine.TileEntityLockableBase;
import com.hbm.tileentity.machine.storage.TileEntityCrateIron;
import net.minecraft.block.Block;
@ -14,6 +15,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemDoor;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
@ -152,6 +154,19 @@ abstract public class Feature extends StructureComponent {
return 0;
}
/**
*
* @param metadata (0 for facing North, 1 for facing South, 2 for facing West, 3 for facing East)
*/
protected int getDecoModelMeta(int metadata) {
//N: 0b00, S: 0b01, W: 0b10, E: 0b11
int rot = metadata & 3;
return 0;
}
/**
* Places door at specified location with orientation-adjusted meta
* don't ask me which directions are what (take direction such as South/0 and add 1)
@ -182,7 +197,36 @@ abstract public class Feature extends StructureComponent {
if(inventory != null) {
amount = (int)Math.floor(amount * StructureConfig.lootAmountFactor);
WeightedRandomChestContent.generateChestContents(rand, content, inventory, amount);
WeightedRandomChestContent.generateChestContents(rand, content, inventory, amount < 1 ? 1 : amount);
return true;
}
return false;
}
/**
* Block TE MUST extend TileEntityLockableBase, otherwise this will not work and crash!
* @return TE implementing IInventory and extending TileEntityLockableBase with randomized contents + lock
*/
protected boolean generateLockableContents(World world, StructureBoundingBox box, Random rand, Block block, int featureX, int featureY, int featureZ,
WeightedRandomChestContent[] content, int amount, double mod) {
int posX = this.getXWithOffset(featureX, featureZ);
int posY = this.getYWithOffset(featureY);
int posZ = this.getZWithOffset(featureX, featureZ);
this.placeBlockAtCurrentPosition(world, block, 0, featureX, featureY, featureZ, box);
TileEntity tile = world.getTileEntity(posX, posY, posZ);
TileEntityLockableBase lock = (TileEntityLockableBase) tile;
IInventory inventory = (IInventory) tile;
if(inventory != null && lock != null) {
lock.setPins(rand.nextInt(999) + 1);
lock.setMod(mod);
lock.lock();
amount = (int)Math.floor(amount * StructureConfig.lootAmountFactor);
WeightedRandomChestContent.generateChestContents(rand, content, inventory, amount < 1 ? 1 : amount);
return true;
}
@ -250,6 +294,24 @@ abstract public class Feature extends StructureComponent {
}
}
/** Methods that remove the replaceBlock and alwaysReplace, and other parameters: as they are useless and only serve as a time sink normally. */
protected void fillWithBlocks(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
this.fillWithBlocks(world, box, minX, minY, minZ, maxX, maxY, maxZ, block, block, false);
}
protected void fillWithMetadataBlocks(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block, int meta) {
this.fillWithMetadataBlocks(world, box, minX, minY, minZ, maxX, maxY, maxZ, block, meta, block, meta, false);
}
protected void randomlyFillWithBlocks(World world, StructureBoundingBox box, Random rand, float randLimit, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Block block) {
this.randomlyFillWithBlocks(world, box, rand, randLimit, minX, minY, minZ, maxX, maxY, maxZ, block);
}
protected void fillWithRandomizedBlocks(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Random rand, BlockSelector selector) {
this.fillWithRandomizedBlocks(world, box, minX, minY, minZ, maxX, maxY, maxZ, false, rand, selector);
}
/** Block Selectors **/
static class Sandstone extends StructureComponent.BlockSelector {

View File

@ -0,0 +1,197 @@
package com.hbm.world.worldgen.components;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.lib.HbmChestContents;
import com.hbm.world.worldgen.components.Feature.ConcreteBricks;
import net.minecraft.init.Blocks;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
//Oh my fucking god TM
public class OfficeFeatures {
public static class LargeOffice extends Feature {
private static ConcreteBricks ConcreteBricks = new ConcreteBricks();
private boolean[] hasPlacedLoot = new boolean[2];
public LargeOffice() {
super();
}
public LargeOffice(Random rand, int minX, int minY, int minZ) {
super(rand, minX, minY, minZ, 14, 5, 12);
this.hasPlacedLoot[0] = false;
this.hasPlacedLoot[1] = false;
}
@Override
protected void func_143012_a(NBTTagCompound nbt) {
super.func_143012_a(nbt);
nbt.setBoolean("hasLoot1", this.hasPlacedLoot[0]);
nbt.setBoolean("hasLoot2", this.hasPlacedLoot[1]);
}
@Override
protected void func_143011_b(NBTTagCompound nbt) {
super.func_143011_b(nbt);
this.hasPlacedLoot[0] = nbt.getBoolean("hasLoot1");
this.hasPlacedLoot[1] = nbt.getBoolean("hasLoot2");
}
//Holy shit I despise this method so goddamn much
//TODO BOB: please i beg you make some sort of utility tool to simplify this
//ideally we'd invent something like the structure blocks or even a more advanced
//schematic to java tool
@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox box) {
if(!this.setAverageHeight(world, box, this.boundingBox.minY)) {
return true;
}
this.boundingBox.offset(0, -1, 0);
//Pillars
fillWithBlocks(world, box, 0, 0, 2, 0, 4, 2, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 5, 0, 0, 5, 4, 0, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, sizeX, 0, 0, sizeX, 4, 0, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 0, 0, 5, 0, 3, 5, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 0, 0, sizeZ, 0, 3, sizeZ, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 3, 0, sizeZ, 3, 3, sizeZ, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 6, 0, sizeZ, 6, 3, sizeZ, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 9, 0, sizeZ, 9, 3, sizeZ, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, 9, 0, 7, 9, 3, 7, ModBlocks.concrete_pillar);
fillWithBlocks(world, box, sizeX, 0, sizeZ, sizeX, 4, sizeZ, ModBlocks.concrete_pillar);
//Walls
//Back
fillWithRandomizedBlocks(world, box, 1, 0, 2, 5, 4, 2, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 5, 0, 1, 5, 4, 1, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 6, 0, 0, sizeX - 1, 1, 0, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 6, 2, 0, 6, 2, 0, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 9, 2, 0, 10, 2, 0, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX - 2, 2, 0, sizeX - 1, 2, 0, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 6, 3, 0, sizeX - 1, 4, 0, rand, ConcreteBricks);
//Right
fillWithRandomizedBlocks(world, box, sizeX, 0, 1, sizeX, 1, sizeZ - 1, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX, 2, 1, sizeX, 2, 2, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX, 2, 5, sizeX, 2, 7, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX, 2, sizeZ - 2, sizeX, 2, sizeZ - 1, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX, 3, 1, sizeX, 4, sizeZ - 1, rand, ConcreteBricks);
//Front
fillWithRandomizedBlocks(world, box, 0, 4, sizeZ, sizeX - 1, 4, sizeZ, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 10, 0, sizeZ, sizeX - 1, 1, sizeZ, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 10, 2, sizeZ, 10, 2, sizeZ, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, sizeX - 1, 2, sizeZ, sizeX - 1, 2, sizeZ, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 10, 3, sizeZ, sizeX - 1, 3, sizeZ, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 9, 0, 8, 9, 3, sizeZ - 1, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 1, 0, 7, 8, 0, 7, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 1, 1, 7, 1, 2, 7, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 4, 1, 7, 8, 4, 7, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 1, 4, 7, 3, 4, 7, rand, ConcreteBricks);
//Left
fillWithRandomizedBlocks(world, box, 0, 4, 3, 0, 4, sizeZ - 1, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 0, 0, 3, 0, 1, 6, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 0, 2, 3, 0, 3, 3, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 0, 2, 6, 0, 3, 6, rand, ConcreteBricks);
//Interior
fillWithRandomizedBlocks(world, box, 5, 1, 3, 5, 3, 5, rand, ConcreteBricks);
fillWithRandomizedBlocks(world, box, 5, 3, 6, 5, 3, 6, rand, ConcreteBricks);
//Trim
randomlyFillWithBlocks(world, box, rand, 0.75F, 0, sizeY, 2, 5, sizeY, 2, Blocks.stone_slab);
randomlyFillWithBlocks(world, box, rand, 0.75F, 5, sizeY, 1, 5, sizeY, 1, Blocks.stone_slab);
randomlyFillWithBlocks(world, box, rand, 0.75F, 5, sizeY, 0, sizeX, sizeY, 0, Blocks.stone_slab);
randomlyFillWithBlocks(world, box, rand, 0.75F, sizeX, sizeY, 1, sizeX, sizeY, sizeZ, Blocks.stone_slab);
randomlyFillWithBlocks(world, box, rand, 0.75F, 0, sizeY, sizeZ, sizeX - 1, sizeY, sizeZ, Blocks.stone_slab);
randomlyFillWithBlocks(world, box, rand, 0.75F, 0, sizeY, 3, 0, sizeY, sizeZ - 1, Blocks.stone_slab);
//Floor
fillWithMetadataBlocks(world, box, 1, 0, 3, 4, 6, hpos, Blocks.wool, 13); //Green Wool
fillWithBlocks(world, box, 5, 0, 3, 5, 0, 6, ModBlocks.brick_light);
fillWithBlocks(world, box, 1, 0, 1, sizeX - 1, 0, 6, ModBlocks.brick_light);
fillWithBlocks(world, box, 10, 0, 7, sizeX - 1, 0, sizeZ - 1, ModBlocks.brick_light);
//Ceiling
fillWithBlocks(world, box, 6, 4, 1, sizeX - 1, 4, 2, ModBlocks.brick_light);
fillWithBlocks(world, box, 1, 4, 3, sizeX - 1, 4, sizeZ - 1, ModBlocks.brick_light);
//Decorations
//Carpet
fillWithMetadataBlocks(world, box, 9, 1, 3, 11, 1, 6, Blocks.carpet, 8); //Light gray
//Windows
randomlyFillWithBlocks(world, box, rand, 0.75F, 0, 2, 4, 0, 3, 5, Blocks.glass_pane);
randomlyFillWithBlocks(world, box, rand, 0.75F, 7, 2, 0, 8, 2, 0, Blocks.glass_pane);
randomlyFillWithBlocks(world, box, rand, 0.75F, sizeX - 3, 2, 0, sizeX - 2, 2, 0, Blocks.glass_pane);
randomlyFillWithBlocks(world, box, rand, 0.75F, sizeX, 2, 3, sizeX, 2, 4, Blocks.glass_pane);
randomlyFillWithBlocks(world, box, rand, 0.75F, sizeX, 2, 8, sizeX, 2, 9, Blocks.glass_pane);
randomlyFillWithBlocks(world, box, rand, 0.75F, sizeX - 3, 2, sizeZ, sizeX - 2, 2, sizeZ, Blocks.glass_pane);
//Fuwnituwe >w<
int stairMetaE = this.getMetadataWithOffset(Blocks.oak_stairs, 1); //East
int stairMetaN = this.getMetadataWithOffset(Blocks.oak_stairs, 2); //Nowth :3
int stairMetaS = this.getMetadataWithOffset(Blocks.oak_stairs, 3); //South
int stairMetaWU = this.getMetadataWithOffset(Blocks.oak_stairs, 5); //West, Upside-down
int stairMetaEU = this.getMetadataWithOffset(Blocks.oak_stairs, 5); //East, Upside-down
int stairMetaNU = this.getMetadataWithOffset(Blocks.oak_stairs, 6); //Nowth, Upside-down uwu
int stairMetaSU = this.getMetadataWithOffset(Blocks.oak_stairs, 7); //South, Upside-down
//Desk 1 :3
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaEU, 1, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaEU, 2, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaNU, 3, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.oak_stairs, stairMetaS, 3, 1, 2, box); //Chaiw :3
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(0), 1, 2, 4, box); //Nowth-facing Computer :33
//Desk 2 :3
placeBlockAtCurrentPosition(world, Blocks.oak_stairs, stairMetaS, 7, 1, 3, box); //Chaiw :3
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaEU, 6, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaWU, 7, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.planks, 1, 8, 1, 4, box); //Spwuce Pwanks :3
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(0), 7, 2, 4, box); //Nowth-facing Computer X3
placeBlockAtCurrentPosition(world, Blocks.flower_pot, 0, 8, 2, 4, box);
//Desk 3 :3
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaEU, 10, 1, 1, box);
fillWithMetadataBlocks(world, box, 11, 1, 1, sizeX - 1, 1, 1, Blocks.spruce_stairs, stairMetaSU);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaNU, sizeX - 1, 1, 2, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaSU, sizeX - 1, 1, 3, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaWU, sizeX - 1, 1, 4, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaNU, sizeX - 1, 1, 5, box);
placeBlockAtCurrentPosition(world, Blocks.oak_stairs, stairMetaN, 11, 1, 2, box); //Chaiw ;3
placeBlockAtCurrentPosition(world, Blocks.oak_stairs, stairMetaE, sizeX - 2, 1, 4, box); //Chaiw :333
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(1), sizeX - 3, 2, 1, box); //South-facing Computer :3
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(2), sizeX - 1, 2, 5, box); //West-facing Computer ^w^
placeBlockAtCurrentPosition(world, Blocks.flower_pot, 0, sizeX - 1, 2, 3, box);
placeBlockAtCurrentPosition(world, ModBlocks.radiorec, getDecoMeta(3), sizeX - 1, 2, 2, box); //Wadio
//Desk 4 DX
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaEU, 10, 1, 8, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaWU, 11, 1, 8, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaN, 10, 1, 9, box); //Chaiw ;3
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(1), 10, 2, 8, box); //South-facing Computer :33
//Desk 5 :333
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaSU, sizeX - 1, 1, sizeZ - 3, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaWU, sizeX - 1, 1, sizeZ - 2, box);
placeBlockAtCurrentPosition(world, Blocks.spruce_stairs, stairMetaNU, sizeX - 1, 1, sizeZ - 1, box);
placeBlockAtCurrentPosition(world, Blocks.oak_stairs, stairMetaE, sizeX - 3, 1, sizeZ - 1, box); //UwU... Chaiw!!!! :333 I wove chaiws XD :333 OwO what's this?? chaiw???? :333333333333333333
placeBlockAtCurrentPosition(world, ModBlocks.deco_computer, getDecoModelMeta(2), sizeX - 1, 2, sizeZ - 1, box); //West-facing Computer >w<
//Cobwebs pwobabwy
//Woot
if(!this.hasPlacedLoot[0])
this.hasPlacedLoot[0] = generateInvContents(world, box, rand, Blocks.chest, sizeX - 4, 1, sizeZ - 1, HbmChestContents.officeTrash, 10);
if(!this.hasPlacedLoot[1])
this.hasPlacedLoot[1] = generateLockableContents(world, box, rand, ModBlocks.safe, 6, 1, 1, null, 10, 0.2D);
//TODO: add book with funny lore to safe, add cobwebs too
return false;
}
}
}