This commit is contained in:
Daniel Mills 2021-01-08 02:50:28 -05:00
parent 4a30b6d264
commit b6f3e3a62f
8 changed files with 0 additions and 1855 deletions

View File

@ -1,14 +0,0 @@
package com.volmit.iris.nms;
import org.bukkit.World;
import org.bukkit.WorldCreator;
public interface INMSCreator
{
default World createWorld(WorldCreator creator)
{
return createWorld(creator, false);
}
public World createWorld(WorldCreator creator, boolean loadSpawn);
}

View File

@ -1,596 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.volmit.iris.nms.v16_2;
import com.mojang.serialization.Codec;
import com.volmit.iris.nms.INMS;
import com.volmit.iris.scaffold.cache.Cache;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.scaffold.engine.IrisAccess;
import com.volmit.iris.scaffold.engine.IrisAccessProvider;
import com.volmit.iris.util.*;
import net.minecraft.server.v1_16_R2.BlockPosition;
import net.minecraft.server.v1_16_R2.HeightMap;
import net.minecraft.server.v1_16_R2.*;
import org.bukkit.WorldCreator;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers;
import org.bukkit.material.MaterialData;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
public final class NMSChunkGenerator_16_2 extends ChunkGenerator implements IrisAccessProvider {
private static final IBlockData k;
private final O<WorldServer> ws;
protected final IBlockData f;
protected final IBlockData g;
private final long w;
private final int maxHeight;
private final int xzSize;
protected final Supplier<GeneratorSettingBase> h;
private WorldCreator wc;
private EngineCompositeGenerator gen;
private BlockColumn BC;
private KMap<Long, Runnable> posts = new KMap<>();
static {
k = Blocks.AIR.getBlockData();
}
public NMSChunkGenerator_16_2(O<WorldServer> ws, WorldCreator wc, WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier) {
this(ws, wc, worldchunkmanager, worldchunkmanager, i, supplier);
}
private NMSChunkGenerator_16_2(O<WorldServer> ws, WorldCreator wc, WorldChunkManager worldchunkmanager, WorldChunkManager worldchunkmanager1, long i, Supplier<GeneratorSettingBase> supplier) {
super(worldchunkmanager, worldchunkmanager1, ((GeneratorSettingBase)supplier.get()).a(), i);
this.wc = wc;
this.ws = ws;
this.gen = (EngineCompositeGenerator) wc.generator();
this.w = i;
GeneratorSettingBase generatorsettingbase = supplier.get();
this.h = supplier;
NoiseSettings noisesettings = generatorsettingbase.b();
this.f = generatorsettingbase.c();
this.g = generatorsettingbase.d();
this.maxHeight = noisesettings.f() * 4;
this.xzSize = noisesettings.a() / this.maxHeight;
BC = new BlockColumn(new IBlockData[this.xzSize * this.maxHeight]);
}
public int getSpawnHeight()
{
return getSeaLevel() + 8;
}
public WorldChunkManager getWorldChunkManager()
{
return this.c;
}
public int getGenerationDepth()
{
return 256;
}
public void doCarving(long i, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features)
{
if(gen.isVanillaCaves())
{
super.doCarving(i, biomemanager, ichunkaccess, worldgenstage_features);
}
}
@Override
protected Codec<? extends ChunkGenerator> a()
{
return ChunkGeneratorAbstract.d;
}
public boolean a(long i, ResourceKey<GeneratorSettingBase> resourcekey)
{
return this.w == i && this.h.get().a(resourcekey);
}
@Override
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type)
{
try
{
return 1+gen.getComposite().getDefaultEngine().getMinHeight() + Math.max(gen.getComposite().getDefaultEngine().getHeight(i, j), gen.getComposite().getDefaultEngine().getDimension().getFluidHeight());
}
catch(Throwable e)
{
return 0;
}
}
@Override
public IBlockAccess a(int x, int z)
{
return BC;
}
protected IBlockData a(double d0, int i)
{
IBlockData iblockdata;
if(d0 > 0.0D)
{
iblockdata = this.f;
}
else if(i < this.getSeaLevel())
{
iblockdata = this.g;
}
else
{
iblockdata = k;
}
return iblockdata;
}
@Override
public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess)
{
}
@Override
public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess)
{
KList<StructurePiece> objectlist = new KList<StructurePiece>(10);
KList<WorldGenFeatureDefinedStructureJigsawJunction> objectlist1 = new KList<>(32);
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
int i = chunkcoordintpair.x;
int j = chunkcoordintpair.z;
int k = i << 4;
int l = j << 4;
if(gen.shouldGenerateStructures())
{
Iterator<?> iterator = StructureGenerator.t.iterator();
while(iterator.hasNext())
{
StructureGenerator<?> structuregenerator = (StructureGenerator<?>) iterator.next();
structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) ->
{
Iterator<?> iterator1 = structurestart.d().iterator();
while(iterator1.hasNext())
{
StructurePiece structurepiece = (StructurePiece) iterator1.next();
if(structurepiece.a(chunkcoordintpair, 12))
{
if(structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece)
{
WorldGenFeaturePillagerOutpostPoolPiece worldgenfeaturepillageroutpostpoolpiece = (WorldGenFeaturePillagerOutpostPoolPiece) structurepiece;
WorldGenFeatureDefinedStructurePoolTemplate.Matching worldgenfeaturedefinedstructurepooltemplate_matching = worldgenfeaturepillageroutpostpoolpiece.b().e();
if(worldgenfeaturedefinedstructurepooltemplate_matching == WorldGenFeatureDefinedStructurePoolTemplate.Matching.RIGID)
{
objectlist.add(worldgenfeaturepillageroutpostpoolpiece);
}
Iterator<?> iterator2 = worldgenfeaturepillageroutpostpoolpiece.e().iterator();
while(iterator2.hasNext())
{
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = (WorldGenFeatureDefinedStructureJigsawJunction) iterator2.next();
int i1 = worldgenfeaturedefinedstructurejigsawjunction.a();
int j1 = worldgenfeaturedefinedstructurejigsawjunction.c();
if(i1 > k - 12 && j1 > l - 12 && i1 < k + 15 + 12 && j1 < l + 15 + 12)
{
objectlist1.add(worldgenfeaturedefinedstructurejigsawjunction);
}
}
}
else
{
objectlist.add(structurepiece);
}
}
}
});
}
}
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
HeightMap heightmap = protochunk.a(HeightMap.Type.OCEAN_FLOOR_WG);
HeightMap heightmap1 = protochunk.a(HeightMap.Type.WORLD_SURFACE_WG);
AtomicBoolean allow = new AtomicBoolean(true);
posts.put(Cache.key(i, j), gen.generateChunkRawData(ws.get().getWorld(), i, j, new TerrainChunk() {
@Override
public void setBiome(int x, int y, int z, Biome bio)
{
protochunk.getBiomeIndex().setBiome(x, y, z, (BiomeBase) INMS.get().getBiomeBase(ws.get().r().b(IRegistry.ay), bio));
}
@Override
public void setBiome(int x, int z, Biome bio)
{
protochunk.getBiomeIndex().setBiome(x, 0, z, (BiomeBase) INMS.get().getBiomeBase(ws.get().r().b(IRegistry.ay), bio));
}
@Override
public Biome getBiome(int x, int y, int z)
{
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x&15, y, z&15));
}
@Override
public void setRaw(org.bukkit.generator.ChunkGenerator.ChunkData data) {
}
@Override
public Biome getBiome(int x, int z)
{
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, 0, z));
}
public int getMaxHeight()
{
return 256;
}
public void setBlock(int x, int y, int z, org.bukkit.Material material)
{
this.setBlock(x, y, z, material.createBlockData());
}
public void setBlock(int x, int y, int z, MaterialData material)
{
this.setBlock(x, y, z, CraftMagicNumbers.getBlock((MaterialData) material));
}
public void setBlock(int x, int y, int z, BlockData blockData)
{
if(allow.get())
{
heightmap.a(x,y,z,((CraftBlockData) blockData).getState());
heightmap1.a(x,y,z,((CraftBlockData) blockData).getState());
}
this.setBlock(x, y, z, ((CraftBlockData) blockData).getState());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, org.bukkit.Material material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.createBlockData());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock((MaterialData) material));
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState());
}
public org.bukkit.Material getType(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial((Block) this.getTypeId(x, y, z).getBlock());
}
public MaterialData getTypeAndData(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial((IBlockData) this.getTypeId(x, y, z));
}
public BlockData getBlockData(int x, int y, int z)
{
return CraftBlockData.fromData((IBlockData) this.getTypeId(x, y, z));
}
@Override
public org.bukkit.generator.ChunkGenerator.ChunkData getRaw() {
return null;
}
@Override
public void inject(org.bukkit.generator.ChunkGenerator.BiomeGrid biome) {
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type)
{
if(xMin > 15 || yMin >= getMaxHeight() || zMin > 15)
{
return;
}
if(xMin < 0)
{
xMin = 0;
}
if(yMin < 0)
{
yMin = 0;
}
if(zMin < 0)
{
zMin = 0;
}
if(xMax > 16)
{
xMax = 16;
}
if(yMax > getMaxHeight())
{
yMax = getMaxHeight();
}
if(zMax > 16)
{
zMax = 16;
}
if(xMin >= xMax || yMin >= yMax || zMin >= zMax)
{
return;
}
int y = yMin;
while(y < yMax)
{
int x = xMin;
while(x < xMax)
{
int z = zMin;
while(z < zMax)
{
protochunk.setType(new BlockPosition(x, y, z), type, false);
++z;
}
++x;
}
++y;
}
}
public IBlockData getTypeId(int x, int y, int z)
{
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
{
return Blocks.AIR.getBlockData();
}
return protochunk.getType(new BlockPosition(x, y, z));
}
public byte getData(int x, int y, int z)
{
return CraftMagicNumbers.toLegacyData((IBlockData) this.getTypeId(x, y, z));
}
private void setBlock(int x, int y, int z, IBlockData type)
{
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
{
return;
}
protochunk.setType(new BlockPosition(x, y, z), type, false);
if(type.getBlock().isTileEntity())
{
// if (this.tiles == null) {
// this.tiles = new HashSet<BlockPosition>();
// }
// this.tiles.add(new BlockPosition(x, y, z));
}
}
}));
allow.set(false);
}
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager)
{
int i = regionlimitedworldaccess.a();
int j = regionlimitedworldaccess.b();
int k = i * 16;
int l = j * 16;
if(gen.shouldGenerateStructures())
{
BlockPosition blockposition = new BlockPosition(k, 0, l);
BiomeBase biomebase = getStructureBiome(k, l);
SeededRandom seededrandom = new SeededRandom();
long i1 = seededrandom.a(regionlimitedworldaccess.getSeed(), k, l);
try
{
a(biomebase, structuremanager, this, regionlimitedworldaccess, i1, seededrandom, blockposition);
}
catch(Exception exception)
{
}
}
Runnable r = posts.remove(Cache.key(i, j));
if(r != null)
{
r.run();
}
}
private BiomeBase getStructureBiome(int k, int l) {
return (BiomeBase) INMS.get().getBiomeBase(ws.get().getWorld(), gen.getComposite().getDefaultEngine().getSurfaceBiome(k, l).getVanillaDerivative());
}
public void a(BiomeBase bbase, StructureManager var0, ChunkGenerator var1, RegionLimitedWorldAccess var2, long var3, SeededRandom var5, BlockPosition var6)
{
int stages = WorldGenStage.Decoration.values().length;
for(int stage = 0; stage < stages; ++stage)
{
WorldGenStage.Decoration st = WorldGenStage.Decoration.values()[stage];
if(st.equals(WorldGenStage.Decoration.LAKES))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.LOCAL_MODIFICATIONS))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.RAW_GENERATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.TOP_LAYER_MODIFICATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_DECORATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_ORES))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.VEGETAL_DECORATION))
{
continue;
}
StructureGenerator<?> var13;
int var10 = 0;
if(var0.a())
{
@SuppressWarnings("unchecked")
List<StructureGenerator<?>> structureGenerators = ((Map<Integer, List<StructureGenerator<?>>>) new V(bbase).get("g")).getOrDefault(stage, Collections.emptyList());
Iterator<StructureGenerator<?>> iterator = structureGenerators.iterator();
while(iterator.hasNext())
{
var13 = (StructureGenerator<?>) iterator.next();
var5.b(var3, var10, stage);
int var14 = var6.getX() >> 4;
int var15 = var6.getZ() >> 4;
int var16 = var14 << 4;
int var17 = var15 << 4;
try
{
var0.a(SectionPosition.a((BlockPosition) var6), var13).forEach(var8 -> var8.a((GeneratorAccessSeed) var2, var0, var1, (Random) var5, new StructureBoundingBox(var16, var17, var16 + 15, var17 + 15), new ChunkCoordIntPair(var14, var15)));
}
catch(Exception var18)
{
}
++var10;
}
}
}
}
@Override
public int getSeaLevel()
{
try
{
return gen.getComposite().getDefaultEngine().getMinHeight() + gen.getComposite().getDefaultEngine().getDimension().getFluidHeight();
}
catch(Throwable e)
{
return 0;
}
}
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i)
{
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
BiomeBase biomebase = this.b.getBiome((chunkcoordintpair.x * 16) + 2, 0, (chunkcoordintpair.z * 16) + 2);
this.a(StructureFeatures.k, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
for(Supplier<StructureFeature<?, ?>> supplier : biomebase.e().a())
{
StructureFeature<?, ?> structurefeature = (StructureFeature<?, ?>) supplier.get();
if(StructureFeature.c == StructureGenerator.STRONGHOLD)
{
StructureFeature<?, ?> structureFeature = structurefeature;
synchronized(structureFeature)
{
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
continue;
}
}
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
}
}
private void a(StructureFeature<?, ?> structurefeature, IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i, ChunkCoordIntPair chunkcoordintpair, BiomeBase biomebase)
{
StructureStart<?> structurestart = structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, (IStructureAccess) ichunkaccess);
int j = structurestart != null ? structurestart.j() : 0;
StructureSettingsFeature structuresettingsfeature = getSettings().a(structurefeature.d);
if(structuresettingsfeature != null)
{
StructureStart<?> structurestart1 = structurefeature.a(iregistrycustom, this, this.b, definedstructuremanager, i, chunkcoordintpair, biomebase, j, structuresettingsfeature);
structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, structurestart1, (IStructureAccess) ichunkaccess);
}
}
public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess)
{
int i = ichunkaccess.getPos().x;
int j = ichunkaccess.getPos().z;
int k = i << 4;
int l = j << 4;
SectionPosition sectionposition = SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0);
int i1 = i - 8;
while(i1 <= i + 8)
{
int j1 = j - 8;
while(j1 <= j + 8)
{
long k1 = ChunkCoordIntPair.pair((int) i1, (int) j1);
for(StructureStart<?> structurestart : generatoraccessseed.getChunkAt(i1, j1).h().values())
{
try
{
if(structurestart == StructureStart.a || !structurestart.c().a(k, l, k + 15, l + 15))
continue;
structuremanager.a(sectionposition, structurestart.l(), k1, (IStructureAccess) ichunkaccess);
PacketDebug.a((GeneratorAccessSeed) generatoraccessseed, (StructureStart<?>) structurestart);
}
catch(Exception exception)
{
CrashReport crashreport = CrashReport.a((Throwable) exception, (String) "Generating structure reference");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Structure");
crashreportsystemdetails.a("Name", () -> structurestart.l().i());
crashreportsystemdetails.a("Class", () -> structurestart.l().getClass().getCanonicalName());
throw new ReportedException(crashreport);
}
}
++j1;
}
++i1;
}
}
@Override
public IrisAccess getAccess() {
return gen;
}
}

