From 60843b3bb9dd60ad763df676c4685814a9e2ff62 Mon Sep 17 00:00:00 2001 From: cyberpwn Date: Wed, 14 Sep 2022 13:30:39 -0400 Subject: [PATCH] f --- .../com/volmit/iris/core/nms/INMSBinding.java | 2 + .../iris/core/nms/v19_2/NMSBinding19_2.java | 13 +++-- .../iris/core/nms/v1X/NMSBinding1X.java | 5 ++ .../volmit/iris/engine/IrisWorldManager.java | 8 +--- .../engine/actuator/IrisBiomeActuator.java | 48 ++++++++++++------- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/volmit/iris/core/nms/INMSBinding.java b/src/main/java/com/volmit/iris/core/nms/INMSBinding.java index 5cb491a2e..2420cc6eb 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMSBinding.java +++ b/src/main/java/com/volmit/iris/core/nms/INMSBinding.java @@ -58,6 +58,8 @@ public interface INMSBinding { Object getCustomBiomeBaseFor(String mckey); Object getCustomBiomeBaseHolderFor(String mckey); + int getBiomeBaseIdForKey(String key); + String getKeyForBiomeBase(Object biomeBase); Object getBiomeBase(World world, Biome biome); diff --git a/src/main/java/com/volmit/iris/core/nms/v19_2/NMSBinding19_2.java b/src/main/java/com/volmit/iris/core/nms/v19_2/NMSBinding19_2.java index 9dab95d52..2243292e8 100644 --- a/src/main/java/com/volmit/iris/core/nms/v19_2/NMSBinding19_2.java +++ b/src/main/java/com/volmit/iris/core/nms/v19_2/NMSBinding19_2.java @@ -22,7 +22,6 @@ package com.volmit.iris.core.nms.v19_2; import com.volmit.iris.Iris; import com.volmit.iris.core.nms.INMSBinding; import com.volmit.iris.engine.data.cache.AtomicCache; -import com.volmit.iris.engine.object.IrisBiome; import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.hunk.Hunk; import com.volmit.iris.util.mantle.Mantle; @@ -196,7 +195,7 @@ public class NMSBinding19_2 implements INMSBinding { @Override public int getTrueBiomeBaseId(Object biomeBase) { - return getCustomBiomeRegistry().getId((net.minecraft.world.level.biome.Biome) biomeBase); + return getCustomBiomeRegistry().getId(((Holder) biomeBase).value()); } @Override @@ -218,6 +217,10 @@ public class NMSBinding19_2 implements INMSBinding { return getCustomBiomeRegistry().getHolder(getTrueBiomeBaseId(getCustomBiomeRegistry().get(new ResourceLocation(mckey)))).get(); } + public int getBiomeBaseIdForKey(String key) { + return getCustomBiomeRegistry().getId(getCustomBiomeRegistry().get(new ResourceLocation(key))); + } + @Override public String getKeyForBiomeBase(Object biomeBase) { return getCustomBiomeRegistry().getKey((net.minecraft.world.level.biome.Biome) biomeBase).getPath(); // something, not something:something @@ -404,19 +407,23 @@ public class NMSBinding19_2 implements INMSBinding { @Override public void injectBiomesFromMantle(Chunk e, Mantle mantle) { LevelChunk chunk = ((CraftChunk)e).getHandle(); + AtomicInteger c = new AtomicInteger(); + AtomicInteger r = new AtomicInteger(); mantle.iterateChunk(e.getX(), e.getZ(), MatterBiomeInject.class, (x,y,z,b) -> { if(b != null) { if(b.isCustom()) { chunk.setBiome(x, y, z, (Holder) getBiomeBaseFromId(b.getBiomeId())); + c.getAndIncrement(); } else { chunk.setBiome(x, y, z, (Holder) getBiomeBase(e.getWorld(), b.getBiome())); + r.getAndIncrement(); } } }); - chunk.setUnsaved(true); + Iris.info("Injected " + c.get() + " custom biomes and " + r.get() + " vanilla biomes into chunk " + e.getX() + "," + e.getZ()); } private static Object getFor(Class type, Object source) { diff --git a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java index 59cf364fc..15bf05294 100644 --- a/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java +++ b/src/main/java/com/volmit/iris/core/nms/v1X/NMSBinding1X.java @@ -124,6 +124,11 @@ public class NMSBinding1X implements INMSBinding { return null; } + @Override + public int getBiomeBaseIdForKey(String key) { + return 0; + } + @Override public String getKeyForBiomeBase(Object biomeBase) { return null; diff --git a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java index c03b3c51a..3792052bd 100644 --- a/src/main/java/com/volmit/iris/engine/IrisWorldManager.java +++ b/src/main/java/com/volmit/iris/engine/IrisWorldManager.java @@ -479,12 +479,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager { fixEnergy(); getEngine().cleanupMantleChunk(e.getX(), e.getZ()); - if(generated && !injectBiomes.isEmpty()) { - Position2 p = new Position2(e.getX(), e.getZ()); - - if(injectBiomes.remove(p)) { - INMS.get().injectBiomesFromMantle(e, getMantle()); - } + if(generated) { + INMS.get().injectBiomesFromMantle(e, getMantle()); } } diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java index c3946d3a5..c2f54ac56 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisBiomeActuator.java @@ -52,30 +52,42 @@ public class IrisBiomeActuator extends EngineAssignedActuator { @BlockCoordinates @Override public void onActuate(int x, int z, Hunk h, boolean multicore, ChunkContext context) { - PrecisionStopwatch p = PrecisionStopwatch.start(); + try + { + PrecisionStopwatch p = PrecisionStopwatch.start(); - for(int xf = 0; xf < h.getWidth(); xf++) { - IrisBiome ib; - for(int zf = 0; zf < h.getDepth(); zf++) { - ib = context.getBiome().get(xf, zf); - int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData())); - MatterBiomeInject matter = null; + int m = 0; + for(int xf = 0; xf < h.getWidth(); xf++) { + IrisBiome ib; + for(int zf = 0; zf < h.getDepth(); zf++) { + ib = context.getBiome().get(xf, zf); + int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData())); + MatterBiomeInject matter = null; - if(ib.isCustom()) { - IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z); - Object biomeBase = INMS.get().getCustomBiomeBaseHolderFor(getDimension().getLoadKey() + ":" + custom.getId()); - matter = BiomeInjectMatter.get(INMS.get().getTrueBiomeBaseId(biomeBase)); - } else { - Biome v = ib.getSkyBiome(rng, x, 0, z); - matter = BiomeInjectMatter.get(v); - } + if(ib.isCustom()) { + IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z); + matter = BiomeInjectMatter.get(INMS.get().getBiomeBaseIdForKey(getDimension().getLoadKey() + ":" + custom.getId())); + } else { + Biome v = ib.getSkyBiome(rng, x, 0, z); + matter = BiomeInjectMatter.get(v); + } + + for(int i = 0; i < maxHeight; i++) { + getEngine().getMantle().getMantle().set(x, i, z, matter); + m++; + } - for(int i = 0; i < maxHeight; i++) { - getEngine().getMantle().getMantle().set(x, i, z, matter); } } + + getEngine().getMetrics().getBiome().put(p.getMilliseconds()); + Iris.info("Biome Actuator: " + p.getMilliseconds() + "ms"); + Iris.info("Mantle: " + m + " blocks"); } - getEngine().getMetrics().getBiome().put(p.getMilliseconds()); + catch(Throwable e) + { + e.printStackTrace(); + } } }