Biomes support multi-custom instances

This commit is contained in:
Daniel Mills 2021-07-14 13:51:01 -04:00
parent fd8077a5cd
commit c167e881fb
4 changed files with 36 additions and 15 deletions

View File

@ -2,6 +2,7 @@ package com.volmit.iris.generator.actuator;
import com.volmit.iris.nms.INMS; import com.volmit.iris.nms.INMS;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomeCustom;
import com.volmit.iris.scaffold.engine.Engine; import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.engine.EngineAssignedActuator; import com.volmit.iris.scaffold.engine.EngineAssignedActuator;
import com.volmit.iris.scaffold.hunk.Hunk; import com.volmit.iris.scaffold.hunk.Hunk;
@ -13,8 +14,11 @@ import com.volmit.iris.util.RNG;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
public class IrisBiomeActuator extends EngineAssignedActuator<Biome> { public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
private final RNG rng;
public IrisBiomeActuator(Engine engine) { public IrisBiomeActuator(Engine engine) {
super(engine, "Biome"); super(engine, "Biome");
rng = new RNG(engine.getWorld().getSeed() + 243995);
} }
@Override @Override
@ -35,7 +39,8 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
{ {
try try
{ {
Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey()+":"+ib.getCustom().getId()); IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey()+":"+custom.getId());
((BiomeGridHunkView)h).forceBiomeBaseInto(x, 0, z, biomeBase); ((BiomeGridHunkView)h).forceBiomeBaseInto(x, 0, z, biomeBase);
for (int i = 0; i < h.getHeight(); i++) { for (int i = 0; i < h.getHeight(); i++) {
@ -46,7 +51,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
catch(Throwable e) catch(Throwable e)
{ {
e.printStackTrace(); e.printStackTrace();
Biome v = ib.getSkyBiome(RNG.r, x, 0, z); Biome v = ib.getSkyBiome(rng, x, 0, z);
for (int i = 0; i < h.getHeight(); i++) { for (int i = 0; i < h.getHeight(); i++) {
h.set(xxf, i, zzf, v); h.set(xxf, i, zzf, v);
} }
@ -55,7 +60,7 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
else else
{ {
Biome v = ib.getSkyBiome(RNG.r, x, 0, z); Biome v = ib.getSkyBiome(rng, x, 0, z);
for (int i = 0; i < h.getHeight(); i++) { for (int i = 0; i < h.getHeight(); i++) {
h.set(xxf, i, zzf, v); h.set(xxf, i, zzf, v);
} }

View File

@ -32,8 +32,9 @@ public class IrisBiome extends IrisRegistrant implements IRare {
private String name = "A Biome"; private String name = "A Biome";
@DontObfuscate @DontObfuscate
@ArrayType(min = 1, type = IrisBiomeCustom.class)
@Desc("If the biome type custom is defined, specify this") @Desc("If the biome type custom is defined, specify this")
private IrisBiomeCustom custom; private KList<IrisBiomeCustom> customDerivitives;
@DontObfuscate @DontObfuscate
@Desc("Entity spawns to override or add to this biome. Anytime an entity spawns, it has a chance to be replaced as one of these overrides.") @Desc("Entity spawns to override or add to this biome. Anytime an entity spawns, it has a chance to be replaced as one of these overrides.")
@ -201,7 +202,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
public boolean isCustom() public boolean isCustom()
{ {
return getCustom() != null; return getCustomDerivitives() != null && getCustomDerivitives().isNotEmpty();
} }
public double getGenLinkMax(String loadKey) { public double getGenLinkMax(String loadKey) {
@ -535,6 +536,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z)); return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
} }
public IrisBiomeCustom getCustomBiome(RNG rng, double x, double y, double z) {
if (customDerivitives.size() == 1) {
return customDerivitives.get(0);
}
return customDerivitives.get(getBiomeGenerator(rng).fit(0, customDerivitives.size() - 1, x, y, z));
}
public KList<IrisBiome> getRealChildren(DataProvider g) { public KList<IrisBiome> getRealChildren(DataProvider g) {
return realChildren.aquire(() -> return realChildren.aquire(() ->
{ {
@ -564,6 +573,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
return new KList<String>(m); return new KList<String>(m);
} }
//TODO: Test
public Biome getGroundBiome(RNG rng, double x, double y, double z) { public Biome getGroundBiome(RNG rng, double x, double y, double z) {
if (biomeScatter.isEmpty()) { if (biomeScatter.isEmpty()) {
return getDerivative(); return getDerivative();

View File

@ -65,6 +65,8 @@ public class IrisBlockDrops {
return false; return false;
} }
// TODO: WARNING USES RNG.R
@Deprecated
public void fillDrops(boolean debug, KList<ItemStack> d) { public void fillDrops(boolean debug, KList<ItemStack> d) {
for (IrisLoot i : getDrops()) { for (IrisLoot i : getDrops()) {
if (RNG.r.i(1, i.getRarity()) == i.getRarity()) { if (RNG.r.i(1, i.getRarity()) == i.getRarity()) {

View File

@ -468,19 +468,23 @@ public class IrisDimension extends IrisRegistrant {
if(i.isCustom()) if(i.isCustom())
{ {
write = true; write = true;
File output = new File(datapacks, "iris/data/" + getLoadKey() + "/worldgen/biome/" + i.getCustom().getId() + ".json");
if(!output.exists()) for(IrisBiomeCustom j : i.getCustomDerivitives())
{ {
changed = true; File output = new File(datapacks, "iris/data/" + getLoadKey() + "/worldgen/biome/" + j.getId() + ".json");
}
Iris.verbose(" Installing Data Pack Biome: " + output.getPath()); if(!output.exists())
output.getParentFile().mkdirs(); {
try { changed = true;
IO.writeAll(output, i.getCustom().generateJson()); }
} catch (IOException e) {
e.printStackTrace(); Iris.verbose(" Installing Data Pack Biome: " + output.getPath());
output.getParentFile().mkdirs();
try {
IO.writeAll(output, j.generateJson());
} catch (IOException e) {
e.printStackTrace();
}
} }
} }
} }