View File

@ -1,258 +0,0 @@
package com.volmit.iris.nms.v16_2;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.Lifecycle;
import com.volmit.iris.nms.INMSCreator;
import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.util.O;
import com.volmit.iris.util.V;
import net.minecraft.server.v1_16_R2.*;
import net.minecraft.server.v1_16_R2.IRegistryCustom.Dimension;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
import org.bukkit.event.Event;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
class NMSCreator16_2 implements INMSCreator
{
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
public World createWorld(WorldCreator creator, boolean loadSpawn)
{
EngineCompositeGenerator pro = (EngineCompositeGenerator) creator.generator();
CraftServer server = ((CraftServer) Bukkit.getServer());
Map<String, World> worlds = new V(server).get("worlds");
DedicatedServer console = new V(server).get("console");
Preconditions.checkState(!console.worldServer.isEmpty(), (Object) "Cannot create additional worlds on STARTUP");
Validate.notNull((Object) creator, "Creator may not be null");
final String name = creator.name();
org.bukkit.generator.ChunkGenerator generator = creator.generator();
final File folder = new File(server.getWorldContainer(), name);
final World world = server.getWorld(name);
if(world != null)
{
return world;
}
if(folder.exists() && !folder.isDirectory())
{
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
}
if(generator == null)
{
generator = server.getGenerator(name);
}
ResourceKey<WorldDimension> actualDimension = null;
switch(creator.environment())
{
case NORMAL:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.OVERWORLD;
break;
}
case NETHER:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_NETHER;
break;
}
case THE_END:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_END;
break;
}
default:
{
throw new IllegalArgumentException("Illegal dimension");
}
}
Convertable.ConversionSession worldSession;
try
{
worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, (ResourceKey) actualDimension);
}
catch(IOException ex)
{
throw new RuntimeException(ex);
}
MinecraftServer.convertWorld(worldSession);
final boolean hardcore = creator.hardcore();
final RegistryReadOps<NBTBase> registryreadops = (RegistryReadOps<NBTBase>) RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), getConsoleDimension(console));
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
if(worlddata == null)
{
final Properties properties = new Properties();
properties.put("generator-settings", Objects.toString(creator.generatorSettings()));
properties.put("level-seed", Objects.toString(creator.seed()));
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
properties.put("level-type", Objects.toString(creator.type().getName()));
final GeneratorSettings generatorsettings = GeneratorSettings.a(getConsoleDimension(console), properties);
@SuppressWarnings("deprecation")
final WorldSettings worldSettings = new WorldSettings(name, EnumGamemode.getById(server.getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
}
worlddata.checkName(name);
worlddata.a(console.getServerModName(), console.getModded().isPresent());
if(console.options.has("forceUpgrade"))
{
net.minecraft.server.v1_16_R2.Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> true, (ImmutableSet) worlddata.getGeneratorSettings().d().d().stream().map(entry -> ResourceKey.a(IRegistry.K, entry.getKey().a())).collect(ImmutableSet.toImmutableSet()));
}
final long j = BiomeManager.a(creator.seed());
final List<MobSpawner> list = (List<MobSpawner>) ImmutableList.of((MobSpawner) new MobSpawnerPhantom(), (MobSpawner) new MobSpawnerPatrol(), (MobSpawner) new MobSpawnerCat(), (MobSpawner) new VillageSiege(), (MobSpawner) new MobSpawnerTrader((IWorldDataServer) worlddata));
DimensionManager dimensionmanager;
net.minecraft.server.v1_16_R2.ChunkGenerator chunkgenerator;
long ll = creator.seed();
dimensionmanager = (DimensionManager) getConsoleDimension(console).a().d(DimensionManager.OVERWORLD);
O<WorldServer> ws = new O<WorldServer>();
chunkgenerator = new NMSChunkGenerator_16_2(ws, creator, (WorldChunkManager) new NMSWorldChunkManager16_2(((EngineCompositeGenerator)creator.generator()), creator.name(), ll, false, false, (IRegistry<BiomeBase>) getConsoleDimension(console).b(IRegistry.ay)), ll, () -> (GeneratorSettingBase) getConsoleDimension(console).b(IRegistry.ar).d(GeneratorSettingBase.c));
final ResourceKey<net.minecraft.server.v1_16_R2.World> worldKey = (ResourceKey<net.minecraft.server.v1_16_R2.World>) ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(Locale.ENGLISH)));
//@builder
final WorldServer internal = new WorldServer((MinecraftServer) console,
console.executorService, worldSession,
(IWorldDataServer) worlddata,
(ResourceKey) worldKey,
dimensionmanager,
server.getServer().worldLoadListenerFactory.create(11),
chunkgenerator,
worlddata.getGeneratorSettings().isDebugWorld(),
j,
(List) ((creator.environment() == World.Environment.NORMAL) ? list : ImmutableList.of()),
true,
creator.environment(),
server.getGenerator(name));
//@done
IrisWorlds.register(internal.getWorld(), pro);
ws.set(internal);
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
{
try
{
internal.close();
}
catch(IOException e)
{
e.printStackTrace();
}
return null;
}
console.initWorld(internal, (IWorldDataServer) worlddata, (SaveData) worlddata, worlddata.getGeneratorSettings());
internal.setSpawnFlags(true, true);
console.worldServer.put(internal.getDimensionKey(), internal);
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
if(loadSpawn)
{
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
}
else
{
MinecraftServer.LOGGER.info("Preparing start region for dimens... Oh wait, We don't do that here anymore.");
}
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
return (World) internal.getWorld();
}
private Dimension getConsoleDimension(DedicatedServer console)
{
Dimension dim = null;
try
{
dim = new V((MinecraftServer) console, true).get("customRegistry");
if(dim != null)
{
return dim;
}
}
catch(Throwable e)
{
}
try
{
dim = new V((MinecraftServer) console, true).get("f");
if(dim != null)
{
return dim;
}
}
catch(Throwable e)
{
}
for(Field i : MinecraftServer.class.getDeclaredFields())
{
if(i.getType().equals(dim.getClass()))
{
i.setAccessible(true);
if(Modifier.isStatic(i.getModifiers()))
{
try
{
return (Dimension) i.get(null);
}
catch(Throwable e)
{
}
}
else
{
try
{
return (Dimension) i.get((MinecraftServer) console);
}
catch(Throwable e)
{
}
}
}
}
if(dim == null)
{
try
{
throw new RuntimeException("Cannot find dimension field!");
}
catch(Throwable e)
{
e.printStackTrace();
}
}
return dim;
}
}

