make dimension registry server side

This commit is contained in:
Sen 2025-07-24 15:54:34 +02:00
parent b9d62c2253
commit 4de4f41a5d
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
98 changed files with 1008 additions and 608 deletions

View file

@ -45,7 +45,6 @@ import common.entity.npc.EntityHuman;
import common.entity.npc.EntityNPC;
import common.init.EntityRegistry;
import common.init.Registry;
import common.init.UniverseRegistry;
import common.log.Log;
import common.net.bootstrap.ServerBootstrap;
import common.net.channel.Channel;
@ -73,6 +72,7 @@ import common.packet.RPacketEnableCompression;
import common.packet.RPacketLoginSuccess;
import common.packet.SPacketEntityEffect;
import common.packet.SPacketChangeGameState;
import common.packet.SPacketDimensions;
import common.packet.SPacketPlayerListItem;
import common.packet.SPacketPlayerAbilities;
import common.packet.SPacketDisconnect;
@ -83,6 +83,7 @@ import common.packet.SPacketServerConfig;
import common.packet.SPacketSetExperience;
import common.packet.SPacketSkin;
import common.packet.SPacketTimeUpdate;
import common.rng.Random;
import common.tags.TagObject;
import common.util.BlockPos;
import common.util.EncryptUtil;
@ -100,7 +101,9 @@ import server.clipboard.ReorderRegistry;
import server.clipboard.RotationRegistry;
import server.command.CommandEnvironment;
import server.command.Executor;
import server.dimension.Dimensions;
import server.init.TeleportRegistry;
import server.init.UniverseRegistry;
import server.network.HandshakeHandler;
import server.network.Player;
import server.network.User;
@ -164,6 +167,7 @@ public final class Server implements IThreadListener, Executor {
if(Util.DEVMODE)
Log.SYSTEM.warn("Entwicklungsmodus aktiv - Debugging-Features sind verfügbar");
Registry.register();
UniverseRegistry.register();
TeleportRegistry.register();
RotationRegistry.register();
ReorderRegistry.register();
@ -421,12 +425,17 @@ public final class Server implements IThreadListener, Executor {
}
}
dim.readData(tag == null ? new TagObject() : tag);
if(tag == null || !tag.hasLong("Seed"))
if(tag == null || !tag.hasLong("Seed")) {
Random rand = new Random();
if(!Vars.seed.isEmpty())
rand.setSeed((long)Vars.seed.hashCode() ^ ~((long)UniverseRegistry.getName(dim).hashCode()));
dim.setSeed(rand.longv());
Log.TICK.info("Startwert für %s: %d" + (Vars.seed.isEmpty() ? "" : " von Basiswert '%s'"), dim.getDisplay(), dim.getSeed(), Vars.seed);
}
}
private void saveDimension(Dimension dim) {
TagObject tag = dim.writeData();
TagObject tag = dim.writeData(false);
File file = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "data.cdt");
try {
file.getParentFile().mkdirs();
@ -586,6 +595,7 @@ public final class Server implements IThreadListener, Executor {
for(Dimension dim : UniverseRegistry.getDimensions()) {
this.loadDimension(dim);
}
Dimensions.updateDimensions();
if(this.keyPair == null) {
Log.SYSTEM.info("Generiere neues Schlüsselpaar");
this.keyPair = EncryptUtil.createKeypair();
@ -711,7 +721,9 @@ public final class Server implements IThreadListener, Executor {
}
}
if(++this.syncTimer == 20) {
this.sendPacket(new SPacketTimeUpdate(this.space.getDayTime(), this.getInfo()));
for(Player conn : this.players) {
this.sendPacket(new SPacketTimeUpdate(this.space.getDayTime(), Dimensions.formatTime(conn.getPresentEntity() == null ? this.space : (WorldServer)conn.getPresentEntity().worldObj, conn.getPresentEntity(), true), this.getInfo()));
}
this.syncTimer = 0;
}
this.ticked.clear();
@ -916,7 +928,8 @@ public final class Server implements IThreadListener, Executor {
vars.add(new Pair(var.getKey(), var.getValue().getRaw()));
}
conn.sendPacket(new SPacketServerConfig(vars));
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, EntityRegistry.getEntityID(player), tag == null));
conn.sendPacket(new SPacketDimensions(Dimensions.getDimensionData()));
conn.sendPacket(new SPacketJoinGame(player.getId(), world.dimension, UniverseRegistry.getName(world.dimension), EntityRegistry.getEntityID(player), tag == null));
conn.sendPacket(new SPacketHeldItemChange(player.inventory.currentItem));
this.sendPacket(new SPacketPlayerListItem(false, conn));
@ -1051,7 +1064,7 @@ public final class Server implements IThreadListener, Executor {
nplayer.setPosition(nplayer.posX, nplayer.posY + 1.0D, nplayer.posZ);
}
}
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.setPlayerLocation(nplayer.posX, nplayer.posY, nplayer.posZ, nplayer.rotYaw, nplayer.rotPitch);
conn.sendPacket(new SPacketSetExperience(nplayer.experience, nplayer.experienceTotal, nplayer.experienceLevel));
this.updateTimeAndWeatherForPlayer(conn, world);
@ -1093,7 +1106,7 @@ public final class Server implements IThreadListener, Executor {
world.loadChunk((int)nplayer.posX >> 4, (int)nplayer.posZ >> 4);
world.addPlayer(nplayer);
world.spawnEntityInWorld(nplayer);
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.sendPacket(new SPacketRespawn(world.dimension != oldWorld.dimension ? world.dimension : null, world.dimension != oldWorld.dimension ? UniverseRegistry.getName(world.dimension) : null, EntityRegistry.getEntityID(nplayer), conn.isInEditor()));
conn.sendPacket(new SPacketSkin(nplayer.getId(), nplayer.getSkin())); // , nplayer.getModel()));
conn.setPlayerLocation(nplayer.posX, nplayer.posY, nplayer.posZ, nplayer.rotYaw, nplayer.rotPitch);
conn.sendPacket(new SPacketSetExperience(nplayer.experience, nplayer.experienceTotal, nplayer.experienceLevel));
@ -1111,7 +1124,7 @@ public final class Server implements IThreadListener, Executor {
public void transferToDimension(EntityNPC player, Dimension dimension, BlockPos pos, float yaw, float pitch, PortalType portal) {
WorldServer oldWorld = (WorldServer)player.getServerWorld(); // this.getWorld(player.dimension);
WorldServer newWorld = this.getWorld(dimension);
player.connection.sendPacket(new SPacketRespawn(newWorld.dimension, EntityRegistry.getEntityID(player), player.connection.isInEditor()));
player.connection.sendPacket(new SPacketRespawn(newWorld.dimension, UniverseRegistry.getName(newWorld.dimension), EntityRegistry.getEntityID(player), player.connection.isInEditor()));
oldWorld.removePlayerEntityDangerously(player);
player.dead = false;
this.placeInDimension(player, oldWorld, newWorld, pos, portal);
@ -1182,7 +1195,7 @@ public final class Server implements IThreadListener, Executor {
}
private void updateTimeAndWeatherForPlayer(Player conn, WorldServer world) {
conn.sendPacket(new SPacketTimeUpdate(world.getDayTime(), this.getInfo()));
conn.sendPacket(new SPacketTimeUpdate(world.getDayTime(), Dimensions.formatTime(world, conn.getPresentEntity(), true), this.getInfo()));
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.SET_WEATHER, world.getWeather().ordinal()));
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.RAIN_STRENGTH, world.getRainStrength()));
conn.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.DARKNESS, world.getDarkness()));

View file

