i'm too tired

dr kel larping
This commit is contained in:
Vaern 2023-08-18 18:13:00 -07:00
parent 1cfef371ed
commit b6eaf25b99
5 changed files with 50 additions and 23 deletions

View File

@ -2,18 +2,15 @@ package com.hbm.items.tool;
import java.util.List;
import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.lib.HbmWorld;
import com.hbm.lib.Library;
import com.hbm.world.gen.MapGenNTMFeatures;
import com.hbm.world.gen.component.BrutalistFeatures.ElevatedPrefab1;
import com.hbm.world.gen.component.OfficeFeatures.LargeOfficeCorner;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.StructureBoundingBox;
public class ItemWandD extends Item {
@ -37,13 +34,17 @@ public class ItemWandD extends Item {
//PollutionHandler.incrementPollution(world, pos.blockX, pos.blockY, pos.blockZ, PollutionType.SOOT, 15);
//HbmWorld.worldGenerator.specialFeatureGen.findClosestPosition(pos.blockX >> 4, pos.blockZ >> 4);
int i = pos.blockX >> 4;
int j = pos.blockZ >> 4;
MapGenNTMFeatures.Start start = new MapGenNTMFeatures.Start(world, world.rand, i, j);
//MapGenNTMFeatures.Start start = new MapGenNTMFeatures.Start(world, world.rand, i, j);
i = (i << 4) + 8;
j = (j << 4) + 8;
start.generateStructure(world, world.rand, new StructureBoundingBox(i, j, i + 32, j + 32));
LargeOfficeCorner corner = new LargeOfficeCorner(world.rand, i, 64, j);
corner.addComponentParts(world, world.rand, corner.getBoundingBox());
//start.generateStructure(world, world.rand, new StructureBoundingBox(i, j, i + 32, j + 32));
/*TimeAnalyzer.startCount("setBlock");
world.setBlock(pos.blockX, pos.blockY, pos.blockZ, Blocks.dirt);

View File

@ -32,6 +32,10 @@ public class MapGenSpecialFeatures extends MapGenStructure {
return "NTMSpecialFeatures";
}
public void setWorld(World world) {
this.worldObj = world;
}
@Override
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
if(locs.isEmpty())
@ -43,11 +47,9 @@ public class MapGenSpecialFeatures extends MapGenStructure {
//i'll probs make a system to predict which locations are what in advance
//seems like biomes can be cached/gen'd without creating the chunk, thankfully
//vec3 will be the angle + distance from provided coords, given in chunk coords
/*public Vec3 findClosestPosition(int chunkX, int chunkZ) {
public Vec3 findClosestPosition(int chunkX, int chunkZ) {
createBookList();
long time = System.nanoTime();
ChunkCoordIntPair pair = new ChunkCoordIntPair(0, 0);
long dist = Long.MAX_VALUE;
for(ChunkCoordIntPair loc : bookLocs) {
@ -61,8 +63,6 @@ public class MapGenSpecialFeatures extends MapGenStructure {
}
}
System.out.print(System.nanoTime() - time);
return Vec3.createVectorHelper(pair.chunkXPos - chunkX, 0, pair.chunkZPos - chunkZ);
}
@ -72,18 +72,14 @@ public class MapGenSpecialFeatures extends MapGenStructure {
if(!bookLocs.isEmpty()) return;
long time = System.nanoTime();
for(ChunkCoordIntPair loc : locs) {
bookLocs.add(loc);
}
System.out.print(System.nanoTime() - time);
}*/
}
protected void generatePositions() {
//for safety: maybe mandate interactions with these methods to an outside class/wrapper who say "fuck you"
Random rand = new Random(this.worldObj.getSeed()); //TODO: worldObj is null until func_15139_a is called!! very bad!!!
Random rand = new Random(this.worldObj.getSeed());
double theta = rand.nextDouble() * Math.PI * 2;
int ringMax = 4; //each ring of structures has more (and is farther) than the last
int ringDist = 1;

View File

@ -19,15 +19,17 @@ import net.minecraftforge.event.world.WorldEvent;
public class NTMWorldGenerator implements IWorldGenerator {
private MapGenNTMFeatures scatteredFeatureGen; //looks like it's based! thank god!
private MapGenSpecialFeatures specialFeatureGen; //change back if it's actually cringe and throws NPEs
public MapGenSpecialFeatures specialFeatureGen; //change back if it's actually cringe and throws NPEs
private final Random rand = new Random(); //A central random, used to cleanly generate our stuff without affecting vanilla or modded seeds.
/** Inits all MapGen upon the loading of a new world. Hopefully clears out structureMaps and structureData when a different world is loaded. */
@SubscribeEvent
public void onLoad(WorldEvent.Load event) {
scatteredFeatureGen = (MapGenNTMFeatures) getModdedMapGen(new MapGenNTMFeatures(), EventType.CUSTOM); //TODO: set worlds to a non-null value here.
specialFeatureGen = (MapGenSpecialFeatures) getModdedMapGen(new MapGenSpecialFeatures(), EventType.CUSTOM); //we've got access to it plain n simple here anyway
scatteredFeatureGen = (MapGenNTMFeatures) getModdedMapGen(new MapGenNTMFeatures(), EventType.CUSTOM);
specialFeatureGen = (MapGenSpecialFeatures) getModdedMapGen(new MapGenSpecialFeatures(), EventType.CUSTOM);
specialFeatureGen.setWorld(event.world); //doesn't matter on the client so we're good anyway
hasPopulationEvent = false;
}

View File

@ -6,6 +6,7 @@ import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ModBlocks;
import com.hbm.blocks.generic.BlockBobble.BobbleType;
import com.hbm.blocks.generic.BlockBobble.TileEntityBobble;
import com.hbm.blocks.generic.BlockLoot.TileEntityLoot;
import com.hbm.config.StructureConfig;
import com.hbm.handler.MultiblockHandlerXR;
import com.hbm.tileentity.machine.TileEntityLockableBase;
@ -39,7 +40,7 @@ abstract public class Component extends StructureComponent {
protected Component(Random rand, int minX, int minY, int minZ, int maxX, int maxY, int maxZ ) {
super(0);
this.coordBaseMode = rand.nextInt(4);
this.coordBaseMode = 0;//rand.nextInt(4);
switch(this.coordBaseMode) {
case 0:
@ -435,6 +436,22 @@ abstract public class Component extends StructureComponent {
}
}
protected void placeLootBlock(World world, StructureBoundingBox box, Random rand, int featureX, int featureY, int featureZ, ItemStack stack) {
int posX = this.getXWithOffset(featureX, featureZ);
int posY = this.getYWithOffset(featureY);
int posZ = this.getZWithOffset(featureX, featureZ);
if(!box.isVecInside(posX, posY, posZ)) return;
world.setBlock(posX, posY, posZ, ModBlocks.deco_loot, 0, 2);
TileEntityLoot loot = (TileEntityLoot) world.getTileEntity(posX, posY, posZ);
if(loot != null && loot.items.isEmpty()) {
loot.addItem(stack, rand.nextGaussian() * 0.02, 0, rand.nextGaussian() * 0.02);
}
}
/**
* Places random bobblehead with a randomized orientation at specified location
*/
@ -690,7 +707,7 @@ abstract public class Component extends StructureComponent {
}
}
}
//TODO replace the shitty block selector with something else. probably a lambda that returns a metablock for convenience
protected void fillWithRandomizedBlocks(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ, Random rand, BlockSelector selector) { //so i don't have to replace shit
if(getYWithOffset(minY) < box.minY || getYWithOffset(maxY) > box.maxY)

View File

@ -3,10 +3,16 @@ package com.hbm.world.gen.component;
import java.util.Random;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.special.ItemBookLore;
import com.hbm.lib.HbmChestContents;
import com.hbm.lib.HbmWorld;
import com.hbm.util.LootGenerator;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraft.world.gen.structure.StructureBoundingBox;
@ -546,6 +552,11 @@ public class OfficeFeatures {
placeBlockAtCurrentPosition(world, ModBlocks.deco_loot, 0, 1, 10, 11, box);
LootGenerator.lootMedicine(world, this.getXWithOffset(1, 11), this.getYWithOffset(10), this.getZWithOffset(1, 11));
//if(rand.nextInt(3) == 0) {
Vec3 pair = HbmWorld.worldGenerator.specialFeatureGen.findClosestPosition(this.boundingBox.minX >> 4, this.boundingBox.minZ >> 4);
ItemStack book = ItemBookLore.createBook(pair.xCoord * 16 + ", " + pair.zCoord * 16, 1, 0x7F0037, 0xFFFFFF);
placeLootBlock(world, box, rand, 8, 10, 10, book);
//}
//this hurt my soul
return true;