View File

@ -1,57 +0,0 @@
package com.volmit.iris.nms.v16_2;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.volmit.iris.nms.INMS;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import net.minecraft.server.v1_16_R2.*;
import org.bukkit.block.Biome;
public class NMSWorldChunkManager16_2 extends WorldChunkManager {
public static final Codec<NMSWorldChunkManager16_2> e = RecordCodecBuilder.create((var0) -> {
return var0.group(Codec.LONG.fieldOf("seed").stable().forGetter((var0x) -> {
return var0x.h;
}), Codec.BOOL.optionalFieldOf("legacy_biome_init_layer", false, Lifecycle.stable()).forGetter((var0x) -> {
return var0x.i;
}), Codec.BOOL.fieldOf("large_biomes").orElse(false).stable().forGetter((var0x) -> {
return var0x.j;
}), RegistryLookupCodec.a(IRegistry.ay).forGetter((var0x) -> {
return var0x.k;
})).apply(var0, var0.stable((a,b,c,d) -> new NMSWorldChunkManager16_2(null, "", a, b, c, d)));
});
private final long h;
private final boolean i;
private final boolean j;
private final EngineCompositeGenerator compound;
private final IRegistry<BiomeBase> k;
public NMSWorldChunkManager16_2(EngineCompositeGenerator compound, String wn, long var0, boolean var2, boolean var3, IRegistry<BiomeBase> var4) {
super(compound.getAllBiomes(wn).convert((v)-> v.getDerivative().getKey().getKey()).stream().map((var1) -> {
return () -> {
return (BiomeBase)var4.d(ResourceKey.a(IRegistry.ay, new MinecraftKey(var1)));
};
}));
this.compound = compound;
this.h = var0;
this.i = var2;
this.j = var3;
this.k = var4;
}
protected Codec<? extends WorldChunkManager> a() {
return e;
}
public BiomeBase getBiome(int var0, int var1, int var2) {
try
{
return (BiomeBase) INMS.get().getBiomeBase(k, compound.getComposite().getDefaultEngine().getSurfaceBiome(var0, var2).getVanillaDerivative());
}
catch(Throwable e)
{
return (BiomeBase) INMS.get().getBiomeBase(k, Biome.THE_VOID);
}
}
}