@ -3,8 +3,8 @@ package server.command;
import java.util.Collection;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import common.util.Position;
import server.init.UniverseRegistry;
public class DimensionParser extends CompletingParser {
private final boolean useSender;

View file

@ -5,7 +5,7 @@ import java.util.List;
import common.collect.Lists;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import server.init.UniverseRegistry;
import server.world.WorldServer;
public class WorldParser extends DimensionParser {

View file

@ -12,13 +12,16 @@ import common.dimension.Dimension;
import common.dimension.Planet;
import common.dimension.Star;
import common.init.NameRegistry;
import common.init.UniverseRegistry;
import common.packet.SPacketDimensions;
import common.rng.Random;
import server.Server;
import server.command.ArgumentParser;
import server.command.Command;
import server.command.CommandEnvironment;
import server.command.Executor;
import server.command.RunException;
import server.dimension.Dimensions;
import server.init.UniverseRegistry;
import server.network.Player;
import server.world.Converter;
@ -27,13 +30,16 @@ public class CommandLoad extends Command {
private String loadingDim;
public static Planet registerPlanet(String star, String name, String custom, int sky, int fog, int clouds, long orbit, long rotation,
public static Planet registerPlanet(Server server, String star, String name, String custom, int sky, int fog, int clouds, long orbit, long rotation,
float offset, float gravity, float temperature, int brightness) {
star = star == null ? UniverseRegistry.getName(new Random().pick(Lists.newArrayList(UniverseRegistry.getStars()))) : star;
if(!UniverseRegistry.isType(star, DimType.STAR) || UniverseRegistry.isRegistered(name))
return null;
Planet dim = new Planet(sky, fog, clouds, 17000000, orbit, rotation, offset, gravity, temperature, brightness);
return UniverseRegistry.registerCustomPlanet(name, custom, dim, star);
Planet planet = UniverseRegistry.registerCustomPlanet(name, custom, dim, star);
Dimensions.updateDimensions();
server.sendPacket(new SPacketDimensions(UniverseRegistry.getId(planet), UniverseRegistry.getName(planet), planet));
return planet;
}
public static void registerPreset(Dimension preset) {
@ -117,7 +123,7 @@ public class CommandLoad extends Command {
}
this.loadingDim = name;
if(Converter.convert(dir, name, pos -> env.getServer().schedule(() -> {
Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
Planet planet = registerPlanet(env.getServer(), star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
this.loadingDim = null;
exec.log(TextColor.GREEN + "Welt %s wurde erfolgreich in Dimension '%s' konvertiert", dir, display);
if(teleport && pos != null) {
@ -134,7 +140,7 @@ public class CommandLoad extends Command {
}
return;
}
Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
Planet planet = registerPlanet(env.getServer(), star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
exec.log(TextColor.GREEN + "Dimension '%s' wurde registriert", display);
if(teleport && ((Player)exec).getPresentEntity() != null)
((Player)exec).getPresentEntity().teleport(CommandWorld.adjust(env.getServer().getWorld(planet), ((Player)exec).getPresentEntity().getPosition()), planet);

View file

@ -6,6 +6,7 @@ import server.command.Command;
import server.command.CommandEnvironment;
import server.command.Executor;
import server.command.RunException;
import server.dimension.Dimensions;
import server.network.Player;
import server.world.WorldServer;
@ -90,7 +91,7 @@ public class CommandTime extends Command {
dim.setDayTime(time);
dim.resetWeather();
}
exec.log("Zeit auf %s gesetzt", world.formatTime(exec.isPlayer() ? ((Player)exec).getPresentEntity() : null, false));
exec.log("Zeit auf %s gesetzt", Dimensions.formatTime(world, exec.isPlayer() ? ((Player)exec).getPresentEntity() : null, false));
return time;
}
}

View file

@ -0,0 +1,160 @@
package server.dimension;
import java.util.List;
import common.collect.Lists;
import common.dimension.Area;
import common.dimension.DimType;
import common.dimension.Dimension;
import common.dimension.Moon;
import common.dimension.Planet;
import common.dimension.Sector;
import common.dimension.Space;
import common.dimension.Star;
import common.entity.npc.EntityNPC;
import common.packet.SPacketDimensions.DimData;
import server.init.UniverseRegistry;
import server.world.WorldServer;
public abstract class Dimensions {
public static int calcSunColor(Dimension dim) {
if(dim.getType() == DimType.MOON) {
Planet planet = UniverseRegistry.getPlanet((Moon)dim);
Star star = UniverseRegistry.getStar(planet);
return (star.getSkyColor() & 0xffffff) | (star.isExterminated() ? 0x80000000 : 0);
}
else if(dim.getType() == DimType.PLANET) {
Star star = UniverseRegistry.getStar((Planet)dim);
return (star.getSkyColor() & 0xffffff) | (star.isExterminated() ? 0x80000000 : 0);
}
return 0xffffffff;
}
public static int[] calcMoonColors(Dimension dim) {
if(dim.getType() == DimType.MOON) {
Planet planet = UniverseRegistry.getPlanet((Moon)dim);
return new int[] {(planet.getSkyColor() & 0xffffff) | (planet.isExterminated() ? 0x80000000 : 0)};
}
else if(dim.getType() == DimType.PLANET) {
List<Moon> moons = UniverseRegistry.getMoons((Planet)dim);
int[] colors = new int[moons.size()];
for(int z = 0; z < colors.length; z++) {
colors[z] = (moons.get(z).getSkyColor() & 0xffffff) | (moons.get(z).isExterminated() ? 0x80000000 : 0);
}
return colors;
}
return new int[0];
}
public static String[] getBaseNames(Dimension dim) {
if(dim == Space.INSTANCE)
return new String[0];
String planet = null;
String star = null;
switch(dim.getType()) {
case MOON:
dim = UniverseRegistry.getPlanet((Moon)dim);
planet = dim.getDisplay();
case PLANET:
dim = UniverseRegistry.getStar((Planet)dim);
star = dim.getDisplay();
case STAR:
Sector sector = UniverseRegistry.getSector((Star)dim);
String sect = sector.getDisplay();
String galaxy = UniverseRegistry.getGalaxy(sector).getDisplay();
if(planet != null)
return new String[] {planet, star, sect, galaxy};
else if(star != null)
return new String[] {star, sect, galaxy};
else
return new String[] {sect, galaxy};
case AREA:
return new String[] {UniverseRegistry.getDomain((Area)dim).getDisplay()};
default:
return new String[0];
}
}
public static int getTimeQualifier(Dimension dim, Dimension home) {
if(home == null || home.getType() != DimType.PLANET)
return -1;
Planet homePlanet = (Planet)home;
if(dim == Space.INSTANCE)
return 7;
else if(dim.getType() == DimType.SEMI)
return 8;
else if(dim.getType() == DimType.AREA)
return 9;
if(dim == homePlanet)
return 0;
Star homeStar = UniverseRegistry.getStar(homePlanet);
if(dim == homeStar)
return 3;
Moon moon = dim.getType() == DimType.MOON ? (Moon)dim : null;
Planet planet = dim.getType() == DimType.PLANET ? (Planet)dim : (moon != null ? UniverseRegistry.getPlanet(moon) : null);
if(planet == homePlanet)
return 1;
Star star = dim.getType() == DimType.STAR ? (Star)dim : (planet != null ? UniverseRegistry.getStar(planet) : null);
if(star == homeStar)
return 2;
Sector homeSector = UniverseRegistry.getSector(homeStar);
Sector sector = star != null ? UniverseRegistry.getSector(star) : null;
if(sector == homeSector)
return 4;
if(sector != null && UniverseRegistry.getGalaxy(sector) == UniverseRegistry.getGalaxy(homeSector))
return 5;
return 6;
}
public static String formatTime(WorldServer world, Dimension home, int category, boolean days) {
String qualifier = home != null ? (category >= 0 ? category + "." : "?.") : "";
long time = world.getDayTime();
String gtime;
if((home == null || !home.isCelestial()) && !world.dimension.isCelestial()) {
gtime = "???.???.M?";
}
else {
long yearTime = (home != null && home.isCelestial() ? home : world.dimension).getOrbitalPeriod();
long year = time / yearTime;
long frac = (time * 1000L / yearTime) % 1000L;
gtime = String.format("%03d.%03d.M%d", frac, year % 1000L, year / 1000L + 1L);
}
if(!days)
return qualifier + gtime;
String ltime;
if(!world.dimension.isCelestial()) {
ltime = " T???.??? D???.???.G?";
}
else {
long day = time / world.dimension.getRotationalPeriod();
time = time % world.dimension.getRotationalPeriod();
ltime = String.format(" T%03d.%03d D%03d.%03d.G%d",
time / 1000L, time % 1000L, (day / 1000L) % 1000L, day % 1000L, day / 1000000L);
}
return qualifier + gtime + ltime;
}
public static String formatTime(WorldServer world, EntityNPC player, boolean days) {
return formatTime(world, player == null ? null : player.getOrigin().getDimension(), player == null ? -1 : getTimeQualifier(world.dimension, player.getOrigin().getDimension()), days);
}
public static void updateDimensions() {
for(Dimension dim : UniverseRegistry.getDimensions()) {
if(dim == Space.INSTANCE)
continue;
if(dim.getType() == DimType.PLANET || dim.getType() == DimType.MOON) {
dim.setSunColor(calcSunColor(dim));
dim.setMoonColors(calcMoonColors(dim));
}
dim.setBaseNames(getBaseNames(dim));
}
}
public static List<DimData> getDimensionData() {
List<DimData> list = Lists.newArrayList();
for(Dimension dim : UniverseRegistry.getDimensions()) {
list.add(new DimData(UniverseRegistry.getId(dim), UniverseRegistry.getName(dim), dim.getType(), dim.getDisplay(), dim.getBaseNames()));
}
return list;
}
}

View file

@ -3,7 +3,6 @@ package server.init;
import java.util.Map;
import common.collect.Maps;
import common.dimension.Dimension;
import common.init.UniverseRegistry;
import common.util.PortalType;
public abstract class TeleportRegistry {

View file

@ -0,0 +1,735 @@
package server.init;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import common.biome.Biome;
import common.biome.Scaling;
import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
import common.dimension.Area;
import common.dimension.CloudType;
import common.dimension.DimType;
import common.dimension.Dimension;
import common.dimension.Dimension.PopulatorType;
import common.dimension.Domain;
import common.dimension.Galaxy;
import common.dimension.Moon;
import common.dimension.Section;
import common.dimension.Planet;
import common.dimension.Sector;
import common.dimension.Semi;
import common.dimension.Space;
import common.dimension.Star;
import common.entity.Entity;
import common.entity.animal.EntityBat;
import common.entity.animal.EntityCat;
import common.entity.animal.EntityChicken;
import common.entity.animal.EntityCow;
import common.entity.animal.EntityFox;
import common.entity.animal.EntityHorse;
import common.entity.animal.EntityMouse;
import common.entity.animal.EntityPig;
import common.entity.animal.EntityRabbit;
import common.entity.animal.EntitySheep;
import common.entity.animal.EntityWolf;
import common.entity.npc.EntityArachnoid;
import common.entity.npc.EntityBloodElf;
import common.entity.npc.EntityCultivator;
import common.entity.npc.EntityElf;
import common.entity.npc.EntityFireDemon;
import common.entity.npc.EntityHaunter;
import common.entity.npc.EntityMage;
import common.entity.npc.EntityMerfolk;
import common.entity.npc.EntityMetalhead;
import common.entity.npc.EntitySlime;
import common.entity.npc.EntitySpirit;
import common.entity.npc.EntityTiefling;
import common.entity.npc.EntityUndead;
import common.entity.npc.EntityWoodElf;
import common.entity.npc.EntityZombie;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.DimensionRegistry;
import common.init.EntityRegistry;
import common.init.MetalType;
import common.world.Weather;
import java.util.Set;
public abstract class UniverseRegistry extends DimensionRegistry {
private static final List<Section> SECTIONS = Lists.newArrayList();
private static final Set<String> NAME_LIST = Sets.newTreeSet();
private static final Map<Moon, Planet> MOON_PLANET = Maps.newHashMap();
private static final Map<Planet, List<Moon>> PLANET_MOONS = Maps.newHashMap();
private static final Map<Planet, Star> PLANET_STAR = Maps.newHashMap();
private static final Map<Star, List<Planet>> STAR_PLANETS = Maps.newHashMap();
private static final Map<Star, Sector> STAR_SECTOR = Maps.newHashMap();
private static final Map<Sector, List<Star>> SECTOR_STARS = Maps.newHashMap();
private static final Map<Sector, Galaxy> SECTOR_GALAXY = Maps.newHashMap();
private static final Map<Galaxy, List<Sector>> GALAXY_SECTORS = Maps.newHashMap();
private static final Map<Area, Domain> AREA_DOMAIN = Maps.newHashMap();
private static final Map<Domain, List<Area>> DOMAIN_AREAS = Maps.newHashMap();
private static final Set<Semi> SEMI = Sets.newHashSet();
public static List<Section> getSections() {
return SECTIONS;
}
public static Collection<Galaxy> getGalaxies() {
return GALAXY_SECTORS.keySet();
}
public static Collection<Sector> getSectors() {
return SECTOR_GALAXY.keySet();
}
public static Collection<Domain> getDomains() {
return DOMAIN_AREAS.keySet();
}
public static Collection<Star> getStars() {
return STAR_SECTOR.keySet();
}
public static Collection<Planet> getPlanets() {
return PLANET_STAR.keySet();
}
public static Collection<Moon> getMoons() {
return MOON_PLANET.keySet();
}
public static Collection<Area> getAreas() {
return AREA_DOMAIN.keySet();
}
public static Collection<Semi> getSemis() {
return SEMI;
}
public static List<Sector> getSectors(Galaxy galaxy) {
return GALAXY_SECTORS.get(galaxy);
}
public static List<Star> getStars(Sector sector) {
return SECTOR_STARS.get(sector);
}
public static List<Planet> getPlanets(Star star) {
return STAR_PLANETS.get(star);
}
public static List<Moon> getMoons(Planet planet) {
return PLANET_MOONS.get(planet);
}
public static List<Area> getAreas(Domain domain) {
return DOMAIN_AREAS.get(domain);
}
public static Star getStar(Planet planet) {
return PLANET_STAR.get(planet);
}
public static Planet getPlanet(Moon moon) {
return MOON_PLANET.get(moon);
}
public static Sector getSector(Star star) {
return STAR_SECTOR.get(star);
}
public static Galaxy getGalaxy(Sector sector) {
return SECTOR_GALAXY.get(sector);
}
public static Domain getDomain(Area area) {
return AREA_DOMAIN.get(area);
}
public static Section getSection(String name) {
return NAME_MAP.get(name);
}
public static Set<String> getWorldNames() {
return NAME_LIST;
}
public static boolean isRegistered(String name) {
return NAME_MAP.containsKey(name);
}
public static boolean isType(String name, DimType type) {
return NAME_MAP.containsKey(name) && NAME_MAP.get(name) instanceof Dimension dim && dim.getType() == type;
}
public static Galaxy registerCustomGalaxy(String name, String display) {
Galaxy galaxy = new Galaxy(true);
registerGalaxyInt(name, display, galaxy);
return galaxy;
}
public static Sector registerCustomSector(String name, String display, String galaxy) {
Section base = NAME_MAP.get(galaxy);
if(!(base instanceof Galaxy baseGalaxy))
throw new IllegalArgumentException("Galaxie " + galaxy + " existiert nicht");
Sector sector = new Sector(true);
registerSectorInt(name, display, sector, baseGalaxy);
return sector;
}
public static Domain registerCustomDomain(String name, String display) {
Domain domain = new Domain(true);
registerDomainInt(name, display, domain);
return domain;
}
public static Star registerCustomStar(String name, String display, Star dim, String sector) {
Section base = NAME_MAP.get(sector);
if(!(base instanceof Sector baseSector))
throw new IllegalArgumentException("Sektor " + sector + " existiert nicht");
if(!dim.isCustom())
dim = (Star)dim.makeCustomCopy();
registerStarInt(name, display, dim, baseSector);
return dim;
}
public static Planet registerCustomPlanet(String name, String display, Planet dim, String star) {
Section base = NAME_MAP.get(star);
if(!(base instanceof Star baseStar))
throw new IllegalArgumentException("Stern " + star + " existiert nicht");
if(!dim.isCustom())
dim = (Planet)dim.makeCustomCopy();
registerPlanetInt(name, display, dim, baseStar);
return dim;
}
public static Moon registerCustomMoon(String name, String display, Moon dim, String planet) {
Section base = NAME_MAP.get(planet);
if(!(base instanceof Planet basePlanet))
throw new IllegalArgumentException("Planet " + planet + " existiert nicht");
if(!dim.isCustom())
dim = (Moon)dim.makeCustomCopy();
registerMoonInt(name, display, dim, basePlanet);
return dim;
}
public static Area registerCustomArea(String name, String display, Area dim, String domain) {
Section base = NAME_MAP.get(domain);
if(!(base instanceof Domain baseDomain))
throw new IllegalArgumentException("Bereich " + domain + " existiert nicht");
if(!dim.isCustom())
dim = (Area)dim.makeCustomCopy();
registerAreaInt(name, display, dim, baseDomain);
return dim;
}
public static Semi registerCustomSemi(String name, String display, Semi dim) {
if(!dim.isCustom())
dim = (Semi)dim.makeCustomCopy();
registerSemiInt(name, display, dim);
return dim;
}
private static void register(String name, String display, Section obj) {
if(NAME_MAP.containsKey(name))
throw new IllegalArgumentException("Objekt " + name + " ist bereits registriert");
obj.setDisplay(display);
NAME_MAP.put(name, obj);
NAMES.put(obj, name);
SECTIONS.add(obj);
if(obj instanceof Dimension dim) {
NAME_LIST.add(name);
ID_MAP.put(DIMENSIONS.size(), dim);
IDS.put(dim, DIMENSIONS.size());
DIMENSIONS.add(dim);
}
}
private static void registerGalaxyInt(String name, String display, Galaxy galaxy) {
register(name, display, galaxy);
GALAXY_SECTORS.put(galaxy, Lists.newArrayList());
}
private static void registerSectorInt(String name, String display, Sector sector, Galaxy galaxy) {
register(name, display, sector);
SECTOR_GALAXY.put(sector, galaxy);
SECTOR_STARS.put(sector, Lists.newArrayList());
GALAXY_SECTORS.get(galaxy).add(sector);
}
private static void registerDomainInt(String name, String display, Domain domain) {
register(name, display, domain);
DOMAIN_AREAS.put(domain, Lists.newArrayList());
}
private static void registerStarInt(String name, String display, Star star, Sector sector) {
register(name, display, star);
STAR_SECTOR.put(star, sector);
STAR_PLANETS.put(star, Lists.newArrayList());
SECTOR_STARS.get(sector).add(star);
}
private static void registerPlanetInt(String name, String display, Planet planet, Star star) {
register(name, display, planet);
PLANET_STAR.put(planet, star);
PLANET_MOONS.put(planet, Lists.newArrayList());
STAR_PLANETS.get(star).add(planet);
}
private static void registerMoonInt(String name, String display, Moon moon, Planet planet) {
register(name, display, moon);
MOON_PLANET.put(moon, planet);
PLANET_MOONS.get(planet).add(moon);
}
private static void registerAreaInt(String name, String display, Area area, Domain domain) {
register(name, display, area);
AREA_DOMAIN.put(area, domain);
DOMAIN_AREAS.get(domain).add(area);
}
private static void registerSemiInt(String name, String display, Semi semi) {
register(name, display, semi);
SEMI.add(semi);
}
private static Galaxy lastGalaxy;
private static Sector lastSector;
private static Domain lastDomain;
private static Star lastStar;
private static Planet lastPlanet;
private static String fromDisplay(String display) {
return display.toLowerCase().replace("'", "").replace(' ', '_');
}
private static void registerGalaxy(String name, String display, Runnable sub) {
registerGalaxyInt(name, display, lastGalaxy = new Galaxy(false));
sub.run();
lastGalaxy = null;
}
private static void registerSector(String name, String display, Runnable sub) {
registerSectorInt(name, display, lastSector = new Sector(false), lastGalaxy);
sub.run();
lastSector = null;
}
private static void registerDomain(String name, String display, Runnable sub) {
registerDomainInt(name, display, lastDomain = new Domain(false));
sub.run();
lastDomain = null;
}
private static void registerStar(String name, String display, Dimension dim, Runnable sub) {
registerStarInt(name, display, lastStar = (Star)dim, lastSector);
sub.run();
lastStar = null;
}
private static void registerPlanet(String name, String display, Dimension dim) {
registerPlanetInt(name, display, (Planet)dim, lastStar);
}
private static void registerPlanet(String name, String display, Dimension dim, Runnable sub) {
registerPlanetInt(name, display, lastPlanet = (Planet)dim, lastStar);
sub.run();
lastPlanet = null;
}
private static void registerMoon(String name, String display, Dimension dim) {
registerMoonInt(name, display, (Moon)dim, lastPlanet);
}
private static void registerArea(String name, String display, Dimension dim) {
registerAreaInt(name, display, (Area)dim, lastDomain);
}
private static void registerSemi(String name, String display, Dimension dim) {
registerSemiInt(name, display, (Semi)dim);
}
private static void registerGalaxy(String display, Runnable sub) {
registerGalaxy(fromDisplay(display), "Galaxie " + display, sub);
}
private static void registerSector(String display, Runnable sub) {
registerSector(fromDisplay(display), "Sektor " + display, sub);
}
private static void registerDomain(String display, Runnable sub) {
registerDomain(fromDisplay(display), display, sub);
}
private static void registerStar(String display, Dimension dim, Runnable sub) {
registerStar(fromDisplay(display), "Stern " + display, dim, sub);
}
private static void registerPlanet(String display, Dimension dim) {
registerPlanet(fromDisplay(display), "Planet " + display, dim);
}
private static void registerPlanet(String display, Dimension dim, Runnable sub) {
registerPlanet(fromDisplay(display), "Planet " + display, dim, sub);
}
private static void registerMoon(String display, Dimension dim) {
registerMoon(fromDisplay(display), "Mond " + display, dim);
}
private static void registerArea(String display, Dimension dim) {
registerArea(fromDisplay(display), display, dim);
}
private static void registerSemi(String display, Dimension dim) {
registerSemi(fromDisplay(display), display, dim);
}
private static void registerStar(String display, int radius, float gravity, float temp, Runnable sub) {
registerStar(display, new Star(radius, gravity, temp), sub);
}
private static void registerMoon(String display, int radius, long orbit, long rotation, float gravity, float temperature) {
registerMoon(display, new Moon(radius, orbit, rotation, gravity, temperature));
}
private static void registerMoon(String display, int radius, long orbitRotation, float gravity, float temperature) {
registerMoon(display, new Moon(radius, orbitRotation, gravity, temperature));
}
// public static final Biome PLAIN = new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW);
// public static final Biome DESERT = new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW);
// public static final Biome HILLS = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE);
// public static final Biome FOREST = new Biome(8.0f, 80.0f);
// public static final Biome TAIGA = new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM);
// public static final Biome SWAMP = new Biome(12.0f, 90.0f, Scaling.SEA_POND);
// public static final Biome ICE = new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW);
// public static final Biome ICE_HILLS = new Biome(-20.0f, 50.0f, Scaling.HILLS_LOW);
// public static final Biome BEACH = new Biome(12.0f, 40.0f, Scaling.SEA_SHORE);
// public static final Biome DESERT_HILLS = new Biome(60.0f, 0.0f, Scaling.HILLS_LOW);
// public static final Biome FOREST_HILLS = new Biome(8.0f, 80.0f, Scaling.HILLS_LOW);
// public static final Biome TAIGA_HILLS = new Biome(-10.0f, 80.0f, Scaling.HILLS_LOW);
// public static final Biome HILLS_EDGE = new Biome(-12.0f, 30.0f, Scaling.HILLS_MEDIUM);
// public static final Biome TROPIC = new Biome(18.0f, 90.0f);
// public static final Biome TROPIC_HILLS = new Biome(18.0f, 90.0f, Scaling.HILLS_LOW);
// public static final Biome TROPIC_EDGE = new Biome(18.0f, 80.0f);
// public static final Biome STONE_BEACH = new Biome(-12.0f, 30.0f, Scaling.SEA_VARYING);
// public static final Biome ICE_BEACH = new Biome(-18.0f, 30.0f, Scaling.SEA_SHORE);
// public static final Biome BIRCH_FOREST = new Biome(4.0f, 60.0f);
// public static final Biome BIRCH_HILLS = new Biome(4.0f, 60.0f, Scaling.HILLS_LOW);
// public static final Biome DARK_FOREST = new Biome(8.0f, 80.0f);
// public static final Biome ICE_TAIGA = new Biome(-40.0f, 40.0f, Scaling.PLAINS_MEDIUM);
// public static final Biome ICE_TAIGA_HILLS = new Biome(-40.0f, 40.0f, Scaling.HILLS_LOW);
// public static final Biome LARGE_TAIGA = new Biome(-8.0f, 80.0f, Scaling.PLAINS_MEDIUM);
// public static final Biome LARGE_TAIGA_HILLS = new Biome(-8.0f, 80.0f, Scaling.HILLS_LOW);
// public static final Biome LARGE_HILLS = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE);
// public static final Biome SAVANNA = new Biome(28.0f, 0.0f, Scaling.PLAINS_LOW);
// public static final Biome SAVANNA_PLATEAU = new Biome(20.0f, 0.0f, Scaling.HILLS_PLATEAU);
//
// public static final Biome DESERT_MOD = new Biome(60.0f, 0.0f, 0.225F, 0.25F);
// public static final Biome HILLS_MOD = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE);
// public static final Biome FLOWER_FOREST = new Biome(8.0f, 80.0f, 0.1F, 0.4F);
// public static final Biome TAIGA_MOD = new Biome(-10.0f, 80.0f, 0.3F, 0.4F);
// public static final Biome SWAMP_MOD = new Biome(12.0f, 90.0f, -0.1F, 0.3F);
// public static final Biome ICE_SPIKES = new Biome(-20.0f, 50.0f, 0.425F, 0.45F);
// public static final Biome TROPIC_MOD = new Biome(18.0f, 90.0f, 0.2F, 0.4F);
// public static final Biome TROPIC_EDGE_MOD = new Biome(18.0f, 80.0f, 0.2F, 0.4F);
// public static final Biome BIRCH_FOREST_MOD = new Biome(4.0f, 60.0f, 0.2F, 0.4F);
// public static final Biome BIRCH_HILLS_MOD = new Biome(4.0f, 60.0f, 0.55F, 0.5F);
// public static final Biome DARK_FOREST_MOD = new Biome(8.0f, 80.0f, 0.2F, 0.4F);
// public static final Biome ICE_TAIGA_MOD = new Biome(-40.0f, 40.0f, 0.3F, 0.4F);
// public static final Biome SPRUCE_TAIGA = new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM);
// public static final Biome REDWOOD_TAIGA = new Biome(-10.0f, 80.0f, 0.3F, 0.4F);
// public static final Biome LARGE_HILLS_MOD = new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE);
// public static final Biome SAVANNA_MOD = new Biome(24.0f, 0.0f, 0.3625F, 1.225F);
// public static final Biome SAVANNA_PLATEAU_MOD = new Biome(20.0f, 0.0f, 1.05F, 1.2125F);
//
// .setBiomeGen(Biome.FOREST, false, 4, 4, 6, 50).enableMobs().enableSnow()
// .setFrostBiomes(Biome.ICE, Biome.ICE, Biome.ICE, Biome.ICE_TAIGA, Biome.LARGE_TAIGA)
// .setColdBiomes(Biome.FOREST, Biome.HILLS, Biome.TAIGA, Biome.PLAIN)
// .setMediumBiomes(Biome.FOREST, Biome.DARK_FOREST, Biome.HILLS, Biome.PLAIN, Biome.BIRCH_FOREST,
// Biome.SWAMP, Biome.TROPIC)
// .setHotBiomes(Biome.DESERT, Biome.DESERT, Biome.DESERT, Biome.SAVANNA, Biome.SAVANNA, Biome.PLAIN)
public static void register() { // TODO: add mushroom 0.2F, 0.3F .addSpawn(EntityDwarf.class, 8, 4, 8)
register("space", "Der Weltraum", Space.INSTANCE);
registerGalaxy("milkyway", "Galaxie Milchstraße", () -> {
registerSector("Solar", () -> {
registerStar("Sol", 695508000, 274.0f, 5778.0f, () -> {
registerPlanet("Terra", new Planet(6378136, 8766144L, 24000L, 28.0f, 9.81f, 259.15f)
.setPerlinGen(Blocks.stone.getState(), Blocks.water.getState(), 63)
.setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState())
.setPopulator(PopulatorType.BASIC)
.setBiomeGen(new Biome(8.0f, 80.0f), false, 4, 4, 6, 50).enableSnow()
.setFrostBiomes(new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-20.0f, 50.0f, Scaling.PLAINS_LOW), new Biome(-40.0f, 40.0f, Scaling.PLAINS_MEDIUM), new Biome(-8.0f, 80.0f, Scaling.PLAINS_MEDIUM))
.setColdBiomes(new Biome(8.0f, 80.0f), new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE), new Biome(-10.0f, 80.0f, Scaling.PLAINS_MEDIUM), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW))
.setMediumBiomes(new Biome(8.0f, 80.0f), new Biome(8.0f, 80.0f, 0.1F, 0.4F), new Biome(8.0f, 80.0f), new Biome(-12.0f, 30.0f, Scaling.HILLS_LARGE), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW), new Biome(4.0f, 60.0f),
new Biome(12.0f, 90.0f, Scaling.SEA_POND), new Biome(18.0f, 90.0f))
.setHotBiomes(new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(60.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(60.0f, 0.0f, Scaling.HILLS_LOW), new Biome(28.0f, 0.0f, Scaling.PLAINS_LOW), new Biome(20.0f, 0.0f, Scaling.HILLS_PLATEAU), new Biome(12.0f, 40.0f, Scaling.PLAINS_LOW))
.enableCavesRavines(Blocks.lava.getState()).setDungeons(8)
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false)
.addLake(Blocks.lava.getState(), Blocks.stone.getState(), null, 8, 8, 255, true)
.addLiquid(Blocks.flowing_water.getState(), 50, 8, 255, false)
.addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true)
.addMetalOres(MetalType.values())
.addOre(Blocks.dirt.getState(), 10, 0, 33, 0, 256, false)
.addOre(Blocks.gravel.getState(), 8, 0, 33, 0, 256, false)
.addOre(Blocks.rock.getState(), 6, 0, 22, 24, 72, false)
.addOre(Blocks.coal_ore.getState(), 20, 0, 17, 0, 128, false)
.addOre(Blocks.charge_ore.getState(), 8, 0, 8, 0, 16, false)
.addOre(Blocks.lapis_ore.getState(), 1, 0, 7, 16, 16, true)
.addOre(Blocks.diamond_ore.getState(), 1, 0, 8, 0, 16, false)
.addOre(Blocks.ruby_ore.getState(), 1, 0, 4, 12, 8, true)
.addOre(Blocks.cinnabar_ore.getState(), 1, 0, 11, 0, 24, false)
.addSpawn(EntitySheep.class, 12, 4, 4)
.addSpawn(EntityRabbit.class, 10, 3, 10)
.addSpawn(EntityPig.class, 10, 4, 4)
.addSpawn(EntityChicken.class, 10, 4, 4)
.addSpawn(EntityCow.class, 8, 4, 4)
.addSpawn(EntityArachnoid.class, 100, 4, 4)
.addSpawn(EntityZombie.class, 100, 4, 4)
.addSpawn(EntityUndead.class, 100, 4, 4)
.addSpawn(EntityHaunter.class, 100, 4, 4)
.addSpawn(EntitySlime.class, 100, 4, 4)
.addSpawn(EntityMage.class, 5, 1, 1)
.addSpawn(EntityBat.class, 10, 8, 8)
.addSpawn(EntityMouse.class, 10, 8, 8)
.addSpawn(EntityWolf.class, 5, 2, 4)
.addSpawn(EntityFox.class, 4, 2, 6)
.addSpawn(EntityWoodElf.class, 100, 4, 16)
.addSpawn(EntityElf.class, 12, 4, 16)
.addSpawn(EntityMerfolk.class, 10, 4, 4)
.addSpawn(EntityHorse.class, 5, 2, 6)
.addSpawn(EntityCat.class, 2, 1, 1)
.enableVillages().enableMineshafts().enableScattered().enableStrongholds(), () -> {
registerMoon("Luna", 1737100, 655728L, 1.62f, 210.0f);
});
registerPlanet("mercury", "Planet Merkur", new Planet(0x666666, 0x535353, 0x858585, 2440530, 2111297L, 1407509L, 3.7f, 440.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63));
registerPlanet("Venus", new Planet(0xc0c0c0, 0xa0a0a0, 0xe0e0e0, 6051800, 5392908L, 5832449L, 8.87f, 737.0f)
.setPerlinGen(Blocks.sand.getState(), Blocks.air.getState(), 63));
registerPlanet("Mars", new Planet(0xd6905b, 0xbd723a, 0xbd9273, 3396190, 16487781L, 24623L, 3.71f, 208.0f)
.setPerlinGen(Blocks.red_sand.getState(), Blocks.air.getState(), 63), () -> {
registerMoon("Phobos", 11080, 7654L, 0.0057f, 233.0f);
registerMoon("Deimos", 6270, 30312L, 0.003f, 233.0f);
});
registerPlanet("Jupiter", new Planet(0xffd5ba, 0xb89f90, 0xc7b5a9, 71492000, 103989391L, 9925L, 24.79f, 163.0f).enableDenseFog()
.setFlatGen(Blocks.hydrogen.getState(), 256).setCloudHeight(576.0f), () -> {
});
registerPlanet("Saturn", new Planet(0xf1d1a1, 0xd3b385, 0xeed7b5, 60268000, 258141008L, 10656L, 10.44f, 133.0f).enableDenseFog()
.setFlatGen(Blocks.hydrogen.getState(), 256).setCloudHeight(576.0f), () -> {
});
registerPlanet("Uranus", new Planet(0xcee6ff, 0xadd2f9, 0x8eb0d3, 25559000, 736503770L, 17240L, 8.87f, 78.0f)
.setPerlinGen(Blocks.packed_ice.getState(), Blocks.water.getState(), 70)
.addOre(Blocks.diamond_ore.getState(), 4, 4, 12, 0, 60, false), () -> {
});
registerPlanet("neptune", "Planet Neptun", new Planet(0xb4d9ff, 0x85bef9, 0x649bd3, 24764000, 1444584441L, 16110L, 11.15f, 72.0f)
.setPerlinGen(Blocks.packed_ice.getState(), Blocks.water.getState(), 70)
.addOre(Blocks.diamond_ore.getState(), 4, 2, 1, 0, 60, false), () -> {
registerMoon("Triton", 1353400, 141044L, 0.779f, 38.0f);
// registerMoon("Nereid", , L, f, .0f);
// registerMoon("Naiad", , L, f, .0f);
// registerMoon("Thalassa", , L, f, .0f);
// registerMoon("Despina", , L, f, .0f);
// registerMoon("Galatea", , L, f, .0f);
// registerMoon("Larissa", , L, f, .0f);
// registerMoon("Proteus", , L, f, .0f);
// registerMoon("Halimede", , L, f, .0f);
// registerMoon("Psamathe", , L, f, .0f);
// registerMoon("Sao", , L, f, .0f);
// registerMoon("Laomedeia", , L, f, .0f);
// registerMoon("Neso", , L, f, .0f);
// registerMoon("Hippocamp", , L, f, .0f);
});
registerPlanet("Ceres", new Planet(0x666666, 0x535353, 0x858585, 473000, 40315496L, 9074L, 0.27f, 167.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63));
registerPlanet("Pluto", new Planet(0x666666, 0x535353, 0x858585, 1188300, 2173127098L, 153293L, 0.62f, 40.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63), () -> {
registerMoon("Charon", 606000, 153293L, 0.288f, 53.0f);
registerMoon("Nix", 22500, 596511L, 0.0028f, 38.0f);
registerMoon("Hydra", 27500, 916842L, 0.051f, 23.0f);
registerMoon("Kerberos", 7000, 772021L, 0.0015f, 19.0f);
registerMoon("Styx", 5500, 483877L, 77760L, 0.0013f, 18.0f);
});
registerPlanet("Haumea", new Planet(0x666666, 0x535353, 0x858585, 816000, 2487831667L, 3914L, 0.63f, 48.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63));
registerPlanet("Makemake", new Planet(0x666666, 0x535353, 0x858585, 715000, 2684193293L, 22826L, 0.4f, 30.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63));
registerPlanet("Eris", new Planet(0x666666, 0x535353, 0x858585, 1163000, 4900274496L, 378862L, 0.82f, 30.0f)
.setPerlinGen(Blocks.moon_rock.getState(), Blocks.air.getState(), 63));
});
registerStar("Gi'rok", 603421976, 232.0f, 5220.0f, () -> {
registerPlanet("gharoth", "Elbenplanet Gharoth", new Planet(2806382, 4837386L, 52960L, 30.0f, 10.0f, 257.3f + 8.0f) //TODO: check temp
.setSimpleGen(Blocks.dirt.getState(), Blocks.water.getState(), 64)
.setSimpleReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState())
.setPopulator(PopulatorType.ELVEN_FOREST).enableCaves(Blocks.air.getState()).setDungeons(4).enableSnow()
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false)
.addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true)
.addLiquid(Blocks.flowing_water.getState(), 50, 8, 255, false)
.addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true)
.addOre(Blocks.thetium_ore.getState(), 1, 0, 3, 0, 14, false)
.addOre(Blocks.gyriyn_ore.getState(), 0, 2, 3, 0, 12, false)
.addSpawn(EntitySheep.class, 12, 4, 4)
.addSpawn(EntityRabbit.class, 10, 3, 10)
.addSpawn(EntityChicken.class, 10, 4, 4)
.addSpawn(EntityMouse.class, 10, 8, 8)
.addSpawn(EntityWoodElf.class, 100, 4, 16)
.addSpawn(EntityElf.class, 12, 4, 16)
.addSpawn(EntityFox.class, 3, 2, 5));
registerPlanet("transylvania", "Vampirplanet Transsylvanien", new Planet(8374921, 33850466L, 49760L, 20.0f, 10.0f, 255.5f)
.setPerlinGen(Blocks.rock.getState(), Blocks.water.getState(), 63)
.setTerranianReplacer(Blocks.grass.getState(), Blocks.dirt.getState(), Blocks.gravel.getState(), Blocks.sand.getState()).setBiomeGen(new Biome(8.0f, 80.0f), true, 5, 3, 3, 30)
.setPopulator(PopulatorType.FOREST).enableCavesRavines(Blocks.lava.getState()).setDungeons(10).enableSnow()
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false)
.addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true)
.addLiquid(Blocks.flowing_water.getState(), 50, 8, 255, false)
.addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true)
.addOre(Blocks.coal_ore.getState(), 12, 0, 14, 4, 28, false)
.addOre(Blocks.lead_ore.getState(), 2, 0, 8, 0, 8, false)
.addOre(Blocks.ardite_ore.getState(), 0, 2, 3, 0, 12, false)
.addOre(Blocks.nichun_ore.getState(), 0, 10, 1, 0, 10, false)
.addSpawn(EntitySheep.class, 12, 4, 4)
.addSpawn(EntityCow.class, 8, 4, 4)
.addSpawn(EntityArachnoid.class, 100, 4, 4)
.addSpawn(EntityZombie.class, 100, 4, 4)
.addSpawn(EntityUndead.class, 100, 4, 4)
.addSpawn(EntitySlime.class, 100, 4, 4)
.addSpawn(EntityBat.class, 10, 8, 8)
.addSpawn(EntityMouse.class, 10, 8, 8)
.addSpawn(EntityWolf.class, 5, 2, 4)
.addSpawn(EntityHorse.class, 5, 2, 6), () -> {
registerMoon("yrdinath", "Eismond Yrdinath", new Moon(0xccccff, 2503812, 46743637L, 17460L, 2.5f, 239.15f, Blocks.snow, Blocks.ice, 0.1F, 0.2F) //TODO: check height
.enableSnow().setDefaultWeather(Weather.SNOW)
.addSpawn(EntitySheep.class, 50, 4, 4)
.addSpawn(EntitySpirit.class, 10, 1, 1));
registerMoon("mythril", "Eismond Mythril", new Moon(0xbbbbff, 2213749, 42659432L, 15330L, 2.25f, 221.65f, Blocks.snow, Blocks.ice, 0.1F, 0.2F)
.enableSnow().setDefaultWeather(Weather.SNOW)
.addSpawn(EntitySheep.class, 50, 4, 4)
.addSpawn(EntitySpirit.class, 10, 1, 1));
});
registerPlanet("mesar", "Wüstenplanet Me'sar", new Planet(0xff7f3f, 0xff6022, 0xff6f00, 9823183, 56643366L, 87340L, 11.0f, 333.15f)
.setPerlinGen(Blocks.rock.getState(), Blocks.air.getState(), 63, 0.2f, 0.4f)
.setMesarianReplacer(Blocks.red_sand.getState(), Blocks.dirt.getState()).setPopulator(PopulatorType.MESARIAN)
.enableCavesRavines(Blocks.lava.getState())
.addLake(Blocks.lava.getState(), null, null, 8, 8, 255, true)
.addLiquid(Blocks.flowing_lava.getState(), 20, 8, 255, true)
.addOre(Blocks.iron_ore.getState(), 6, 2, 24, 0, 64, false)
.addOre(Blocks.gold_ore.getState(), 4, 2, 20, 0, 48, false)
.addOre(Blocks.lead_ore.getState(), 6, 0, 14, 0, 32, false)
.addOre(Blocks.copper_ore.getState(), 8, 2, 12, 0, 52, false)
.addOre(Blocks.coal_ore.getState(), 8, 4, 30, 0, 16, false)
.addOre(Blocks.stone.getState(), 8, 4, 33, 0, 80, false));
});
});
});
registerGalaxy("Drkthrn", () -> {
registerSector("blvck", "Sectvr Blvck", () -> {
registerStar("Ov'rol", new Star(0x000000, 832718528, 302.0f, 12666.0f, Blocks.goo), () -> {
registerPlanet("blackplanet", "Der Schwarze Planet", new Planet(0x000000, 0x000000, 0x000000, 13038204, 4632918508L, 204556L, 12.0f, 0.0f)
.setPerlinGen(Blocks.blackened_stone.getState(), Blocks.goo.getState(), 63)
.setSimpleAltReplacer(Blocks.blackened_soil.getState(), Blocks.blackened_dirt.getState(), Blocks.blackened_cobble.getState())
.setPopulator(PopulatorType.BLACKENED)
.enableCaves(Blocks.air.getState()).setDungeons(4)
.addLake(Blocks.goo.getState(), null, null, 8, 8, 255, true)
// .addOre(Blocks.PLACEHOLDER_ore.getState(), 0, 2, 3, 0, 12, false)
.addSpawn(EntityMetalhead.class, 50, 1, 1)
);
});
});
});
Dimension warp = new Semi(0x0c001f, 0x190033, 124072917, 285.0f, 3).setCloudTexture(CloudType.DENSE).setCloudHeight(238.0f)
.setPerlinGen(Blocks.obsidian.getState(), Blocks.lava.getState(), 63, 1.0F, 2.0F).setPopulator(PopulatorType.CHAOS)
.enableCavesRavines(Blocks.air.getState()).enableLongCaves().enableSnow()
.addLake(Blocks.water.getState(), null, Blocks.obsidian.getState(), 8, 0, 255, false)
.addLake(Blocks.lava.getState(), null, null, 1, 8, 255, false)
.addLiquid(Blocks.flowing_water.getState(), 1, 8, 255, false)
.addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true)
.setStarBrightness(0.9f).setDeepStarBrightness(0.6f)
.setStarColorSin(25.0f, 0.1f, 0.25f, 0xff00ff, 1, 4).setDeepStarColorSin(25.0f, 0.1f, 0.5f, 0xff00ff, 1, 4);
for(Class<? extends Entity> clazz : EntityRegistry.getAllClasses()) {
if(EntityLiving.class.isAssignableFrom(clazz))
warp.addSpawn((Class<? extends EntityLiving>)clazz, 1, 1, 8);
}
registerSemi("warp", "Der Warp", warp);
registerDomain("Tian'Xin", () -> {
registerArea("Ni'enrath", new Area(0x7f00ff, 532109, 276.15f, 1).setLightColor(0x07000f).setBlockColor(0xcf6fff)
.setPerlinGen(Blocks.tian.getState(), Blocks.spring_water.getState(), 63, 0.1F, 1.0F)
.setSimpleAltReplacer(Blocks.tian_soil.getState(), Blocks.tian.getState())
.setPopulator(PopulatorType.TIAN).enableLongCaves().enableSnow()
.addLake(Blocks.spring_water.getState(), Blocks.tian.getState(), Blocks.tian.getState(), 4, 0, 255, false)
.addLiquid(Blocks.flowing_spring_water.getState(), 50, 8, 255, false)
.addSpawn(EntityCultivator.class, 50, 1, 1)
.addSpawn(EntityMerfolk.class, 10, 4, 4)
.addSpawn(EntityRabbit.class, 10, 3, 10)
.addSpawn(EntityBat.class, 10, 8, 8)
.addSpawn(EntityMouse.class, 10, 8, 8));
});
registerDomain("Digital", () -> {
registerArea("Cyberspace", new Area(0x000000, 16777216, 293.15f, 15).setLightColor(0x00ff00).setBlockColor(0xff0000).enableBlockLightSubtraction()
.setFlatGen(Blocks.green_clay.getState(), 2));
});
registerDomain("hell", "Hölle", () -> {
registerArea("thedric", "Kreis Thedric", new Area(0x330707, 105639735, 347.15f, 2).enableLongCaves().enableFortresses()
.enableWorldCeiling().enableDenseFog()
.setCavernGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 63)
.setSurfaceReplacer(Blocks.gravel.getState(), Blocks.soul_sand.getState()).setPopulator(PopulatorType.HELL)
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 10, 1, 2)
.addSpawn(EntityMetalhead.class, 1, 1, 1));
registerArea("kyroth", "Kreis Kyroth", new Area(0x990000, 86742970, 387.15f, 3).enableLongCaves()
.setSimpleGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 64)
.setSimpleReplacer(Blocks.obsidian.getState(), Blocks.soul_sand.getState())
.addLake(Blocks.lava.getState(), null, null, 4, 8, 255, false)
.addLiquid(Blocks.flowing_lava.getState(), 40, 8, 255, true)
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 50, 2, 10)
.addSpawn(EntityCultivator.class, 10, 1, 1));
registerArea("ahrd", "Kreis Ahrd", new Area(0xcc0000, 67028432, 467.15f, 15).enableLongCaves()
.setPerlinGen(Blocks.hellrock.getState(), Blocks.lava.getState(), 63, 1.0F, 0.5F)
.setSimpleAltReplacer(Blocks.soul_sand.getState())
.addLake(Blocks.lava.getState(), Blocks.soul_sand.getState(), Blocks.soul_sand.getState(),
2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true)
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 50, 2, 10)
.addSpawn(EntityCultivator.class, 10, 1, 1));
registerArea("mizorath", "Kreis Mizorath", new Area(0xff0000, 54029584, 1067.15f, 15)
.setPerlinGen(Blocks.hellrock.getState(), Blocks.blood.getState(), 63, -0.2F, 0.1F)
.setSimpleAltReplacer(Blocks.soul_sand.getState())
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 50, 2, 10)
.addSpawn(EntityCultivator.class, 10, 1, 1));
registerArea("dargoth", "Kreis Dargoth", new Area(0xff3f0c, 43293629, 1707.15f, 15)
.setPerlinGen(Blocks.hellrock.getState(), Blocks.magma.getState(), 63, -0.2F, 0.1F)
.setSimpleAltReplacer(Blocks.soul_sand.getState())
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 50, 2, 10)
.addSpawn(EntityCultivator.class, 10, 1, 1));
registerArea("aasirith", "Kreis Aasirith", new Area(0x191919, 36291872, 2482.0f, 1).enableLongCaves()
.setPerlinGen(Blocks.rock.getState(), Blocks.magma.getState(), 63, 0.125F, 0.05F)
.setSimpleAltReplacer(Blocks.ash.getState(), Blocks.rock.getState(), Blocks.ash.getState())
.addLake(Blocks.lava.getState(), Blocks.rock.getState(), Blocks.rock.getState(),
2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true)
.addSpawn(EntityFireDemon.class, 50, 4, 4)
.addSpawn(EntityTiefling.class, 100, 4, 4)
.addSpawn(EntityBloodElf.class, 50, 2, 10)
.addSpawn(EntityCultivator.class, 10, 1, 1));
});
}
}

