mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-02-21 21:42:28 +00:00
mhmm
This commit is contained in:
parent
b5df3b0979
commit
40af290153
@ -22,6 +22,8 @@ public class HbmWorld {
|
|||||||
initWorldGen();
|
initWorldGen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static NTMWorldGenerator worldGenerator;
|
||||||
|
|
||||||
public static void initWorldGen() {
|
public static void initWorldGen() {
|
||||||
|
|
||||||
//MapGenStructureIO.registerStructure(StructureStartTest.class, "HFR_STRUCTURE");
|
//MapGenStructureIO.registerStructure(StructureStartTest.class, "HFR_STRUCTURE");
|
||||||
@ -33,7 +35,7 @@ public class HbmWorld {
|
|||||||
|
|
||||||
registerWorldGen(new HbmWorldGen(), 1);
|
registerWorldGen(new HbmWorldGen(), 1);
|
||||||
|
|
||||||
NTMWorldGenerator worldGenerator = new NTMWorldGenerator();
|
worldGenerator = new NTMWorldGenerator();
|
||||||
registerWorldGen(worldGenerator, 1); //Ideally, move everything over from HbmWorldGen to NTMWorldGenerator
|
registerWorldGen(worldGenerator, 1); //Ideally, move everything over from HbmWorldGen to NTMWorldGenerator
|
||||||
MinecraftForge.EVENT_BUS.register(worldGenerator);
|
MinecraftForge.EVENT_BUS.register(worldGenerator);
|
||||||
//registerWorldGen(new WorldGenTest(), 1);
|
//registerWorldGen(new WorldGenTest(), 1);
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
package com.hbm.world.gen;
|
package com.hbm.world.gen;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.hbm.config.GeneralConfig;
|
import com.hbm.config.GeneralConfig;
|
||||||
import com.hbm.world.gen.component.SpecialFeatures.SpecialContainer;
|
import com.hbm.world.gen.component.SpecialFeatures.SpecialContainer;
|
||||||
|
|
||||||
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraft.world.ChunkCoordIntPair;
|
import net.minecraft.world.ChunkCoordIntPair;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.gen.structure.MapGenStructure;
|
import net.minecraft.world.gen.structure.MapGenStructure;
|
||||||
@ -18,7 +21,10 @@ import net.minecraft.world.gen.structure.StructureStart;
|
|||||||
//it's 'special' because it's not unique but also limited
|
//it's 'special' because it's not unique but also limited
|
||||||
public class MapGenSpecialFeatures extends MapGenStructure {
|
public class MapGenSpecialFeatures extends MapGenStructure {
|
||||||
//suuuuuper efficient for .contains()
|
//suuuuuper efficient for .contains()
|
||||||
|
//do i even need chunkcoordintpairs? idk
|
||||||
Set<ChunkCoordIntPair> locs = new HashSet<ChunkCoordIntPair>();
|
Set<ChunkCoordIntPair> locs = new HashSet<ChunkCoordIntPair>();
|
||||||
|
//efficient enough for books n shit
|
||||||
|
List<ChunkCoordIntPair> bookLocs = new ArrayList<ChunkCoordIntPair>();
|
||||||
|
|
||||||
/** String ID for this MapGen */
|
/** String ID for this MapGen */
|
||||||
@Override
|
@Override
|
||||||
@ -28,10 +34,56 @@ public class MapGenSpecialFeatures extends MapGenStructure {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
protected boolean canSpawnStructureAtCoords(int chunkX, int chunkZ) {
|
||||||
|
if(locs.isEmpty())
|
||||||
|
generatePositions();
|
||||||
|
|
||||||
if(locs.isEmpty()) {
|
return locs.contains(new ChunkCoordIntPair(chunkX, chunkZ));
|
||||||
|
}
|
||||||
|
|
||||||
Random rand = new Random(this.worldObj.getSeed());
|
//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) {
|
||||||
|
createBookList();
|
||||||
|
|
||||||
|
long time = System.nanoTime();
|
||||||
|
|
||||||
|
ChunkCoordIntPair pair = new ChunkCoordIntPair(0, 0);
|
||||||
|
long dist = Long.MAX_VALUE;
|
||||||
|
for(ChunkCoordIntPair loc : bookLocs) {
|
||||||
|
int x = loc.chunkXPos - chunkX;
|
||||||
|
int z = loc.chunkZPos - chunkZ;
|
||||||
|
long cont = x * x + z * z;
|
||||||
|
|
||||||
|
if(cont < dist) {
|
||||||
|
pair = loc;
|
||||||
|
dist = cont;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.print(System.nanoTime() - time);
|
||||||
|
|
||||||
|
return Vec3.createVectorHelper(pair.chunkXPos - chunkX, 0, pair.chunkZPos - chunkZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void createBookList() {
|
||||||
|
if(locs.isEmpty())
|
||||||
|
generatePositions();
|
||||||
|
|
||||||
|
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!!!
|
||||||
double theta = rand.nextDouble() * Math.PI * 2;
|
double theta = rand.nextDouble() * Math.PI * 2;
|
||||||
int ringMax = 4; //each ring of structures has more (and is farther) than the last
|
int ringMax = 4; //each ring of structures has more (and is farther) than the last
|
||||||
int ringDist = 1;
|
int ringDist = 1;
|
||||||
@ -52,7 +104,7 @@ public class MapGenSpecialFeatures extends MapGenStructure {
|
|||||||
|
|
||||||
if(i == (ringDist - 1) * 4 + ringMax) {
|
if(i == (ringDist - 1) * 4 + ringMax) {
|
||||||
ringDist++;
|
ringDist++;
|
||||||
|
//maybe insert random theta each time?
|
||||||
if(i + ringDist * 4 > total) //last ring may be sparser, but evenly spaced too
|
if(i + ringDist * 4 > total) //last ring may be sparser, but evenly spaced too
|
||||||
ringMax = total - i;
|
ringMax = total - i;
|
||||||
else
|
else
|
||||||
@ -61,11 +113,10 @@ public class MapGenSpecialFeatures extends MapGenStructure {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return locs.contains(new ChunkCoordIntPair(chunkX, chunkZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected StructureStart getStructureStart(int chunkX, int chunkZ) {
|
protected StructureStart getStructureStart(int chunkX, int chunkZ) {
|
||||||
|
locs.remove(new ChunkCoordIntPair(chunkX, chunkZ));
|
||||||
|
|
||||||
return new SpecialStart(this.worldObj, this.rand, chunkX, chunkZ);
|
return new SpecialStart(this.worldObj, this.rand, chunkX, chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,8 +26,8 @@ public class NTMWorldGenerator implements IWorldGenerator {
|
|||||||
/** Inits all MapGen upon the loading of a new world. Hopefully clears out structureMaps and structureData when a different world is loaded. */
|
/** Inits all MapGen upon the loading of a new world. Hopefully clears out structureMaps and structureData when a different world is loaded. */
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onLoad(WorldEvent.Load event) {
|
public void onLoad(WorldEvent.Load event) {
|
||||||
scatteredFeatureGen = (MapGenNTMFeatures) getModdedMapGen(new MapGenNTMFeatures(), EventType.CUSTOM);
|
scatteredFeatureGen = (MapGenNTMFeatures) getModdedMapGen(new MapGenNTMFeatures(), EventType.CUSTOM); //TODO: set worlds to a non-null value here.
|
||||||
specialFeatureGen = (MapGenSpecialFeatures) getModdedMapGen(new MapGenSpecialFeatures(), EventType.CUSTOM);
|
specialFeatureGen = (MapGenSpecialFeatures) getModdedMapGen(new MapGenSpecialFeatures(), EventType.CUSTOM); //we've got access to it plain n simple here anyway
|
||||||
hasPopulationEvent = false;
|
hasPopulationEvent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user