mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Buffet mode fixes
This commit is contained in:
parent
fe78d4f1e7
commit
e06175f600
@ -32,7 +32,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'com.volmit.iris'
|
group 'com.volmit.iris'
|
||||||
version '1.7.9'
|
version '1.7.10'
|
||||||
def apiVersion = '1.17'
|
def apiVersion = '1.17'
|
||||||
def name = getRootProject().getName() // See settings.gradle
|
def name = getRootProject().getName() // See settings.gradle
|
||||||
def main = 'com.volmit.iris.Iris'
|
def main = 'com.volmit.iris.Iris'
|
||||||
|
@ -177,12 +177,21 @@ public class IrisEngine implements Engine {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hotload() {
|
public void hotload() {
|
||||||
|
hotloadSilently();
|
||||||
|
Iris.callEvent(new IrisEngineHotloadEvent(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hotloadComplex() {
|
||||||
|
complex.close();
|
||||||
|
complex = new IrisComplex(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hotloadSilently() {
|
||||||
getData().dump();
|
getData().dump();
|
||||||
getData().clearLists();
|
getData().clearLists();
|
||||||
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
|
getTarget().setDimension(getData().getDimensionLoader().load(getDimension().getLoadKey()));
|
||||||
prehotload();
|
prehotload();
|
||||||
setupEngine();
|
setupEngine();
|
||||||
Iris.callEvent(new IrisEngineHotloadEvent(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,6 +24,7 @@ import com.volmit.iris.core.gui.components.Renderer;
|
|||||||
import com.volmit.iris.core.project.loader.IrisData;
|
import com.volmit.iris.core.project.loader.IrisData;
|
||||||
import com.volmit.iris.engine.IrisComplex;
|
import com.volmit.iris.engine.IrisComplex;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||||
import com.volmit.iris.engine.object.basic.IrisColor;
|
import com.volmit.iris.engine.object.basic.IrisColor;
|
||||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||||
@ -66,6 +67,7 @@ import org.bukkit.block.Biome;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -86,6 +88,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
|
|
||||||
EngineMantle getMantle();
|
EngineMantle getMantle();
|
||||||
|
|
||||||
|
void hotloadSilently();
|
||||||
|
|
||||||
|
void hotloadComplex();
|
||||||
|
|
||||||
void recycle();
|
void recycle();
|
||||||
|
|
||||||
EngineActuator<BlockData> getTerrainActuator();
|
EngineActuator<BlockData> getTerrainActuator();
|
||||||
@ -140,6 +146,12 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
|||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
double modifyZ(double z);
|
double modifyZ(double z);
|
||||||
|
|
||||||
|
@BlockCoordinates
|
||||||
|
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException
|
||||||
|
{
|
||||||
|
generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc), multicore);
|
||||||
|
}
|
||||||
|
|
||||||
@BlockCoordinates
|
@BlockCoordinates
|
||||||
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) throws WrongEngineBroException;
|
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) throws WrongEngineBroException;
|
||||||
|
|
||||||
|
@ -92,6 +92,9 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
@Desc("Vertically split up the biome palettes with 3 air blocks in between to visualize them")
|
@Desc("Vertically split up the biome palettes with 3 air blocks in between to visualize them")
|
||||||
private boolean explodeBiomePalettes = false;
|
private boolean explodeBiomePalettes = false;
|
||||||
|
|
||||||
|
@Desc("Studio Mode for testing different parts of the world")
|
||||||
|
private StudioMode studioMode = StudioMode.NORMAL;
|
||||||
|
|
||||||
@MinNumber(1)
|
@MinNumber(1)
|
||||||
@MaxNumber(16)
|
@MaxNumber(16)
|
||||||
@Desc("Customize the palette height explosion")
|
@Desc("Customize the palette height explosion")
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.object.dimensional;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.object.annotations.Desc;
|
||||||
|
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||||
|
import com.volmit.iris.engine.platform.studio.generators.BiomeBuffetGenerator;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Desc("Represents a studio mode")
|
||||||
|
public enum StudioMode {
|
||||||
|
NORMAL(i -> i.setStudioGenerator(null)),
|
||||||
|
BIOME_BUFFET_1x1(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 1))),
|
||||||
|
BIOME_BUFFET_3x3(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 3))),
|
||||||
|
BIOME_BUFFET_5x5(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 5))),
|
||||||
|
BIOME_BUFFET_9x9(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 9))),
|
||||||
|
BIOME_BUFFET_18x18(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 18))),
|
||||||
|
BIOME_BUFFET_36x36(i -> i.setStudioGenerator(new BiomeBuffetGenerator(i.getEngine(), 36))),
|
||||||
|
REGION_BUFFET(i -> i.setStudioGenerator(null)),
|
||||||
|
OBJECT_BUFFET(i -> i.setStudioGenerator(null)),
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final Consumer<BukkitChunkGenerator> injector;
|
||||||
|
|
||||||
|
StudioMode(Consumer<BukkitChunkGenerator> injector)
|
||||||
|
{
|
||||||
|
this.injector = injector;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inject(BukkitChunkGenerator c)
|
||||||
|
{
|
||||||
|
injector.accept(c);
|
||||||
|
}
|
||||||
|
}
|
@ -28,6 +28,8 @@ import com.volmit.iris.engine.framework.EngineTarget;
|
|||||||
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||||
import com.volmit.iris.engine.object.common.IrisWorld;
|
import com.volmit.iris.engine.object.common.IrisWorld;
|
||||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||||
|
import com.volmit.iris.engine.object.dimensional.StudioMode;
|
||||||
|
import com.volmit.iris.engine.platform.studio.StudioGenerator;
|
||||||
import com.volmit.iris.util.collection.KList;
|
import com.volmit.iris.util.collection.KList;
|
||||||
import com.volmit.iris.util.data.IrisBiomeStorage;
|
import com.volmit.iris.util.data.IrisBiomeStorage;
|
||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
@ -38,6 +40,7 @@ import com.volmit.iris.util.scheduling.J;
|
|||||||
import com.volmit.iris.util.scheduling.Looper;
|
import com.volmit.iris.util.scheduling.Looper;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -72,10 +75,15 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
private final KList<BlockPopulator> populators;
|
private final KList<BlockPopulator> populators;
|
||||||
private final ChronoLatch hotloadChecker;
|
private final ChronoLatch hotloadChecker;
|
||||||
private final Looper hotloader;
|
private final Looper hotloader;
|
||||||
|
private StudioMode lastMode;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private StudioGenerator studioGenerator;
|
||||||
private final boolean studio;
|
private final boolean studio;
|
||||||
private long lastSeed;
|
private long lastSeed;
|
||||||
|
|
||||||
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
public BukkitChunkGenerator(IrisWorld world, boolean studio, File dataLocation, String dimensionKey) {
|
||||||
|
studioGenerator = null;
|
||||||
populators = new KList<>();
|
populators = new KList<>();
|
||||||
lastSeed = world.seed();
|
lastSeed = world.seed();
|
||||||
loadLock = new Semaphore(LOAD_LOCKS);
|
loadLock = new Semaphore(LOAD_LOCKS);
|
||||||
@ -130,6 +138,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastMode = StudioMode.NORMAL;
|
||||||
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
engine = new IrisEngine(new EngineTarget(world, dimension, data), studio);
|
||||||
populators.clear();
|
populators.clear();
|
||||||
}
|
}
|
||||||
@ -156,7 +165,7 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||||
this.world.bind(world);
|
this.world.bind(world);
|
||||||
getEngine().generate(x * 16, z * 16, blocks, biomes, true);
|
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
|
||||||
Iris.debug("Regenerated " + x + " " + z);
|
Iris.debug("Regenerated " + x + " " + z);
|
||||||
int t = 0;
|
int t = 0;
|
||||||
for(int i = getEngine().getHeight() >> 4; i >= 0; i--)
|
for(int i = getEngine().getHeight() >> 4; i >= 0; i--)
|
||||||
@ -271,11 +280,22 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadLock.acquire();
|
loadLock.acquire();
|
||||||
|
computeStudioGenerator();
|
||||||
TerrainChunk tc = TerrainChunk.create(world, biome);
|
TerrainChunk tc = TerrainChunk.create(world, biome);
|
||||||
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
|
||||||
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
|
||||||
this.world.bind(world);
|
this.world.bind(world);
|
||||||
getEngine().generate(x * 16, z * 16, blocks, biomes, true);
|
|
||||||
|
if(studioGenerator != null)
|
||||||
|
{
|
||||||
|
studioGenerator.generateChunk(getEngine(), tc, x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hunk<BlockData> blocks = Hunk.view((ChunkData) tc);
|
||||||
|
Hunk<Biome> biomes = Hunk.view((BiomeGrid) tc);
|
||||||
|
getEngine().generate(x << 4, z << 4, blocks, biomes, true);
|
||||||
|
}
|
||||||
|
|
||||||
ChunkData c = tc.getRaw();
|
ChunkData c = tc.getRaw();
|
||||||
Iris.debug("Generated " + x + " " + z);
|
Iris.debug("Generated " + x + " " + z);
|
||||||
loadLock.release();
|
loadLock.release();
|
||||||
@ -312,6 +332,14 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void computeStudioGenerator() {
|
||||||
|
if(!getEngine().getDimension().getStudioMode().equals(lastMode))
|
||||||
|
{
|
||||||
|
lastMode = getEngine().getDimension().getStudioMode();
|
||||||
|
getEngine().getDimension().getStudioMode().inject(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
public List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.platform.studio;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public abstract class EnginedStudioGenerator implements StudioGenerator{
|
||||||
|
private final Engine engine;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public abstract void generateChunk(Engine engine, TerrainChunk tc, int x, int z) throws WrongEngineBroException;
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.platform.studio;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||||
|
|
||||||
|
public interface StudioGenerator {
|
||||||
|
void generateChunk(Engine engine, TerrainChunk tc, int x, int z) throws WrongEngineBroException;
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.volmit.iris.engine.platform.studio.generators;
|
||||||
|
|
||||||
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
|
import com.volmit.iris.engine.data.chunk.TerrainChunk;
|
||||||
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||||
|
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||||
|
import com.volmit.iris.engine.platform.studio.EnginedStudioGenerator;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class BiomeBuffetGenerator extends EnginedStudioGenerator {
|
||||||
|
private static final BlockData FLOOR = Material.BARRIER.createBlockData();
|
||||||
|
private final IrisBiome[] biomes;
|
||||||
|
private final int width;
|
||||||
|
private final int biomeSize;
|
||||||
|
|
||||||
|
public BiomeBuffetGenerator(Engine engine, int biomeSize) {
|
||||||
|
super(engine);
|
||||||
|
this.biomeSize = biomeSize;
|
||||||
|
biomes = engine.getDimension().getAllBiomes(engine).toArray(new IrisBiome[0]);
|
||||||
|
width = Math.max((int) Math.sqrt(biomes.length), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateChunk(Engine engine, TerrainChunk tc, int x, int z) throws WrongEngineBroException {
|
||||||
|
int id = Cache.to1D(x/biomeSize, 0, z/biomeSize, width, 1);
|
||||||
|
|
||||||
|
if(id >= 0 && id < biomes.length)
|
||||||
|
{
|
||||||
|
IrisBiome biome = biomes[id];
|
||||||
|
String foc = engine.getDimension().getFocus();
|
||||||
|
|
||||||
|
if(!Objects.equals(foc, biome.getLoadKey()))
|
||||||
|
{
|
||||||
|
engine.getDimension().setFocus(biome.getLoadKey());
|
||||||
|
engine.hotloadComplex();
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.generate(x << 4, z << 4, tc, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
tc.setRegion(0,0,0,16, 1, 16, FLOOR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user