View File

@ -1,598 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.volmit.iris.nms.v16_3;
import com.mojang.serialization.Codec;
import com.volmit.iris.nms.INMS;
import com.volmit.iris.scaffold.cache.Cache;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.scaffold.engine.IrisAccess;
import com.volmit.iris.scaffold.engine.IrisAccessProvider;
import com.volmit.iris.util.*;
import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.HeightMap;
import net.minecraft.server.v1_16_R3.*;
import org.bukkit.WorldCreator;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_16_R3.util.CraftMagicNumbers;
import org.bukkit.material.MaterialData;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
public final class NMSChunkGenerator16_3 extends ChunkGenerator implements IrisAccessProvider {
private static final IBlockData k;
private final O<WorldServer> ws;
protected final IBlockData f;
protected final IBlockData g;
private final long w;
private final int maxHeight;
private final int xzSize;
protected final Supplier<GeneratorSettingBase> h;
private WorldCreator wc;
private EngineCompositeGenerator gen;
private BlockColumn BC;
private KMap<Long, Runnable> posts = new KMap<>();
static {
k = Blocks.AIR.getBlockData();
}
public NMSChunkGenerator16_3(O<WorldServer> ws, WorldCreator wc, WorldChunkManager worldchunkmanager, long i, Supplier<GeneratorSettingBase> supplier) {
this(ws, wc, worldchunkmanager, worldchunkmanager, i, supplier);
}
private NMSChunkGenerator16_3(O<WorldServer> ws, WorldCreator wc, WorldChunkManager worldchunkmanager, WorldChunkManager worldchunkmanager1, long i, Supplier<GeneratorSettingBase> supplier) {
super(worldchunkmanager, worldchunkmanager1, ((GeneratorSettingBase)supplier.get()).a(), i);
this.wc = wc;
this.ws = ws;
this.gen = (EngineCompositeGenerator) wc.generator();
this.w = i;
GeneratorSettingBase generatorsettingbase = supplier.get();
this.h = supplier;
NoiseSettings noisesettings = generatorsettingbase.b();
this.f = generatorsettingbase.c();
this.g = generatorsettingbase.d();
this.maxHeight = noisesettings.f() * 4;
this.xzSize = noisesettings.a() / this.maxHeight;
BC = new BlockColumn(new IBlockData[this.xzSize * this.maxHeight]);
}
public int getSpawnHeight()
{
return getSeaLevel() + 8;
}
public WorldChunkManager getWorldChunkManager()
{
return this.c;
}
public int getGenerationDepth()
{
return 256;
}
public void doCarving(long i, BiomeManager biomemanager, IChunkAccess ichunkaccess, WorldGenStage.Features worldgenstage_features)
{
if(gen.isVanillaCaves())
{
super.doCarving(i, biomemanager, ichunkaccess, worldgenstage_features);
}
}
@Override
protected Codec<? extends ChunkGenerator> a()
{
return ChunkGeneratorAbstract.d;
}
public boolean a(long i, ResourceKey<GeneratorSettingBase> resourcekey)
{
return this.w == i && this.h.get().a(resourcekey);
}
@Override
public int getBaseHeight(int i, int j, HeightMap.Type heightmap_type)
{
try
{
return 1+gen.getComposite().getDefaultEngine().getMinHeight() + Math.max(gen.getComposite().getDefaultEngine().getHeight(i, j), gen.getComposite().getDefaultEngine().getDimension().getFluidHeight());
}
catch(Throwable e)
{
return 0;
}
}
@Override
public IBlockAccess a(int x, int z)
{
return BC;
}
protected IBlockData a(double d0, int i)
{
IBlockData iblockdata;
if(d0 > 0.0D)
{
iblockdata = this.f;
}
else if(i < this.getSeaLevel())
{
iblockdata = this.g;
}
else
{
iblockdata = k;
}
return iblockdata;
}
@Override
public void buildBase(RegionLimitedWorldAccess regionlimitedworldaccess, IChunkAccess ichunkaccess)
{
}
@Override
public void buildNoise(GeneratorAccess generatoraccess, StructureManager structuremanager, IChunkAccess ichunkaccess)
{
KList<StructurePiece> objectlist = new KList<StructurePiece>(10);
KList<WorldGenFeatureDefinedStructureJigsawJunction> objectlist1 = new KList<WorldGenFeatureDefinedStructureJigsawJunction>(32);
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
int i = chunkcoordintpair.x;
int j = chunkcoordintpair.z;
int k = i << 4;
int l = j << 4;
if(gen.shouldGenerateStructures())
{
Iterator<?> iterator = StructureGenerator.t.iterator();
while(iterator.hasNext())
{
StructureGenerator<?> structuregenerator = (StructureGenerator<?>) iterator.next();
structuremanager.a(SectionPosition.a(chunkcoordintpair, 0), structuregenerator).forEach((structurestart) ->
{
Iterator<?> iterator1 = structurestart.d().iterator();
while(iterator1.hasNext())
{
StructurePiece structurepiece = (StructurePiece) iterator1.next();
if(structurepiece.a(chunkcoordintpair, 12))
{
if(structurepiece instanceof WorldGenFeaturePillagerOutpostPoolPiece)
{
WorldGenFeaturePillagerOutpostPoolPiece worldgenfeaturepillageroutpostpoolpiece = (WorldGenFeaturePillagerOutpostPoolPiece) structurepiece;
WorldGenFeatureDefinedStructurePoolTemplate.Matching worldgenfeaturedefinedstructurepooltemplate_matching = worldgenfeaturepillageroutpostpoolpiece.b().e();
if(worldgenfeaturedefinedstructurepooltemplate_matching == WorldGenFeatureDefinedStructurePoolTemplate.Matching.RIGID)
{
objectlist.add(worldgenfeaturepillageroutpostpoolpiece);
}
Iterator<?> iterator2 = worldgenfeaturepillageroutpostpoolpiece.e().iterator();
while(iterator2.hasNext())
{
WorldGenFeatureDefinedStructureJigsawJunction worldgenfeaturedefinedstructurejigsawjunction = (WorldGenFeatureDefinedStructureJigsawJunction) iterator2.next();
int i1 = worldgenfeaturedefinedstructurejigsawjunction.a();
int j1 = worldgenfeaturedefinedstructurejigsawjunction.c();
if(i1 > k - 12 && j1 > l - 12 && i1 < k + 15 + 12 && j1 < l + 15 + 12)
{
objectlist1.add(worldgenfeaturedefinedstructurejigsawjunction);
}
}
}
else
{
objectlist.add(structurepiece);
}
}
}
});
}
}
ProtoChunk protochunk = (ProtoChunk) ichunkaccess;
HeightMap heightmap = protochunk.a(HeightMap.Type.OCEAN_FLOOR_WG);
HeightMap heightmap1 = protochunk.a(HeightMap.Type.WORLD_SURFACE_WG);
AtomicBoolean allow = new AtomicBoolean(true);
posts.put(Cache.key(i, j), gen.generateChunkRawData(ws.get().getWorld(), i, j, new TerrainChunk() {
@Override
public void setBiome(int x, int y, int z, Biome bio)
{
protochunk.getBiomeIndex().setBiome(x, y, z, (BiomeBase) INMS.get().getBiomeBase(ws.get().r().b(IRegistry.ay), bio));
}
@Override
public void setBiome(int x, int z, Biome bio)
{
protochunk.getBiomeIndex().setBiome(x, 0, z, (BiomeBase) INMS.get().getBiomeBase(ws.get().r().b(IRegistry.ay), bio));
}
@Override
public Biome getBiome(int x, int y, int z)
{
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x&15, y, z&15));
}
@Override
public void setRaw(org.bukkit.generator.ChunkGenerator.ChunkData data) {
}
@Override
public Biome getBiome(int x, int z)
{
return CraftBlock.biomeBaseToBiome(ws.get().r().b(IRegistry.ay), protochunk.getBiomeIndex().getBiome(x, 0, z));
}
public int getMaxHeight()
{
return 256;
}
public void setBlock(int x, int y, int z, org.bukkit.Material material)
{
this.setBlock(x, y, z, material.createBlockData());
}
public void setBlock(int x, int y, int z, MaterialData material)
{
this.setBlock(x, y, z, CraftMagicNumbers.getBlock((MaterialData) material));
}
public void setBlock(int x, int y, int z, BlockData blockData)
{
if(allow.get())
{
heightmap.a(x,y,z,((CraftBlockData) blockData).getState());
heightmap1.a(x,y,z,((CraftBlockData) blockData).getState());
}
this.setBlock(x, y, z, ((CraftBlockData) blockData).getState());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, org.bukkit.Material material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.createBlockData());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock((MaterialData) material));
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState());
}
public org.bukkit.Material getType(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial((Block) this.getTypeId(x, y, z).getBlock());
}
public MaterialData getTypeAndData(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial((IBlockData) this.getTypeId(x, y, z));
}
public BlockData getBlockData(int x, int y, int z)
{
return CraftBlockData.fromData((IBlockData) this.getTypeId(x, y, z));
}
@Override
public org.bukkit.generator.ChunkGenerator.ChunkData getRaw() {
return null;
}
@Override
public void inject(org.bukkit.generator.ChunkGenerator.BiomeGrid biome) {
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type)
{
if(xMin > 15 || yMin >= getMaxHeight() || zMin > 15)
{
return;
}
if(xMin < 0)
{
xMin = 0;
}
if(yMin < 0)
{
yMin = 0;
}
if(zMin < 0)
{
zMin = 0;
}
if(xMax > 16)
{
xMax = 16;
}
if(yMax > getMaxHeight())
{
yMax = getMaxHeight();
}
if(zMax > 16)
{
zMax = 16;
}
if(xMin >= xMax || yMin >= yMax || zMin >= zMax)
{
return;
}
int y = yMin;
while(y < yMax)
{
int x = xMin;
while(x < xMax)
{
int z = zMin;
while(z < zMax)
{
protochunk.setType(new BlockPosition(x, y, z), type, false);
++z;
}
++x;
}
++y;
}
}
public IBlockData getTypeId(int x, int y, int z)
{
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
{
return Blocks.AIR.getBlockData();
}
return protochunk.getType(new BlockPosition(x, y, z));
}
public byte getData(int x, int y, int z)
{
return CraftMagicNumbers.toLegacyData((IBlockData) this.getTypeId(x, y, z));
}
private void setBlock(int x, int y, int z, IBlockData type)
{
if(x != (x & 15) || y < 0 || y >= getMaxHeight() || z != (z & 15))
{
return;
}
protochunk.setType(new BlockPosition(x, y, z), type, false);
if(type.getBlock().isTileEntity())
{
// if (this.tiles == null) {
// this.tiles = new HashSet<BlockPosition>();
// }
// this.tiles.add(new BlockPosition(x, y, z));
}
}
}));
allow.set(false);
}
public void addDecorations(RegionLimitedWorldAccess regionlimitedworldaccess, StructureManager structuremanager)
{
int i = regionlimitedworldaccess.a();
int j = regionlimitedworldaccess.b();
int k = i * 16;
int l = j * 16;
if(gen.shouldGenerateStructures())
{
BlockPosition blockposition = new BlockPosition(k, 0, l);
BiomeBase biomebase = getStructureBiome(k, l);
SeededRandom seededrandom = new SeededRandom();
long i1 = seededrandom.a(regionlimitedworldaccess.getSeed(), k, l);
try
{
a(biomebase, structuremanager, this, regionlimitedworldaccess, i1, seededrandom, blockposition);
}
catch(Exception exception)
{
}
}
Runnable r = posts.remove(Cache.key(i, j));
if(r != null)
{
r.run();
}
}
private BiomeBase getStructureBiome(int k, int l) {
return (BiomeBase) INMS.get().getBiomeBase(ws.get().getWorld(), gen.getComposite().getDefaultEngine().getSurfaceBiome(k, l).getVanillaDerivative());
}
public void a(BiomeBase bbase, StructureManager var0, ChunkGenerator var1, RegionLimitedWorldAccess var2, long var3, SeededRandom var5, BlockPosition var6)
{
int stages = WorldGenStage.Decoration.values().length;
for(int stage = 0; stage < stages; ++stage)
{
WorldGenStage.Decoration st = WorldGenStage.Decoration.values()[stage];
if(st.equals(WorldGenStage.Decoration.LAKES))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.LOCAL_MODIFICATIONS))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.RAW_GENERATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.TOP_LAYER_MODIFICATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_DECORATION))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.UNDERGROUND_ORES))
{
continue;
}
if(st.equals(WorldGenStage.Decoration.VEGETAL_DECORATION))
{
continue;
}
StructureGenerator<?> var13;
int var10 = 0;
if(var0.a())
{
@SuppressWarnings("unchecked")
List<StructureGenerator<?>> structureGenerators = ((Map<Integer, List<StructureGenerator<?>>>) new V(bbase).get("g")).getOrDefault(stage, Collections.emptyList());
Iterator<StructureGenerator<?>> iterator = structureGenerators.iterator();
while(iterator.hasNext())
{
var13 = (StructureGenerator<?>) iterator.next();
var5.b(var3, var10, stage);
int var14 = var6.getX() >> 4;
int var15 = var6.getZ() >> 4;
int var16 = var14 << 4;
int var17 = var15 << 4;
try
{
var0.a(SectionPosition.a((BlockPosition) var6), var13).forEach(var8 -> var8.a((GeneratorAccessSeed) var2, var0, var1, (Random) var5, new StructureBoundingBox(var16, var17, var16 + 15, var17 + 15), new ChunkCoordIntPair(var14, var15)));
}
catch(Exception var18)
{
}
++var10;
}
}
}
}
@Override
public int getSeaLevel()
{
try
{
return gen.getComposite().getDefaultEngine().getMinHeight() + gen.getComposite().getDefaultEngine().getDimension().getFluidHeight();
}
catch(Throwable e)
{
return 0;
}
}
public void createStructures(IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i)
{
ChunkCoordIntPair chunkcoordintpair = ichunkaccess.getPos();
BiomeBase biomebase = this.b.getBiome((chunkcoordintpair.x * 16) + 2, 0, (chunkcoordintpair.z * 16) + 2);
this.a(StructureFeatures.k, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
for(Supplier<StructureFeature<?, ?>> supplier : biomebase.e().a())
{
StructureFeature<?, ?> structurefeature = (StructureFeature<?, ?>) supplier.get();
if(StructureFeature.c == StructureGenerator.STRONGHOLD)
{
StructureFeature<?, ?> structureFeature = structurefeature;
synchronized(structureFeature)
{
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
continue;
}
}
this.a(structurefeature, iregistrycustom, structuremanager, ichunkaccess, definedstructuremanager, i, chunkcoordintpair, biomebase);
}
}
private void a(StructureFeature<?, ?> structurefeature, IRegistryCustom iregistrycustom, StructureManager structuremanager, IChunkAccess ichunkaccess, DefinedStructureManager definedstructuremanager, long i, ChunkCoordIntPair chunkcoordintpair, BiomeBase biomebase)
{
StructureStart<?> structurestart = structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, (IStructureAccess) ichunkaccess);
int j = structurestart != null ? structurestart.j() : 0;
StructureSettingsFeature structuresettingsfeature = getSettings().a(structurefeature.d);
if(structuresettingsfeature != null)
{
StructureStart<?> structurestart1 = structurefeature.a(iregistrycustom, this, this.b, definedstructuremanager, i, chunkcoordintpair, biomebase, j, structuresettingsfeature);
structuremanager.a(SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0), structurefeature.d, structurestart1, (IStructureAccess) ichunkaccess);
}
}
public void storeStructures(GeneratorAccessSeed generatoraccessseed, StructureManager structuremanager, IChunkAccess ichunkaccess)
{
int i = ichunkaccess.getPos().x;
int j = ichunkaccess.getPos().z;
int k = i << 4;
int l = j << 4;
SectionPosition sectionposition = SectionPosition.a((ChunkCoordIntPair) ichunkaccess.getPos(), (int) 0);
int i1 = i - 8;
while(i1 <= i + 8)
{
int j1 = j - 8;
while(j1 <= j + 8)
{
long k1 = ChunkCoordIntPair.pair((int) i1, (int) j1);
for(StructureStart<?> structurestart : generatoraccessseed.getChunkAt(i1, j1).h().values())
{
try
{
if(structurestart == StructureStart.a || !structurestart.c().a(k, l, k + 15, l + 15))
continue;
structuremanager.a(sectionposition, structurestart.l(), k1, (IStructureAccess) ichunkaccess);
PacketDebug.a((GeneratorAccessSeed) generatoraccessseed, (StructureStart<?>) structurestart);
}
catch(Exception exception)
{
CrashReport crashreport = CrashReport.a((Throwable) exception, (String) "Generating structure reference");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Structure");
crashreportsystemdetails.a("Name", () -> structurestart.l().i());
crashreportsystemdetails.a("Class", () -> structurestart.l().getClass().getCanonicalName());
throw new ReportedException(crashreport);
}
}
++j1;
}
++i1;
}
}
@Override
public IrisAccess getAccess() {
return gen;
}
}