View file

@ -15,6 +15,7 @@ import common.block.tech.InteractionObject;
import common.collect.Lists;
import common.color.TextColor;
import common.dimension.Dimension;
import common.dimension.Space;
import common.effect.Effect;
import common.effect.StatusEffect;
import common.entity.Entity;
@ -32,7 +33,6 @@ import common.init.Blocks;
import common.init.EntityRegistry;
import common.init.Items;
import common.init.SoundEvent;
import common.init.UniverseRegistry;
import common.inventory.Container;
import common.inventory.ContainerChest;
import common.inventory.ContainerEnchantment;
@ -131,6 +131,7 @@ import server.clipboard.ClipboardPlacer;
import server.clipboard.RotationRegistry;
import server.clipboard.RotationValue;
import server.command.Executor;
import server.init.UniverseRegistry;
import server.util.Form;
import server.vars.SVars;
import server.world.ChunkServer;
@ -1592,7 +1593,7 @@ public class Player extends User implements Executor, IPlayer
String type = EntityRegistry.getEntityName(tag.getString("id"));
int level = tag.getInt("XpLevel");
Dimension origin = UniverseRegistry.getDimension(tag.getString("OriginDim"));
return new PlayerCharacter(name, info, align, dim, pos, type, level, origin == null ? null : UniverseRegistry.getName(origin));
return new PlayerCharacter(name, info, align, dim, pos, type, level, origin == null || origin == Space.INSTANCE ? null : origin.getDisplay());
}
public void onConnect() {
@ -2460,7 +2461,7 @@ public class Player extends User implements Executor, IPlayer
Position pos = this.server.getRandomSpawnPosition(origin);
this.entity.teleport(pos);
this.teleportPos = this.deathPos = null;
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getDisplay(), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel, UniverseRegistry.getName(world.dimension))));
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getDisplay(), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel, world.dimension == Space.INSTANCE ? null : world.dimension.getDisplay())));
// if(this.local)
// this.server.setDone();
break;

View file

@ -25,6 +25,7 @@ import common.block.natural.BlockSnow;
import common.collect.Lists;
import common.collect.Maps;
import common.collect.Sets;
import common.dimension.DimType;
import common.dimension.Dimension;
import common.dimension.Dimension.GeneratorType;
import common.dimension.Lake;
@ -39,7 +40,6 @@ import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.init.Blocks;
import common.init.SoundEvent;
import common.init.UniverseRegistry;
import common.init.WoodType;
import common.log.Log;
import common.network.IPlayer;
@ -82,7 +82,9 @@ import common.world.Weather;
import common.world.World;
import server.Server;
import server.clipboard.ClipboardBlock;
import server.dimension.Dimensions;
import server.init.TeleportRegistry;
import server.init.UniverseRegistry;
import server.network.Player;
import server.vars.SVars;
import server.village.VillageCollection;
@ -1504,7 +1506,7 @@ public final class WorldServer extends AWorldServer {
if(this.dimension.isExterminated())
return false;
this.resetData(true);
this.reloadChunks();
// this.reloadChunks(); //TODO: why was this here?
for(EntityNPC player : this.players) {
player.attackEntityFrom(DamageSource.causeExterminatusDamage(null), 5000);
Packet packet = new SPacketEffect(1025, new BlockPos(player.posX, (double)this.getSeaLevel() + 4.0, player.posZ), 0);
@ -1541,11 +1543,16 @@ public final class WorldServer extends AWorldServer {
this.dimension.setExterminated(exterminated);
this.initGenerator(exterminated);
this.reloadChunks();
if(updated)
if(updated) {
Dimensions.updateDimensions();
for(Player player : this.server.getPlayers()) {
if(player.getEntity() != null)
player.sendPacket(new SPacketCelestials(player.getEntity().worldObj.dimension));
if(player.getEntity() != null) {
Dimension dim = player.getEntity().worldObj.dimension;
if(dim.getType() == DimType.PLANET || dim.getType() == DimType.MOON)
player.sendPacket(new SPacketCelestials(dim));
}
}
}
}
private void insertChunk(int x, int z) {

View file

@ -57,13 +57,14 @@ public class BiomeGenerator {
public BiomeGenerator(long seed, Biome def, boolean fixed, int biomeSize, int riverSize, int snowRarity, int seaRarity,
Biome[] add, int addRarity, Biome[] hot, Biome[] medium, Biome[] cold, Biome[] frost) {
this.biomes = new Biome[5 + hot.length + medium.length + cold.length + frost.length + add.length];
this.defBiome = this.biomes[GenLayer.NONE] = def;
this.biomes = new Biome[6 + hot.length + medium.length + cold.length + frost.length + add.length];
this.biomes[GenLayer.NONE] = new Biome(def.temperature, def.humidity, def.depth, def.scale);
this.biomes[GenLayer.RIVER] = new Biome(0.0f, 50.0f, Scaling.SEA_SHALLOW);
this.biomes[GenLayer.SEA] = new Biome(0.0f, 50.0f, Scaling.SEA_MEDIUM);
this.biomes[GenLayer.ICE_RIVER] = new Biome(-20.0f, 50.0f, Scaling.SEA_SHALLOW);
this.biomes[GenLayer.ICE_SEA] = new Biome(-20.0f, 50.0f, Scaling.SEA_MEDIUM);
int n = 5;
this.defBiome = this.biomes[GenLayer.DEFAULT] = def;
int n = 6;
for(Biome biome : frost) {
this.biomes[n++] = biome;
}

View file

@ -6,6 +6,7 @@ public abstract class GenLayer {
public static final int SEA = 2;
public static final int ICE_RIVER = 3;
public static final int ICE_SEA = 4;
public static final int DEFAULT = 5;
private long worldGenSeed;
private long chunkSeed;