View File

@ -1,261 +0,0 @@
package com.volmit.iris.nms.v16_3;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.mojang.serialization.DynamicOps;
import com.mojang.serialization.Lifecycle;
import com.volmit.iris.nms.INMSCreator;
import com.volmit.iris.scaffold.IrisWorlds;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import com.volmit.iris.util.O;
import com.volmit.iris.util.V;
import net.minecraft.server.v1_16_R3.*;
import net.minecraft.server.v1_16_R3.IRegistryCustom.Dimension;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
import org.bukkit.event.Event;
import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
class NMSCreator16_3 implements INMSCreator
{
@SuppressWarnings({"unchecked", "rawtypes", "resource"})
public World createWorld(WorldCreator creator, boolean loadSpawn)
{
EngineCompositeGenerator pro = (EngineCompositeGenerator) creator.generator();
CraftServer server = ((CraftServer) Bukkit.getServer());
Map<String, World> worlds = new V(server).get("worlds");
DedicatedServer console = new V(server).get("console");
Preconditions.checkState(!console.worldServer.isEmpty(), (Object) "Cannot create additional worlds on STARTUP");
Validate.notNull((Object) creator, "Creator may not be null");
final String name = creator.name();
org.bukkit.generator.ChunkGenerator generator = creator.generator();
final File folder = new File(server.getWorldContainer(), name);
final World world = server.getWorld(name);
if(world != null)
{
return world;
}
if(folder.exists() && !folder.isDirectory())
{
throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
}
if(generator == null)
{
generator = server.getGenerator(name);
}
ResourceKey<WorldDimension> actualDimension = null;
switch(creator.environment())
{
case NORMAL:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.OVERWORLD;
break;
}
case NETHER:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_NETHER;
break;
}
case THE_END:
{
actualDimension = (ResourceKey<WorldDimension>) WorldDimension.THE_END;
break;
}
default:
{
throw new IllegalArgumentException("Illegal dimension");
}
}
Convertable.ConversionSession worldSession;
try
{
worldSession = Convertable.a(server.getWorldContainer().toPath()).c(name, (ResourceKey) actualDimension);
}
catch(IOException ex)
{
throw new RuntimeException(ex);
}
MinecraftServer.convertWorld(worldSession);
final boolean hardcore = creator.hardcore();
final RegistryReadOps<NBTBase> registryreadops = (RegistryReadOps<NBTBase>) RegistryReadOps.a((DynamicOps) DynamicOpsNBT.a, console.dataPackResources.h(), getConsoleDimension(console));
WorldDataServer worlddata = (WorldDataServer) worldSession.a((DynamicOps) registryreadops, console.datapackconfiguration);
if(worlddata == null)
{
final Properties properties = new Properties();
properties.put("generator-settings", Objects.toString(creator.generatorSettings()));
properties.put("level-seed", Objects.toString(creator.seed()));
properties.put("generate-structures", Objects.toString(creator.generateStructures()));
properties.put("level-type", Objects.toString(creator.type().getName()));
final GeneratorSettings generatorsettings = GeneratorSettings.a(getConsoleDimension(console), properties);
@SuppressWarnings("deprecation")
final WorldSettings worldSettings = new WorldSettings(name, EnumGamemode.getById(server.getDefaultGameMode().getValue()), hardcore, EnumDifficulty.EASY, false, new GameRules(), console.datapackconfiguration);
worlddata = new WorldDataServer(worldSettings, generatorsettings, Lifecycle.stable());
}
worlddata.checkName(name);
worlddata.a(console.getServerModName(), console.getModded().isPresent());
if(console.options.has("forceUpgrade"))
{
Main.convertWorld(worldSession, DataConverterRegistry.a(), console.options.has("eraseCache"), () -> true, (ImmutableSet) worlddata.getGeneratorSettings().d().d().stream().map(entry -> ResourceKey.a(IRegistry.K, entry.getKey().a())).collect(ImmutableSet.toImmutableSet()));
}
final long j = BiomeManager.a(creator.seed());
final List<MobSpawner> list = (List<MobSpawner>) ImmutableList.of((MobSpawner) new MobSpawnerPhantom(), (MobSpawner) new MobSpawnerPatrol(), (MobSpawner) new MobSpawnerCat(), (MobSpawner) new VillageSiege(), (MobSpawner) new MobSpawnerTrader((IWorldDataServer) worlddata));
DimensionManager dimensionmanager;
ChunkGenerator chunkgenerator;
long ll = creator.seed();
dimensionmanager = (DimensionManager) getConsoleDimension(console).a().d(DimensionManager.OVERWORLD);
O<WorldServer> ws = new O<WorldServer>();
chunkgenerator = new NMSChunkGenerator16_3(ws, creator, (WorldChunkManager)
new NMSWorldChunkManager16_3(((EngineCompositeGenerator)creator.generator()), creator.name(), ll, false, false, (IRegistry<BiomeBase>) getConsoleDimension(console).b(IRegistry.ay)), ll,
() -> (GeneratorSettingBase) getConsoleDimension(console).b(IRegistry.ar).d(GeneratorSettingBase.c));
final ResourceKey<net.minecraft.server.v1_16_R3.World> worldKey = (ResourceKey<net.minecraft.server.v1_16_R3.World>) ResourceKey.a(IRegistry.L, new MinecraftKey(name.toLowerCase(Locale.ENGLISH)));
//@builder
final WorldServer internal = new WorldServer((MinecraftServer) console,
console.executorService, worldSession,
(IWorldDataServer) worlddata,
(ResourceKey) worldKey,
dimensionmanager,
server.getServer().worldLoadListenerFactory.create(11),
chunkgenerator,
worlddata.getGeneratorSettings().isDebugWorld(),
j,
(List) ((creator.environment() == Environment.NORMAL) ? list : ImmutableList.of()),
true,
creator.environment(),
server.getGenerator(name));
//@done
IrisWorlds.register(internal.getWorld(), pro);
ws.set(internal);
if(!worlds.containsKey(name.toLowerCase(Locale.ENGLISH)))
{
try
{
internal.close();
}
catch(IOException e)
{
e.printStackTrace();
}
return null;
}
console.initWorld(internal, (IWorldDataServer) worlddata, (SaveData) worlddata, worlddata.getGeneratorSettings());
internal.setSpawnFlags(true, true);
console.worldServer.put(internal.getDimensionKey(), internal);
server.getPluginManager().callEvent((Event) new WorldInitEvent((World) internal.getWorld()));
if(loadSpawn)
{
server.getServer().loadSpawn(internal.getChunkProvider().playerChunkMap.worldLoadListener, internal);
}
else
{
MinecraftServer.LOGGER.info("Preparing start region for dimens... Oh wait, We don't do that here anymore.");
}
server.getPluginManager().callEvent((Event) new WorldLoadEvent((World) internal.getWorld()));
return (World) internal.getWorld();
}
private Dimension getConsoleDimension(DedicatedServer console)
{
Dimension dim = null;
try
{
dim = new V((MinecraftServer) console, true).get("customRegistry");
if(dim != null)
{
return dim;
}
}
catch(Throwable e)
{
}
try
{
dim = new V((MinecraftServer) console, true).get("f");
if(dim != null)
{
return dim;
}
}
catch(Throwable e)
{
}
for(Field i : MinecraftServer.class.getDeclaredFields())
{
if(i.getType().equals(dim.getClass()))
{
i.setAccessible(true);
if(Modifier.isStatic(i.getModifiers()))
{
try
{
return (Dimension) i.get(null);
}
catch(Throwable e)
{
}
}
else
{
try
{
return (Dimension) i.get((MinecraftServer) console);
}
catch(Throwable e)
{
}
}
}
}
if(dim == null)
{
try
{
throw new RuntimeException("Cannot find dimension field!");
}
catch(Throwable e)
{
e.printStackTrace();
}
}
return dim;
}
}

View File

@ -1,57 +0,0 @@
package com.volmit.iris.nms.v16_3;
import com.mojang.serialization.Codec;
import com.mojang.serialization.Lifecycle;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.volmit.iris.nms.INMS;
import com.volmit.iris.scaffold.engine.EngineCompositeGenerator;
import net.minecraft.server.v1_16_R3.*;
import org.bukkit.block.Biome;
public class NMSWorldChunkManager16_3 extends WorldChunkManager {
public static final Codec<NMSWorldChunkManager16_3> e = RecordCodecBuilder.create((var0) -> {
return var0.group(Codec.LONG.fieldOf("seed").stable().forGetter((var0x) -> {
return var0x.h;
}), Codec.BOOL.optionalFieldOf("legacy_biome_init_layer", false, Lifecycle.stable()).forGetter((var0x) -> {
return var0x.i;
}), Codec.BOOL.fieldOf("large_biomes").orElse(false).stable().forGetter((var0x) -> {
return var0x.j;
}), RegistryLookupCodec.a(IRegistry.ay).forGetter((var0x) -> {
return var0x.k;
})).apply(var0, var0.stable((a,b,c,d) -> new NMSWorldChunkManager16_3(null, "", a, b, c, d)));
});
private final long h;
private final boolean i;
private final boolean j;
private final EngineCompositeGenerator compound;
private final IRegistry<BiomeBase> k;
public NMSWorldChunkManager16_3(EngineCompositeGenerator compound, String wn, long var0, boolean var2, boolean var3, IRegistry<BiomeBase> var4) {
super(compound.getAllBiomes(wn).convert((v)-> v.getDerivative().getKey().getKey()).stream().map((var1) -> {
return () -> {
return (BiomeBase)var4.d(ResourceKey.a(IRegistry.ay, new MinecraftKey(var1)));
};
}));
this.compound = compound;
this.h = var0;
this.i = var2;
this.j = var3;
this.k = var4;
}
protected Codec<? extends WorldChunkManager> a() {
return e;
}
public BiomeBase getBiome(int var0, int var1, int var2) {
try
{
return (BiomeBase) INMS.get().getBiomeBase(k, compound.getComposite().getDefaultEngine().getSurfaceBiome(var0, var2).getVanillaDerivative());
}
catch(Throwable e)
{
return (BiomeBase) INMS.get().getBiomeBase(k, Biome.THE_VOID);
}
}
}

View File

@ -1,14 +0,0 @@
package com.volmit.iris.nms.v1X;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import com.volmit.iris.nms.INMSCreator;
class NMSCreator1X implements INMSCreator
{
public World createWorld(WorldCreator creator, boolean loadSpawn)
{
return creator.createWorld();
}
}