fix dimensions
This commit is contained in:
parent
0e848f01c4
commit
8b983f15c2
20 changed files with 789 additions and 527 deletions
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
|
@ -249,6 +250,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
|
||||
public static final GuiChar INSTANCE = new GuiChar();
|
||||
private static final File TEXTURE_FOLDER = new File("skins");
|
||||
private static final List<Dimension> DIMENSIONS = Lists.newArrayList();
|
||||
|
||||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
|
@ -264,6 +266,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
@Variable(name = "char_filter_species", category = CVarCategory.GUI, display = "Filtern", callback = FilterFunction.class, switched = true)
|
||||
private FilterType filterSpecies = FilterType.ALL;
|
||||
|
||||
static {
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
if(dim.getType() == DimType.PLANET || dim.getType() == DimType.MOON || dim.getType() == DimType.AREA || dim.getType() == DimType.SEMI)
|
||||
DIMENSIONS.add(dim);
|
||||
}
|
||||
}
|
||||
|
||||
private GuiChar() {
|
||||
}
|
||||
|
||||
|
@ -383,7 +392,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
public void use(ActButton elem, PressType action) {
|
||||
if(GuiChar.this.gm.player != null) {
|
||||
GuiChar.this.gm.show(GuiLoading.makeWaitTask("Lade Welt ..."));
|
||||
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
|
||||
Dimension dim = DIMENSIONS.get(GuiChar.this.dimension);
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
|
||||
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, UniverseRegistry.getId(dim)));
|
||||
}
|
||||
|
@ -410,13 +419,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
}, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag()));
|
||||
this.templateButton.enabled = false;
|
||||
this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
|
||||
this.dimension = new Random().zrange(DIMENSIONS.size());
|
||||
EntityInfo info = EntityRegistry.DNA.get(this.gm.player == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.player));
|
||||
if(info != null && info.origin() != null) {
|
||||
Dimension dim = UniverseRegistry.getDimension(info.origin());
|
||||
if(dim != null) {
|
||||
for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) {
|
||||
if(UniverseRegistry.getBaseDimensions().get(z) == dim) {
|
||||
for(int z = 0; z < DIMENSIONS.size(); z++) {
|
||||
if(DIMENSIONS.get(z) == dim) {
|
||||
this.dimension = z;
|
||||
break;
|
||||
}
|
||||
|
@ -426,14 +435,14 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
this.dimButton = this.add(new ActButton(width - 390, height - 156, 388, 0, new ButtonCallback() {
|
||||
public void use(ActButton elem, PressType mode) {
|
||||
if(mode == PressType.TERTIARY) {
|
||||
GuiChar.this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size());
|
||||
GuiChar.this.dimension = new Random().zrange(DIMENSIONS.size());
|
||||
}
|
||||
else if(mode == PressType.SECONDARY) {
|
||||
if(--GuiChar.this.dimension < 0)
|
||||
GuiChar.this.dimension = UniverseRegistry.getBaseDimensions().size() - 1;
|
||||
GuiChar.this.dimension = DIMENSIONS.size() - 1;
|
||||
}
|
||||
else {
|
||||
if(++GuiChar.this.dimension >= UniverseRegistry.getBaseDimensions().size())
|
||||
if(++GuiChar.this.dimension >= DIMENSIONS.size())
|
||||
GuiChar.this.dimension = 0;
|
||||
}
|
||||
GuiChar.this.setDimButton();
|
||||
|
@ -444,7 +453,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
|
|||
}
|
||||
|
||||
private void setDimButton() {
|
||||
Dimension dim = UniverseRegistry.getBaseDimensions().get(this.dimension);
|
||||
Dimension dim = DIMENSIONS.get(this.dimension);
|
||||
this.dimButton.setText((dim.getType() == DimType.PLANET ? "Heimplanet" : "Heimdimension") + ": " + dim.getFormattedName(false));
|
||||
String name = dim.getFormattedName(true);
|
||||
int index = name.indexOf(" / ");
|
||||
|
|
156
client/src/main/java/client/gui/ingame/GuiCreateDimension.java
Normal file
156
client/src/main/java/client/gui/ingame/GuiCreateDimension.java
Normal file
|
@ -0,0 +1,156 @@
|
|||
package client.gui.ingame;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import client.gui.Gui;
|
||||
import common.biome.Biome;
|
||||
import common.block.foliage.LeavesType;
|
||||
import common.collect.Lists;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Dimension.GeneratorType;
|
||||
import common.dimension.Dimension.ReplacerType;
|
||||
import common.init.Blocks;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.tags.TagObject;
|
||||
import common.world.State;
|
||||
|
||||
public class GuiCreateDimension extends Gui {
|
||||
public static final GuiCreateDimension INSTANCE = new GuiCreateDimension();
|
||||
private static final List<Dimension> PRESETS = Lists.newArrayList();
|
||||
|
||||
private static Dimension addPreset(String display, String base, String data) {
|
||||
Dimension dim = UniverseRegistry.getDimension(base).makeCustomCopy();
|
||||
TagObject ptag;
|
||||
try {
|
||||
ptag = TagObject.parse("{" + data + "}");
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
TagObject dtag = new TagObject();
|
||||
dim.toTags(dtag);
|
||||
if(ptag.getBool("ClearGenerator")) {
|
||||
ptag.remove("ClearGenerator");
|
||||
dtag.remove("FloorBlock");
|
||||
dtag.remove("CeilingBlock");
|
||||
dtag.remove("Layers");
|
||||
dtag.remove("AddBiomes");
|
||||
dtag.remove("FrostBiomes");
|
||||
dtag.remove("ColdBiomes");
|
||||
dtag.remove("MediumBiomes");
|
||||
dtag.remove("HotBiomes");
|
||||
dtag.remove("Ores");
|
||||
dtag.remove("Lakes");
|
||||
dtag.remove("Liquids");
|
||||
dtag.setString("Generator", GeneratorType.FLAT.getName());
|
||||
dtag.setString("Replacer", ReplacerType.NONE.getName());
|
||||
// dtag.setBoolean("MobGen", false);
|
||||
// dtag.setBoolean("SnowGen", false);
|
||||
dtag.setBool("Caves", false);
|
||||
dtag.setBool("Ravines", false);
|
||||
dtag.setBool("AltCaves", false);
|
||||
dtag.setBool("Strongholds", false);
|
||||
dtag.setBool("Villages", false);
|
||||
dtag.setBool("Mineshafts", false);
|
||||
dtag.setBool("Scattered", false);
|
||||
dtag.setBool("Fortresses", false);
|
||||
dtag.setInt("Dungeons", 0);
|
||||
dtag.setInt("BiomeSize", 0);
|
||||
dtag.setInt("RiverSize", 4);
|
||||
dtag.setInt("SnowRarity", 6);
|
||||
dtag.setInt("SeaRarity", 50);
|
||||
dtag.setInt("AddRarity", 50);
|
||||
dtag.setInt("SeaLevel", 0);
|
||||
dtag.setString("DefaultBiome", Biome.NONE.name.toLowerCase());
|
||||
dtag.setBool("SemiFixed", false);
|
||||
// dtag.setString("DefaultWeather", Weather.CLEAR.getName());
|
||||
dtag.setString("DefaultLeaves", LeavesType.SPRING.getName());
|
||||
Dimension.writeState(dtag, "FillerBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "TopBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "SurfaceBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock1", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock2", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "LiquidBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "CaveFillBlock", Blocks.air.getState());
|
||||
}
|
||||
dtag.merge(ptag);
|
||||
dim.fromTags(dtag);
|
||||
dim.setCustomName(display);
|
||||
PRESETS.add(dim);
|
||||
return dim;
|
||||
}
|
||||
|
||||
private static Dimension addPreset(String display, String data) {
|
||||
return addPreset(display, "terra", data);
|
||||
}
|
||||
|
||||
private static Dimension addFlatPreset(String display, Biome biome, boolean populate, State main, Object ... layers) {
|
||||
return addFlatPreset(display, "terra", biome, populate, main, layers);
|
||||
}
|
||||
|
||||
private static Dimension addFlatPreset(String display, String base, Biome biome, boolean populate, State main, Object ... layers) {
|
||||
Dimension dim = addPreset("Flach - " + display, base, "ClearGenerator:1b" + (populate ? "" : ",NoPopulation:1b"));
|
||||
dim.setBiome(biome);
|
||||
if(main != null)
|
||||
dim.setFlatGen(main, layers);
|
||||
return dim;
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
addPreset("Standard", "");
|
||||
addPreset("Doppelte Höhe (128)", "BaseSize:17.0,Stretch:24.0,ScaleY:80.0,SeaLevel:127");
|
||||
addPreset("Große Biome", "BiomeSize:6");
|
||||
addPreset("Überdreht", "Amplification:2.0");
|
||||
addPreset("Wasserwelt", "ScaleX:5000.0,ScaleY:1000.0,ScaleZ:5000.0,Stretch:8.0,BDepthWeight:2.0,BDepthOffset:0.5,BScaleWeight:2.0,BScaleOffset:0.375,SeaLevel:511");
|
||||
addPreset("Inselland", "CoordScale:3000.0,HeightScale:6000.0,UpperLmtScale:250.0,Stretch:10.0");
|
||||
addPreset("Favorit des Gräbers", "ScaleX:5000.0,ScaleY:1000.0,ScaleZ:5000.0,Stretch:5.0,BDepthWeight:2.0,BDepthOffset:1.0,BScaleWeight:4.0,BScaleOffset:1.0");
|
||||
addPreset("Verrückte Berge", "CoordScale:738.41864,HeightScale:157.69133,UpperLmtScale:801.4267,LowerLmtScale:1254.1643,DepthScaleX:374.93652,DepthScaleZ:288.65228,"
|
||||
+ "ScaleX:1355.9908,ScaleY:745.5343,ScaleZ:1183.464,BaseSize:1.8758626,Stretch:1.7137525,BDepthWeight:1.7553768,BDepthOffset:3.4701107,BScaleOffset:2.535211");
|
||||
addPreset("Trockenheit", "ScaleX:1000.0,ScaleY:3000.0,ScaleZ:1000.0,Stretch:10.0,SeaLevel:20");
|
||||
addPreset("Chaotische Höhlen", "UpperLmtScale:2.0,LowerLmtScale:64.0,SeaLevel:6");
|
||||
addPreset("Viel Glück", "LiquidBlock:lava,SeaLevel:40");
|
||||
|
||||
addFlatPreset("Klassisch", Biome.PLAINS, false, Blocks.dirt.getState(), Blocks.bedrock.getState(), 2, Blocks.dirt.getState(),
|
||||
Blocks.grass.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Abbauwelt", Biome.EXTREMEHILLS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 230, Blocks.stone.getState(),
|
||||
5, Blocks.dirt.getState(), Blocks.grass.getState()).enableStrongholds().enableMineshafts().setDungeons(8);
|
||||
|
||||
addFlatPreset("Wasserwelt", Biome.SEA, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 5, Blocks.stone.getState(),
|
||||
52, Blocks.dirt.getState(), 5, Blocks.sand.getState(), 90, Blocks.water.getState());
|
||||
|
||||
addFlatPreset("Oberfläche", Biome.PLAINS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages().enableStrongholds().enableMineshafts().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);
|
||||
|
||||
addFlatPreset("Verschneites Königreich", Biome.ICEPLAINS, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Verschneites Königreich +", Biome.ICEPLAINS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages()
|
||||
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false);
|
||||
|
||||
addFlatPreset("Unendliche Grube", Biome.PLAINS, false, Blocks.dirt.getState(), 2, Blocks.cobblestone.getState(), 3, Blocks.dirt.getState(), Blocks.grass.getState())
|
||||
.setBiomeReplacer(Blocks.gravel.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Wüste", Biome.DESERT, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), 52, Blocks.sandstone.getState())
|
||||
.enableVillages().enableScattered();
|
||||
|
||||
addFlatPreset("Redstonewelt", Biome.DESERT, false, Blocks.sandstone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(),
|
||||
52, Blocks.sandstone.getState());
|
||||
|
||||
addPreset("Leer", "ClearGenerator:1b");
|
||||
addPreset("Alpha 1.2", "Strongholds:0b,Villages:0b,MineShafts:0b,Scattered:0b,Generator:simple,Replacer:simple,Ravines:0b,SeaLevel:64,AltBlock2:sand");
|
||||
}
|
||||
|
||||
private GuiCreateDimension() {
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return "Neue Dimension erstellen";
|
||||
}
|
||||
}
|
|
@ -88,6 +88,7 @@ import common.packet.SPacketBlockAction;
|
|||
import common.packet.SPacketBlockBreakAnim;
|
||||
import common.packet.SPacketBlockChange;
|
||||
import common.packet.SPacketCamera;
|
||||
import common.packet.SPacketCelestials;
|
||||
import common.packet.SPacketCharacterList;
|
||||
import common.packet.SPacketChunkData;
|
||||
import common.packet.SPacketCollectItem;
|
||||
|
@ -1912,11 +1913,19 @@ public class ClientPlayer implements IClientPlayer
|
|||
}
|
||||
}
|
||||
|
||||
public void handleDimName(SPacketDimensionName packetIn) {
|
||||
NetHandler.checkThread(packetIn, this, this.gm, this.world);
|
||||
public void handleDimName(SPacketDimensionName packet) {
|
||||
NetHandler.checkThread(packet, this, this.gm, this.world);
|
||||
if(this.world.dimension.isCustom()) {
|
||||
this.world.dimension.setCustomName(packetIn.getCustomName());
|
||||
this.world.dimension.setDisplayName(packetIn.getFullName());
|
||||
this.world.dimension.setCustomName(packet.getCustomName());
|
||||
this.world.dimension.setDisplayName(packet.getFullName());
|
||||
}
|
||||
}
|
||||
|
||||
public void handleCelestials(SPacketCelestials packet) {
|
||||
NetHandler.checkThread(packet, this, this.gm, this.world);
|
||||
if(this.world.dimension.getType().celestials) {
|
||||
this.world.dimension.setSunColor(packet.getSunColor());
|
||||
this.world.dimension.setMoonColors(packet.getMoonColors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ public class RenderGlobal
|
|||
private static final String MOON_TEX = "textures/world/moon_phases.png";
|
||||
private static final String PLANET_TEX = "textures/world/planet_phases.png";
|
||||
private static final String SUN_TEX = "textures/world/sun.png";
|
||||
private static final String EXTERMINATED_TEX = "textures/world/destroyed.png";
|
||||
private static final float[] SUN_COLOR = new float[4];
|
||||
|
||||
private final Client gm;
|
||||
|
@ -1249,11 +1250,12 @@ public class RenderGlobal
|
|||
GL11.glRotatef(this.theWorld.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
|
||||
if(this.gm.world.dimension.getType().celestials) {
|
||||
float size = 30.0F;
|
||||
this.renderEngine.bindTexture(SUN_TEX);
|
||||
int color = this.gm.world.dimension.getSunColor();
|
||||
if(color != 0xffffffff) {
|
||||
Vec3 ncolor = new Vec3(color).normalize();
|
||||
GlState.color((float)ncolor.xCoord, (float)ncolor.yCoord, (float)ncolor.zCoord, f16);
|
||||
this.renderEngine.bindTexture((color & 0xff000000) != 0 ? EXTERMINATED_TEX : SUN_TEX);
|
||||
Vec3 ncolor = new Vec3(color);
|
||||
float mul = Math.min(1.0f / (float)ncolor.xCoord, Math.min(1.0f / (float)ncolor.yCoord, 1.0f / (float)ncolor.zCoord));
|
||||
GlState.color((float)ncolor.xCoord * mul, (float)ncolor.yCoord * mul, (float)ncolor.zCoord * mul, f16);
|
||||
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
worldrenderer.pos((double)(-size), 100.0D, (double)(-size)).tex(0.0D, 0.0D).endVertex();
|
||||
worldrenderer.pos((double)size, 100.0D, (double)(-size)).tex(1.0D, 0.0D).endVertex();
|
||||
|
@ -1262,26 +1264,28 @@ public class RenderGlobal
|
|||
Tessellator.draw();
|
||||
}
|
||||
size = 20.0F;
|
||||
this.renderEngine.bindTexture(this.gm.world.dimension.getType() == DimType.MOON ? PLANET_TEX : MOON_TEX);
|
||||
int[] colors = this.gm.world.dimension.getMoonColors();
|
||||
this.rand.setSeed(this.gm.world.dimension.getSeed());
|
||||
int mx = 0;
|
||||
int mz = 0;
|
||||
for(int z = 0; z < colors.length; z++) {
|
||||
Vec3 ncolor = new Vec3(colors[z]).normalize();
|
||||
GlState.color((float)ncolor.xCoord, (float)ncolor.yCoord, (float)ncolor.zCoord, f16);
|
||||
int i = this.theWorld.getMoonPhase(z);
|
||||
int k = i % 4;
|
||||
int i1 = i / 4 % 2;
|
||||
float f22 = (float)(k + 0) / 4.0F;
|
||||
float f23 = (float)(i1 + 0) / 2.0F;
|
||||
float f24 = (float)(k + 1) / 4.0F;
|
||||
float f14 = (float)(i1 + 1) / 2.0F;
|
||||
boolean destroyed = (colors[z] & 0xff000000) != 0;
|
||||
this.renderEngine.bindTexture(destroyed ? EXTERMINATED_TEX : (this.gm.world.dimension.getType() == DimType.MOON ? PLANET_TEX : MOON_TEX));
|
||||
Vec3 ncolor = new Vec3(colors[z]);
|
||||
float mul = Math.min(1.0f / (float)ncolor.xCoord, Math.min(1.0f / (float)ncolor.yCoord, 1.0f / (float)ncolor.zCoord));
|
||||
GlState.color((float)ncolor.xCoord * mul, (float)ncolor.yCoord * mul, (float)ncolor.zCoord * mul, f16);
|
||||
int phase = this.theWorld.getMoonPhase(z);
|
||||
int tx = phase % 4;
|
||||
int ty = phase / 4 % 2;
|
||||
float u1 = destroyed ? 0.0f : (float)(tx + 0) / 4.0F;
|
||||
float v1 = destroyed ? 0.0f : (float)(ty + 0) / 2.0F;
|
||||
float u2 = destroyed ? 1.0f : (float)(tx + 1) / 4.0F;
|
||||
float v2 = destroyed ? 1.0f : (float)(ty + 1) / 2.0F;
|
||||
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
worldrenderer.pos((double)(-size + mx), -100.0D, (double)(size + mz)).tex((double)f24, (double)f14).endVertex();
|
||||
worldrenderer.pos((double)(size + mx), -100.0D, (double)(size + mz)).tex((double)f22, (double)f14).endVertex();
|
||||
worldrenderer.pos((double)(size + mx), -100.0D, (double)(-size + mz)).tex((double)f22, (double)f23).endVertex();
|
||||
worldrenderer.pos((double)(-size + mx), -100.0D, (double)(-size + mz)).tex((double)f24, (double)f23).endVertex();
|
||||
worldrenderer.pos((double)(-size + mx), -100.0D, (double)(size + mz)).tex((double)u2, (double)v2).endVertex();
|
||||
worldrenderer.pos((double)(size + mx), -100.0D, (double)(size + mz)).tex((double)u1, (double)v2).endVertex();
|
||||
worldrenderer.pos((double)(size + mx), -100.0D, (double)(-size + mz)).tex((double)u1, (double)v1).endVertex();
|
||||
worldrenderer.pos((double)(-size + mx), -100.0D, (double)(-size + mz)).tex((double)u2, (double)v1).endVertex();
|
||||
Tessellator.draw();
|
||||
mx = this.rand.range(-100, 100);
|
||||
mz = this.rand.range(-100, 100);
|
||||
|
|
BIN
client/src/main/resources/textures/world/destroyed.png
Executable file
BIN
client/src/main/resources/textures/world/destroyed.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
|
@ -11,9 +11,11 @@ import common.init.BlockRegistry;
|
|||
import common.init.Blocks;
|
||||
import common.init.MetalType;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.util.ExtMath;
|
||||
import common.util.Vec3;
|
||||
import common.vars.Vars;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
|
||||
|
@ -222,6 +224,9 @@ public abstract class Dimension extends Nameable {
|
|||
private final List<Liquid> liquids = Lists.newArrayList();
|
||||
|
||||
private long seed = 0L;
|
||||
private boolean exterminated = false;
|
||||
private long timeExisted = 0L;
|
||||
private Weather weather = this.defaultWeather;
|
||||
|
||||
public static void writeState(TagObject tag, String name, State state) {
|
||||
if(state != null)
|
||||
|
@ -246,11 +251,23 @@ public abstract class Dimension extends Nameable {
|
|||
|
||||
public abstract DimType getType();
|
||||
|
||||
|
||||
|
||||
public final void setSeed(long seed) {
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
public final void setExterminated(boolean exterminated) {
|
||||
this.exterminated = exterminated;
|
||||
}
|
||||
|
||||
public final void setTimeExisted(long time) {
|
||||
this.timeExisted = time;
|
||||
}
|
||||
|
||||
public final void setCurrentWeather(Weather weather) {
|
||||
this.weather = weather;
|
||||
}
|
||||
|
||||
|
||||
// public final Dimension setLayers(List<FlatSettings> layers) {
|
||||
// this.seaLevel = 0;
|
||||
|
@ -575,8 +592,8 @@ public abstract class Dimension extends Nameable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public final Dimension setWeather(Weather value) {
|
||||
this.defaultWeather = value;
|
||||
public final Dimension setDefaultWeather(Weather value) {
|
||||
this.defaultWeather = this.weather = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -640,11 +657,23 @@ public abstract class Dimension extends Nameable {
|
|||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final long getSeed() {
|
||||
return this.seed;
|
||||
}
|
||||
|
||||
public final boolean isExterminated() {
|
||||
return this.exterminated;
|
||||
}
|
||||
|
||||
public final long getTimeExisted() {
|
||||
return this.timeExisted;
|
||||
}
|
||||
|
||||
public final Weather getCurrentWeather() {
|
||||
return this.weather;
|
||||
}
|
||||
|
||||
|
||||
public final long getOrbitalPeriod() {
|
||||
return this.orbitalPeriod;
|
||||
|
@ -677,7 +706,7 @@ public abstract class Dimension extends Nameable {
|
|||
// }
|
||||
|
||||
|
||||
public final Weather getWeather() {
|
||||
public final Weather getDefaultWeather() {
|
||||
return this.defaultWeather;
|
||||
}
|
||||
|
||||
|
@ -860,12 +889,11 @@ public abstract class Dimension extends Nameable {
|
|||
return null;
|
||||
}
|
||||
|
||||
public final Dimension copy() {
|
||||
public final Dimension makeCustomCopy() {
|
||||
Dimension dim = create(this.getType());
|
||||
TagObject tag = new TagObject();
|
||||
this.toTags(tag);
|
||||
dim.fromTags(tag);
|
||||
dim.setCustomName(this.getCustomName());
|
||||
return dim;
|
||||
}
|
||||
|
||||
|
@ -875,18 +903,47 @@ public abstract class Dimension extends Nameable {
|
|||
return tag;
|
||||
}
|
||||
|
||||
public final TagObject writeGenerator() {
|
||||
public final TagObject writeData() {
|
||||
TagObject tag = new TagObject();
|
||||
tag.setLong("Seed", this.seed);
|
||||
tag.setLong("Time", this.timeExisted);
|
||||
if(this == Space.INSTANCE)
|
||||
return tag;
|
||||
tag.setBool("Exterminated", this.exterminated);
|
||||
if(this.isCustom())
|
||||
this.toTags(tag);
|
||||
if(!this.exterminated && this.getType().weather)
|
||||
tag.setString("Weather", this.weather.getName());
|
||||
return tag;
|
||||
}
|
||||
|
||||
public final void readGenerator(TagObject tag) {
|
||||
this.seed = tag.getLong("Seed");
|
||||
public final void readData(TagObject tag) {
|
||||
if(tag.hasLong("Seed")) {
|
||||
this.seed = tag.getLong("Seed");
|
||||
}
|
||||
else {
|
||||
Random rand = new Random();
|
||||
if(!Vars.seed.isEmpty())
|
||||
rand.setSeed((long)Vars.seed.hashCode() ^ ~((long)UniverseRegistry.getName(this).hashCode()));
|
||||
this.seed = rand.longv();
|
||||
}
|
||||
this.timeExisted = tag.getLong("Time");
|
||||
if(this == Space.INSTANCE)
|
||||
return;
|
||||
this.exterminated = tag.getBool("Exterminated");
|
||||
if(this.isCustom())
|
||||
this.fromTags(tag);
|
||||
if(this.exterminated) {
|
||||
this.weather = Weather.CLEAR;
|
||||
}
|
||||
else if(this.getType().weather) {
|
||||
this.weather = Weather.getByName(tag.getString("Weather"));
|
||||
if(this.weather == null)
|
||||
this.weather = this.defaultWeather;
|
||||
}
|
||||
else {
|
||||
this.weather = this.defaultWeather;
|
||||
}
|
||||
}
|
||||
|
||||
public final void fromTags(TagObject tag) {
|
||||
|
@ -931,7 +988,7 @@ public abstract class Dimension extends Nameable {
|
|||
this.defaultBiome = Biome.findByName(tag.getString("DefaultBiome"));
|
||||
this.semiFixed = tag.getBool("SemiFixed");
|
||||
this.defaultWeather = Weather.getByName(tag.getString("DefaultWeather"));
|
||||
this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
|
||||
this.defaultWeather = this.weather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
|
||||
this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves"));
|
||||
this.defaultLeaves = this.defaultLeaves == null ? LeavesType.SPRING : this.defaultLeaves;
|
||||
this.top = readState(tag, "TopBlock", Blocks.dirt.getState());
|
||||
|
|
|
@ -24,11 +24,11 @@ public final class Moon extends Dimension {
|
|||
if(planet == null)
|
||||
return super.calcSunColor();
|
||||
Star star = UniverseRegistry.getStar(planet);
|
||||
return star == null ? super.calcSunColor() : star.getSkyColor();
|
||||
return star == null ? super.calcSunColor() : (star.getSkyColor() | (star.isExterminated() ? 0x80000000 : 0));
|
||||
}
|
||||
|
||||
protected int[] calcMoonColors() {
|
||||
Planet planet = UniverseRegistry.getPlanet(this);
|
||||
return planet == null ? super.calcMoonColors() : new int[] {planet.getSkyColor()};
|
||||
return planet == null ? super.calcMoonColors() : new int[] {planet.getSkyColor() | (planet.isExterminated() ? 0x80000000 : 0)};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ public final class Planet extends Dimension {
|
|||
|
||||
protected int calcSunColor() {
|
||||
Star star = UniverseRegistry.getStar(this);
|
||||
return star == null ? super.calcSunColor() : star.getSkyColor();
|
||||
return star == null ? super.calcSunColor() : (star.getSkyColor() | (star.isExterminated() ? 0x80000000 : 0));
|
||||
}
|
||||
|
||||
protected int[] calcMoonColors() {
|
||||
int[] colors = new int[this.moons.size()];
|
||||
for(int z = 0; z < colors.length; z++) {
|
||||
colors[z] = this.moons.get(z).getSkyColor();
|
||||
colors[z] = this.moons.get(z).getSkyColor() | (this.moons.get(z).isExterminated() ? 0x80000000 : 0);
|
||||
}
|
||||
return colors;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import common.init.Blocks;
|
|||
import common.init.EntityRegistry;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.SoundEvent;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
|
@ -270,7 +269,7 @@ public abstract class Entity
|
|||
if(this.inPortal != null) {
|
||||
if(this.vehicle == null && this.passenger == null && Vars.portals) {
|
||||
Dimension current = this.worldObj.dimension;
|
||||
Dimension dest = UniverseRegistry.getPortalDest(current, this.inPortal);
|
||||
Dimension dest = ((AWorldServer)this.worldObj).getPortalDest(this.inPortal);
|
||||
if(dest != current) {
|
||||
this.travelToDimension(dest, null, 0.0f, 0.0f, this.inPortal);
|
||||
this.inPortal = null;
|
||||
|
@ -359,7 +358,7 @@ public abstract class Entity
|
|||
if(!this.worldObj.client && this.worldObj.dimension.getType() != DimType.SPACE) {
|
||||
// this.worldObj.profiler.start("descent");
|
||||
Dimension current = this.worldObj.dimension;
|
||||
Dimension dim = Vars.voidPortal ? UniverseRegistry.getPortalDest(current, PortalType.VOID) : current;
|
||||
Dimension dim = Vars.voidPortal ? ((AWorldServer)this.worldObj).getPortalDest(PortalType.VOID) : current;
|
||||
if(dim == current) { // && (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) {
|
||||
this.kill();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package common.init;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.biome.Biome;
|
||||
import common.block.foliage.LeavesType;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.collect.Sets;
|
||||
|
@ -20,15 +20,6 @@ import common.dimension.Sector;
|
|||
import common.dimension.Semi;
|
||||
import common.dimension.Space;
|
||||
import common.dimension.Star;
|
||||
import common.dimension.Dimension.GeneratorType;
|
||||
import common.dimension.Dimension.ReplacerType;
|
||||
import common.log.Log;
|
||||
import common.rng.Random;
|
||||
import common.tags.TagObject;
|
||||
import common.util.Pair;
|
||||
import common.util.PortalType;
|
||||
import common.util.Triplet;
|
||||
import common.world.State;
|
||||
import common.world.Weather;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -36,9 +27,6 @@ import java.util.Set;
|
|||
public abstract class UniverseRegistry {
|
||||
public static final long EARTH_YEAR = 8766144L;
|
||||
|
||||
private static final List<Dimension> BASE_DIMS = Lists.newArrayList();
|
||||
private static final Map<Integer, Integer> PORTALS = Maps.newHashMap();
|
||||
|
||||
private static final List<Dimension> DIMENSIONS = Lists.newArrayList();
|
||||
private static final Map<Integer, Dimension> ID_MAP = Maps.newTreeMap();
|
||||
private static final Map<Dimension, Integer> IDS = new IdentityHashMap();
|
||||
|
@ -55,238 +43,44 @@ public abstract class UniverseRegistry {
|
|||
private static final Map<Star, Sector> STAR_MAP = Maps.newHashMap();
|
||||
private static final Map<Sector, Galaxy> SECTOR_MAP = Maps.newHashMap();
|
||||
private static final Map<Area, Domain> AREA_MAP = Maps.newHashMap();
|
||||
|
||||
public static void fromTags(TagObject tag) {
|
||||
List<Pair<String, String>> galaxies = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> sectors = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> stars = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> planets = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> moons = Lists.newArrayList();
|
||||
List<Pair<String, String>> semis = Lists.newArrayList();
|
||||
List<Pair<String, String>> domains = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> areas = Lists.newArrayList();
|
||||
|
||||
List<TagObject> list = tag.getList("Dimensions");
|
||||
for(TagObject data : list) {
|
||||
String name = data.getString("Name");
|
||||
String type = data.getString("Type");
|
||||
String display = data.hasString("CustomName") ? data.getString("CustomName") : name;
|
||||
if(type.equals("galaxy"))
|
||||
galaxies.add(new Pair(name, display));
|
||||
else if(type.equals("sector"))
|
||||
sectors.add(new Triplet(name, display, data.getString("Galaxy")));
|
||||
else if(type.equals("domain"))
|
||||
domains.add(new Pair(name, display));
|
||||
else {
|
||||
DimType dim = DimType.getByName(type);
|
||||
if(dim != null) {
|
||||
switch(dim) {
|
||||
case SEMI:
|
||||
semis.add(new Pair(name, display));
|
||||
break;
|
||||
case AREA:
|
||||
areas.add(new Triplet(name, display, data.getString("Domain")));
|
||||
break;
|
||||
case MOON:
|
||||
moons.add(new Triplet(name, display, data.getString("Planet")));
|
||||
break;
|
||||
case PLANET:
|
||||
planets.add(new Triplet(name, display, data.getString("Star")));
|
||||
break;
|
||||
case STAR:
|
||||
stars.add(new Triplet(name, display, data.getString("Sector")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> galaxy : galaxies) {
|
||||
try {
|
||||
registerGalaxy(galaxy.first(), galaxy.second(), true);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Galaxie %s nicht hinzufügen", galaxy.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> sector : sectors) {
|
||||
try {
|
||||
registerSector(sector.first(), sector.second(), sector.third(), true);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Sektor %s nicht hinzufügen", sector.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> star : stars) {
|
||||
try {
|
||||
registerStar(star.first(), star.second(), Dimension.create(DimType.STAR), star.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Stern %s nicht hinzufügen", star.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> planet : planets) {
|
||||
try {
|
||||
registerPlanet(planet.first(), planet.second(), Dimension.create(DimType.PLANET), planet.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Planet %s nicht hinzufügen", planet.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> moon : moons) {
|
||||
try {
|
||||
registerMoon(moon.first(), moon.second(), Dimension.create(DimType.MOON), moon.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Mond %s nicht hinzufügen", moon.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> semi : semis) {
|
||||
try {
|
||||
registerSemi(semi.first(), semi.second(), Dimension.create(DimType.SEMI));
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dimension %s nicht hinzufügen", semi.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> domain : domains) {
|
||||
try {
|
||||
registerDomain(domain.first(), domain.second(), true);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Bereich %s nicht hinzufügen", domain.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> area : areas) {
|
||||
try {
|
||||
registerArea(area.first(), area.second(), Dimension.create(DimType.AREA), area.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dimension %s nicht hinzufügen", area.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TagObject toTags() {
|
||||
TagObject tag = new TagObject();
|
||||
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Dimension dim : DIMENSIONS) {
|
||||
if(dim.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", dim.getType().getName());
|
||||
data.setString("Name", getName(dim));
|
||||
data.setString("CustomName", dim.getCustomName());
|
||||
switch(dim.getType()) {
|
||||
case AREA:
|
||||
data.setString("Domain", AREA_MAP.get(dim).id);
|
||||
break;
|
||||
case MOON:
|
||||
data.setString("Planet", getName(MOON_MAP.get(dim)));
|
||||
break;
|
||||
case PLANET:
|
||||
data.setString("Star", getName(PLANET_MAP.get(dim)));
|
||||
break;
|
||||
case STAR:
|
||||
data.setString("Sector", STAR_MAP.get(dim).id);
|
||||
break;
|
||||
}
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Sector sector : SECTORS.values()) {
|
||||
if(sector.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "sector");
|
||||
data.setString("Name", sector.id);
|
||||
data.setString("CustomName", sector.getCustomName());
|
||||
data.setString("Galaxy", SECTOR_MAP.get(sector).id);
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Galaxy galaxy : GALAXIES.values()) {
|
||||
if(galaxy.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "galaxy");
|
||||
data.setString("Name", galaxy.id);
|
||||
data.setString("CustomName", galaxy.getCustomName());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Domain domain : DOMAINS.values()) {
|
||||
if(domain.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "domain");
|
||||
data.setString("Name", domain.id);
|
||||
data.setString("CustomName", domain.getCustomName());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setList("Dimensions", list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
public static Planet registerPlanet(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 ? getName(new Random().pick(Lists.newArrayList(STAR_MAP.keySet()))) : star;
|
||||
if(!NAME_MAP.containsKey(star) || NAME_MAP.get(star).getType() != DimType.STAR || NAME_MAP.containsKey(name))
|
||||
return null;
|
||||
Dimension dim = new Planet(sky, fog, clouds, orbit, rotation, offset, gravity, temperature, brightness).copy();
|
||||
dim.setTimeQualifier(3);
|
||||
registerPlanet(name, custom, dim, star);
|
||||
return (Planet)dim;
|
||||
}
|
||||
|
||||
public static void registerPreset(Dimension preset) {
|
||||
Random rand = new Random();
|
||||
String pname;
|
||||
do {
|
||||
pname = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(isRegistered(pname.toLowerCase()));
|
||||
if(preset.getType() == DimType.PLANET) {
|
||||
String galaxy;
|
||||
do {
|
||||
galaxy = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(isRegistered(galaxy.toLowerCase()));
|
||||
String sector;
|
||||
do {
|
||||
sector = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(isRegistered(sector.toLowerCase()));
|
||||
String sname;
|
||||
do {
|
||||
sname = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(isRegistered(sname.toLowerCase()));
|
||||
Dimension star = new Star(0xff0000 | (rand.range(0x60, 0xa0) << 8),
|
||||
rand.frange(200.0f, 400.0f), rand.frange(5000.0f, 7000.0f),
|
||||
rand.pick(Blocks.lava.getState(), Blocks.magma.getState()), rand.range(64, 212)).copy();
|
||||
registerGalaxy(galaxy.toLowerCase(), galaxy, true);
|
||||
registerSector(sector.toLowerCase(), sector, galaxy.toLowerCase(), true);
|
||||
registerStar(sname.toLowerCase(), sname, star, galaxy.toLowerCase());
|
||||
registerPlanet(pname.toLowerCase(), pname, preset.copy(), sname.toLowerCase());
|
||||
}
|
||||
else if(preset.getType() == DimType.AREA) {
|
||||
String domain;
|
||||
do {
|
||||
domain = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(isRegistered(domain.toLowerCase()));
|
||||
registerDomain(domain.toLowerCase(), domain, true);
|
||||
registerArea(pname.toLowerCase(), pname, preset.copy(), domain.toLowerCase());
|
||||
}
|
||||
}
|
||||
private static final Set<Semi> SEMI_SET = Sets.newHashSet();
|
||||
|
||||
public static List<Dimension> getDimensions() {
|
||||
return DIMENSIONS;
|
||||
}
|
||||
|
||||
public static Collection<Galaxy> getGalaxies() {
|
||||
return GALAXIES.values();
|
||||
}
|
||||
|
||||
public static Collection<Sector> getSectors() {
|
||||
return SECTORS.values();
|
||||
}
|
||||
|
||||
public static Collection<Domain> getDomains() {
|
||||
return DOMAINS.values();
|
||||
}
|
||||
|
||||
public static Collection<Star> getStars() {
|
||||
return STAR_MAP.keySet();
|
||||
}
|
||||
|
||||
public static Collection<Planet> getPlanets() {
|
||||
return PLANET_MAP.keySet();
|
||||
}
|
||||
|
||||
public static Collection<Moon> getMoons() {
|
||||
return MOON_MAP.keySet();
|
||||
}
|
||||
|
||||
public static Collection<Area> getAreas() {
|
||||
return AREA_MAP.keySet();
|
||||
}
|
||||
|
||||
public static Collection<Semi> getSemis() {
|
||||
return SEMI_SET;
|
||||
}
|
||||
|
||||
public static Dimension getDimension(int dim) {
|
||||
return ID_MAP.get(dim);
|
||||
}
|
||||
|
@ -310,6 +104,18 @@ public abstract class UniverseRegistry {
|
|||
return MOON_MAP.get(moon);
|
||||
}
|
||||
|
||||
public static Sector getSector(Star star) {
|
||||
return STAR_MAP.get(star);
|
||||
}
|
||||
|
||||
public static Galaxy getGalaxy(Sector sector) {
|
||||
return SECTOR_MAP.get(sector);
|
||||
}
|
||||
|
||||
public static Domain getDomain(Area area) {
|
||||
return AREA_MAP.get(area);
|
||||
}
|
||||
|
||||
public static Dimension getDimension(String name) {
|
||||
return NAME_MAP.get(name);
|
||||
}
|
||||
|
@ -318,15 +124,6 @@ public abstract class UniverseRegistry {
|
|||
return NAME_LIST;
|
||||
}
|
||||
|
||||
public static List<Dimension> getBaseDimensions() {
|
||||
return BASE_DIMS;
|
||||
}
|
||||
|
||||
public static Dimension getPortalDest(Dimension src, PortalType portal) {
|
||||
return PORTALS.containsKey((portal.ordinal() << 20) | getId(src)) ? getDimension(PORTALS.get((portal.ordinal() << 20) | getId(src))) :
|
||||
(PORTALS.containsKey(portal.ordinal() | 0x7ff00000) ? getDimension(PORTALS.get(portal.ordinal() | 0x7ff00000)) : src);
|
||||
}
|
||||
|
||||
public static String getFormattedName(Dimension dim, boolean full) {
|
||||
String base = dim.getNameString();
|
||||
if(!full)
|
||||
|
@ -353,23 +150,75 @@ public abstract class UniverseRegistry {
|
|||
return GALAXIES.containsKey(name) || SECTORS.containsKey(name) || DOMAINS.containsKey(name) || NAME_MAP.containsKey(name);
|
||||
}
|
||||
|
||||
public static boolean isDimension(String name) {
|
||||
return NAME_MAP.containsKey(name);
|
||||
}
|
||||
|
||||
public static Galaxy registerCustomGalaxy(String name, String display) {
|
||||
return registerGalaxy(name, display, true);
|
||||
}
|
||||
|
||||
public static Sector registerCustomSector(String name, String display, String galaxy) {
|
||||
return registerSector(name, display, galaxy, true);
|
||||
}
|
||||
|
||||
public static Domain registerCustomDomain(String name, String display) {
|
||||
return registerDomain(name, display, true);
|
||||
}
|
||||
|
||||
public static Star registerCustomStar(String name, String display, Star dim, String sector) {
|
||||
if(!dim.isCustom())
|
||||
dim = (Star)dim.makeCustomCopy();
|
||||
registerStar(name, display, dim, sector);
|
||||
return dim;
|
||||
}
|
||||
|
||||
public static Planet registerCustomPlanet(String name, String display, Planet dim, String star) {
|
||||
if(!dim.isCustom())
|
||||
dim = (Planet)dim.makeCustomCopy();
|
||||
registerPlanet(name, display, dim, star);
|
||||
return dim;
|
||||
}
|
||||
|
||||
public static Moon registerCustomMoon(String name, String display, Moon dim, String planet) {
|
||||
if(!dim.isCustom())
|
||||
dim = (Moon)dim.makeCustomCopy();
|
||||
registerMoon(name, display, dim, planet);
|
||||
return dim;
|
||||
}
|
||||
|
||||
public static Area registerCustomArea(String name, String display, Area dim, String domain) {
|
||||
if(!dim.isCustom())
|
||||
dim = (Area)dim.makeCustomCopy();
|
||||
registerArea(name, display, dim, domain);
|
||||
return dim;
|
||||
}
|
||||
|
||||
public static Semi registerCustomSemi(String name, String display, Semi dim) {
|
||||
if(!dim.isCustom())
|
||||
dim = (Semi)dim.makeCustomCopy();
|
||||
registerSemi(name, display, dim);
|
||||
return dim;
|
||||
}
|
||||
|
||||
private static void checkRegistered(String name) {
|
||||
if(isRegistered(name))
|
||||
throw new IllegalArgumentException("Objekt " + name + " ist bereits registriert");
|
||||
}
|
||||
|
||||
private static void registerGalaxy(String name, String display, boolean custom) {
|
||||
private static Galaxy registerGalaxy(String name, String display, boolean custom) {
|
||||
checkRegistered(name);
|
||||
Galaxy galaxy = new Galaxy(name, custom);
|
||||
galaxy.setCustomName(display);
|
||||
GALAXIES.put(name, galaxy);
|
||||
return galaxy;
|
||||
}
|
||||
|
||||
private static void registerGalaxy(String name, String display) {
|
||||
registerGalaxy(name, display, false);
|
||||
}
|
||||
|
||||
private static void registerSector(String name, String display, String galaxy, boolean custom) {
|
||||
private static Sector registerSector(String name, String display, String galaxy, boolean custom) {
|
||||
checkRegistered(name);
|
||||
Galaxy base = GALAXIES.get(galaxy);
|
||||
if(base == null)
|
||||
|
@ -379,17 +228,19 @@ public abstract class UniverseRegistry {
|
|||
SECTORS.put(name, sector);
|
||||
SECTOR_MAP.put(sector, base);
|
||||
base.addSector(sector);
|
||||
return sector;
|
||||
}
|
||||
|
||||
private static void registerSector(String name, String display, String galaxy) {
|
||||
registerSector(name, display, galaxy, false);
|
||||
}
|
||||
|
||||
private static void registerDomain(String name, String display, boolean custom) {
|
||||
private static Domain registerDomain(String name, String display, boolean custom) {
|
||||
checkRegistered(name);
|
||||
Domain domain = new Domain(name, custom);
|
||||
domain.setCustomName(display);
|
||||
DOMAINS.put(name, domain);
|
||||
return domain;
|
||||
}
|
||||
|
||||
private static void registerDomain(String name, String display) {
|
||||
|
@ -405,8 +256,6 @@ public abstract class UniverseRegistry {
|
|||
ID_MAP.put(DIMENSIONS.size(), dim);
|
||||
IDS.put(dim, DIMENSIONS.size());
|
||||
DIMENSIONS.add(dim);
|
||||
if(!dim.isCustom() && (dim.getType() == DimType.PLANET || dim.getType() == DimType.AREA || dim.getType() == DimType.SEMI))
|
||||
BASE_DIMS.add(dim);
|
||||
}
|
||||
|
||||
private static void registerStar(String name, String display, Dimension dim, String sector) {
|
||||
|
@ -447,14 +296,7 @@ public abstract class UniverseRegistry {
|
|||
|
||||
private static void registerSemi(String name, String display, Dimension dim) {
|
||||
registerDimension(name, display, dim);
|
||||
}
|
||||
|
||||
private static void registerPortal(PortalType portal, String src, String dest) {
|
||||
PORTALS.put((portal.ordinal() << 20) | getId(NAME_MAP.get(src)), getId(NAME_MAP.get(dest)));
|
||||
}
|
||||
|
||||
private static void registerPortal(PortalType portal, String dest) {
|
||||
PORTALS.put(portal.ordinal() | 0x7ff00000, getId(NAME_MAP.get(dest)));
|
||||
SEMI_SET.add((Semi)dim);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
@ -554,7 +396,7 @@ public abstract class UniverseRegistry {
|
|||
.addOre(Blocks.nichun_ore.getState(), 0, 10, 1, 0, 10, false), "girok");
|
||||
registerMoon("yrdinath", "'Eismond Yrdinath'", new Moon(0xccccff, 0xccccff, 46743637L, 17460L, 2.5f, 239.15f, 8).setTimeQualifier(4)
|
||||
.setPerlinGen(Blocks.snow.getState(), Blocks.ice.getState(), 63).setBiome(Biome.SNOWLAND)
|
||||
.enableMobs().enableSnow().setWeather(Weather.SNOW), "transylvania");
|
||||
.enableMobs().enableSnow().setDefaultWeather(Weather.SNOW), "transylvania");
|
||||
registerPlanet("mesar", "'Wüstenplanet Me'sar'", new Planet(0xff7f3f, 0xff6022, 0xff6f00, 56643366L, 87340L, 11.0f, 333.15f)
|
||||
.setTimeQualifier(5).setPerlinGen(Blocks.rock.getState(), Blocks.air.getState(), 63)
|
||||
.setBiomeReplacer(Blocks.red_sand.getState())
|
||||
|
@ -630,132 +472,5 @@ public abstract class UniverseRegistry {
|
|||
.setBiomeReplacer(Blocks.ash.getState()).setBiome(Biome.ASHLAND)
|
||||
.addLake(Blocks.lava.getState(), Blocks.rock.getState(), Blocks.rock.getState(),
|
||||
2, 8, 255, false).addLiquid(Blocks.flowing_lava.getState(), 80, 8, 255, true), "hell");
|
||||
|
||||
setPresets();
|
||||
}
|
||||
|
||||
private static Dimension addPreset(String name, String data) {
|
||||
return addPreset(name, "terra", data);
|
||||
}
|
||||
|
||||
private static Dimension addPreset(String name, String base, String data) {
|
||||
Dimension dim = NAME_MAP.get(base).copy();
|
||||
TagObject ptag;
|
||||
try {
|
||||
ptag = TagObject.parse("{" + data + "}");
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
TagObject dtag = dim.writeGenerator();
|
||||
if(ptag.getBool("ClearGenerator")) {
|
||||
ptag.remove("ClearGenerator");
|
||||
dtag.remove("FloorBlock");
|
||||
dtag.remove("CeilingBlock");
|
||||
dtag.remove("Layers");
|
||||
dtag.remove("AddBiomes");
|
||||
dtag.remove("FrostBiomes");
|
||||
dtag.remove("ColdBiomes");
|
||||
dtag.remove("MediumBiomes");
|
||||
dtag.remove("HotBiomes");
|
||||
dtag.remove("Ores");
|
||||
dtag.remove("Lakes");
|
||||
dtag.remove("Liquids");
|
||||
dtag.setString("Generator", GeneratorType.FLAT.getName());
|
||||
dtag.setString("Replacer", ReplacerType.NONE.getName());
|
||||
// dtag.setBoolean("MobGen", false);
|
||||
// dtag.setBoolean("SnowGen", false);
|
||||
dtag.setBool("Caves", false);
|
||||
dtag.setBool("Ravines", false);
|
||||
dtag.setBool("AltCaves", false);
|
||||
dtag.setBool("Strongholds", false);
|
||||
dtag.setBool("Villages", false);
|
||||
dtag.setBool("Mineshafts", false);
|
||||
dtag.setBool("Scattered", false);
|
||||
dtag.setBool("Fortresses", false);
|
||||
dtag.setInt("Dungeons", 0);
|
||||
dtag.setInt("BiomeSize", 0);
|
||||
dtag.setInt("RiverSize", 4);
|
||||
dtag.setInt("SnowRarity", 6);
|
||||
dtag.setInt("SeaRarity", 50);
|
||||
dtag.setInt("AddRarity", 50);
|
||||
dtag.setInt("SeaLevel", 0);
|
||||
dtag.setString("DefaultBiome", Biome.NONE.name.toLowerCase());
|
||||
dtag.setBool("SemiFixed", false);
|
||||
// dtag.setString("DefaultWeather", Weather.CLEAR.getName());
|
||||
dtag.setString("DefaultLeaves", LeavesType.SPRING.getName());
|
||||
Dimension.writeState(dtag, "FillerBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "TopBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "SurfaceBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock1", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "AltBlock2", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "LiquidBlock", Blocks.air.getState());
|
||||
Dimension.writeState(dtag, "CaveFillBlock", Blocks.air.getState());
|
||||
}
|
||||
dtag.merge(ptag);
|
||||
dim.readGenerator(dtag);
|
||||
dim.setCustomName(name);
|
||||
// BASE_DIMS.add(dim);
|
||||
return dim;
|
||||
}
|
||||
|
||||
private static Dimension addFlatPreset(String name, Biome biome, boolean populate, State main, Object ... layers) {
|
||||
return addFlatPreset(name, "terra", biome, populate, main, layers);
|
||||
}
|
||||
|
||||
private static Dimension addFlatPreset(String name, String base, Biome biome, boolean populate, State main, Object ... layers) {
|
||||
Dimension dim = addPreset("Flach - " + name, base, "ClearGenerator:1b" + (populate ? "" : ",NoPopulation:1b"));
|
||||
dim.setBiome(biome);
|
||||
if(main != null)
|
||||
dim.setFlatGen(main, layers);
|
||||
return dim;
|
||||
}
|
||||
|
||||
private static void setPresets()
|
||||
{
|
||||
addPreset("Standard", "");
|
||||
addPreset("Doppelte Höhe (128)", "BaseSize:17.0,Stretch:24.0,ScaleY:80.0,SeaLevel:127");
|
||||
addPreset("Große Biome", "BiomeSize:6");
|
||||
addPreset("Überdreht", "Amplification:2.0");
|
||||
addPreset("Wasserwelt", "ScaleX:5000.0,ScaleY:1000.0,ScaleZ:5000.0,Stretch:8.0,BDepthWeight:2.0,BDepthOffset:0.5,BScaleWeight:2.0,BScaleOffset:0.375,SeaLevel:511");
|
||||
addPreset("Inselland", "CoordScale:3000.0,HeightScale:6000.0,UpperLmtScale:250.0,Stretch:10.0");
|
||||
addPreset("Favorit des Gräbers", "ScaleX:5000.0,ScaleY:1000.0,ScaleZ:5000.0,Stretch:5.0,BDepthWeight:2.0,BDepthOffset:1.0,BScaleWeight:4.0,BScaleOffset:1.0");
|
||||
addPreset("Verrückte Berge", "CoordScale:738.41864,HeightScale:157.69133,UpperLmtScale:801.4267,LowerLmtScale:1254.1643,DepthScaleX:374.93652,DepthScaleZ:288.65228,"
|
||||
+ "ScaleX:1355.9908,ScaleY:745.5343,ScaleZ:1183.464,BaseSize:1.8758626,Stretch:1.7137525,BDepthWeight:1.7553768,BDepthOffset:3.4701107,BScaleOffset:2.535211");
|
||||
addPreset("Trockenheit", "ScaleX:1000.0,ScaleY:3000.0,ScaleZ:1000.0,Stretch:10.0,SeaLevel:20");
|
||||
addPreset("Chaotische Höhlen", "UpperLmtScale:2.0,LowerLmtScale:64.0,SeaLevel:6");
|
||||
addPreset("Viel Glück", "LiquidBlock:lava,SeaLevel:40");
|
||||
|
||||
addFlatPreset("Klassisch", Biome.PLAINS, false, Blocks.dirt.getState(), Blocks.bedrock.getState(), 2, Blocks.dirt.getState(),
|
||||
Blocks.grass.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Abbauwelt", Biome.EXTREMEHILLS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 230, Blocks.stone.getState(),
|
||||
5, Blocks.dirt.getState(), Blocks.grass.getState()).enableStrongholds().enableMineshafts().setDungeons(8);
|
||||
|
||||
addFlatPreset("Wasserwelt", Biome.SEA, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 5, Blocks.stone.getState(),
|
||||
52, Blocks.dirt.getState(), 5, Blocks.sand.getState(), 90, Blocks.water.getState());
|
||||
|
||||
addFlatPreset("Oberfläche", Biome.PLAINS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages().enableStrongholds().enableMineshafts().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);
|
||||
|
||||
addFlatPreset("Verschneites Königreich", Biome.ICEPLAINS, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Verschneites Königreich +", Biome.ICEPLAINS, true, Blocks.stone.getState(), Blocks.bedrock.getState(), 59, Blocks.stone.getState(),
|
||||
3, Blocks.dirt.getState(), Blocks.grass.getState(), Blocks.snow_layer.getState()).setBiomeReplacer(Blocks.gravel.getState()).enableVillages()
|
||||
.addLake(Blocks.water.getState(), null, Blocks.grass.getState(), 4, 0, 255, false);
|
||||
|
||||
addFlatPreset("Unendliche Grube", Biome.PLAINS, false, Blocks.dirt.getState(), 2, Blocks.cobblestone.getState(), 3, Blocks.dirt.getState(), Blocks.grass.getState())
|
||||
.setBiomeReplacer(Blocks.gravel.getState()).enableVillages();
|
||||
|
||||
addFlatPreset("Wüste", Biome.DESERT, false, Blocks.stone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(), 52, Blocks.sandstone.getState())
|
||||
.enableVillages().enableScattered();
|
||||
|
||||
addFlatPreset("Redstonewelt", Biome.DESERT, false, Blocks.sandstone.getState(), Blocks.bedrock.getState(), 3, Blocks.stone.getState(),
|
||||
52, Blocks.sandstone.getState());
|
||||
|
||||
addPreset("Leer", "ClearGenerator:1b");
|
||||
addPreset("Alpha 1.2", "Strongholds:0b,Villages:0b,MineShafts:0b,Scattered:0b,Generator:simple,Replacer:simple,Ravines:0b,SeaLevel:64,AltBlock2:sand");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import common.packet.SPacketBlockAction;
|
|||
import common.packet.SPacketBlockBreakAnim;
|
||||
import common.packet.SPacketBlockChange;
|
||||
import common.packet.SPacketCamera;
|
||||
import common.packet.SPacketCelestials;
|
||||
import common.packet.SPacketCharacterList;
|
||||
import common.packet.SPacketChunkData;
|
||||
import common.packet.SPacketCollectItem;
|
||||
|
@ -141,4 +142,5 @@ public interface IClientPlayer extends NetHandler {
|
|||
void handleDimName(SPacketDimensionName packet);
|
||||
void handleForm(SPacketDisplayForm packet);
|
||||
void handleServerConfig(SPacketServerConfig packet);
|
||||
void handleCelestials(SPacketCelestials packet);
|
||||
}
|
|
@ -71,6 +71,7 @@ import common.packet.SPacketBlockAction;
|
|||
import common.packet.SPacketBlockBreakAnim;
|
||||
import common.packet.SPacketBlockChange;
|
||||
import common.packet.SPacketCamera;
|
||||
import common.packet.SPacketCelestials;
|
||||
import common.packet.SPacketCharacterList;
|
||||
import common.packet.SPacketChunkData;
|
||||
import common.packet.SPacketCollectItem;
|
||||
|
@ -186,6 +187,7 @@ public enum PacketRegistry {
|
|||
this.server(SPacketLoading.class);
|
||||
this.server(SPacketDisplayForm.class);
|
||||
this.server(SPacketServerConfig.class);
|
||||
this.server(SPacketCelestials.class);
|
||||
|
||||
this.client(CPacketKeepAlive.class);
|
||||
this.client(CPacketMessage.class);
|
||||
|
|
49
common/src/main/java/common/packet/SPacketCelestials.java
Normal file
49
common/src/main/java/common/packet/SPacketCelestials.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package common.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import common.dimension.Dimension;
|
||||
import common.network.IClientPlayer;
|
||||
import common.network.Packet;
|
||||
import common.network.PacketBuffer;
|
||||
|
||||
public class SPacketCelestials implements Packet<IClientPlayer> {
|
||||
private int sunColor;
|
||||
private int[] moonColors;
|
||||
|
||||
public SPacketCelestials() {
|
||||
}
|
||||
|
||||
public SPacketCelestials(Dimension dim) {
|
||||
this.sunColor = dim.getSunColor();
|
||||
this.moonColors = dim.getMoonColors();
|
||||
}
|
||||
|
||||
public void processPacket(IClientPlayer handler) {
|
||||
handler.handleCelestials(this);
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.sunColor = buf.readInt();
|
||||
this.moonColors = new int[buf.readVarInt()];
|
||||
for(int z = 0; z < this.moonColors.length; z++) {
|
||||
this.moonColors[z] = buf.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeInt(this.sunColor);
|
||||
buf.writeVarInt(this.moonColors.length);
|
||||
for(int z = 0; z < this.moonColors.length; z++) {
|
||||
buf.writeInt(this.moonColors[z]);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSunColor() {
|
||||
return this.sunColor;
|
||||
}
|
||||
|
||||
public int[] getMoonColors() {
|
||||
return this.moonColors;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import common.tags.TagObject;
|
|||
|
||||
public class SPacketRespawn implements Packet<IClientPlayer> {
|
||||
private int dimId;
|
||||
private long seed;
|
||||
private DimType dimType;
|
||||
private TagObject dimData;
|
||||
private String dimName;
|
||||
|
@ -31,11 +30,9 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
this.dimId = -2;
|
||||
}
|
||||
else {
|
||||
this.seed = dim.getSeed();
|
||||
this.dimData = dim.writeData();
|
||||
if(dim.isCustom()) {
|
||||
this.dimType = dim.getType();
|
||||
this.dimData = new TagObject();
|
||||
dim.toTags(this.dimData);
|
||||
this.dimName = UniverseRegistry.getName(dim);
|
||||
this.dimDisplay = dim.getCustomName();
|
||||
this.dimFull = dim.getFormattedName(true);
|
||||
|
@ -60,10 +57,9 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||
this.dimId = buf.readVarInt();
|
||||
if(this.dimId >= -1)
|
||||
this.seed = buf.readLong();
|
||||
this.dimData = buf.readTag();
|
||||
if(this.dimId == -1) {
|
||||
this.dimType = buf.readEnumValue(DimType.class);
|
||||
this.dimData = buf.readTag();
|
||||
this.dimName = buf.readString(1024);
|
||||
this.dimDisplay = buf.readString(1024);
|
||||
this.dimFull = buf.readString(4096);
|
||||
|
@ -82,10 +78,9 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||
buf.writeVarInt(this.dimId);
|
||||
if(this.dimId >= -1)
|
||||
buf.writeLong(this.seed);
|
||||
buf.writeTag(this.dimData);
|
||||
if(this.dimId == -1) {
|
||||
buf.writeEnumValue(this.dimType);
|
||||
buf.writeTag(this.dimData);
|
||||
buf.writeString(this.dimName);
|
||||
buf.writeString(this.dimDisplay);
|
||||
buf.writeString(this.dimFull);
|
||||
|
@ -105,10 +100,9 @@ public class SPacketRespawn implements Packet<IClientPlayer> {
|
|||
if(this.dimId < -1)
|
||||
return null;
|
||||
Dimension dim = this.dimId >= 0 ? UniverseRegistry.getDimension(this.dimId) : Dimension.create(this.dimType);
|
||||
dim.setSeed(this.seed);
|
||||
dim.readData(this.dimData);
|
||||
if(!dim.isCustom())
|
||||
return dim;
|
||||
dim.fromTags(this.dimData);
|
||||
dim.setCustomName(this.dimDisplay);
|
||||
dim.setDisplayName(this.dimFull);
|
||||
if(this.dimType.celestials) {
|
||||
|
|
|
@ -23,6 +23,7 @@ public abstract class AWorldServer extends World {
|
|||
|
||||
public abstract List<IPlayer> getAllPlayers();
|
||||
public abstract AWorldServer getOtherWorld(Dimension dimension);
|
||||
public abstract Dimension getPortalDest(PortalType portal);
|
||||
public abstract void placeInDimension(Entity entity, AWorldServer oldWorld, AWorldServer world, BlockPos pos, PortalType portal);
|
||||
public abstract boolean addLoader(BlockPos pos);
|
||||
public abstract boolean removeLoader(BlockPos pos);
|
||||
|
|
|
@ -123,7 +123,7 @@ public abstract class World implements IWorldAccess {
|
|||
this.dimension = dim;
|
||||
// this.storage = storage;
|
||||
this.client = client;
|
||||
this.weather = dim.getWeather();
|
||||
this.weather = dim.getCurrentWeather();
|
||||
}
|
||||
|
||||
public void updatePhysics() {
|
||||
|
@ -1972,7 +1972,7 @@ public abstract class World implements IWorldAccess {
|
|||
}
|
||||
|
||||
public void setWeather(Weather weather) {
|
||||
this.weather = weather;
|
||||
this.dimension.setCurrentWeather(this.weather = weather);
|
||||
}
|
||||
|
||||
public void setDayTime(long time) {
|
||||
|
|
|
@ -27,8 +27,17 @@ import common.Version;
|
|||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Area;
|
||||
import common.dimension.DimType;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Domain;
|
||||
import common.dimension.Galaxy;
|
||||
import common.dimension.Moon;
|
||||
import common.dimension.Planet;
|
||||
import common.dimension.Sector;
|
||||
import common.dimension.Semi;
|
||||
import common.dimension.Space;
|
||||
import common.dimension.Star;
|
||||
import common.effect.StatusEffect;
|
||||
import common.entity.Entity;
|
||||
import common.entity.npc.EntityHuman;
|
||||
|
@ -80,6 +89,7 @@ import common.util.ExtMath;
|
|||
import common.util.Pair;
|
||||
import common.util.PortalType;
|
||||
import common.util.Position;
|
||||
import common.util.Triplet;
|
||||
import common.util.Util;
|
||||
import common.util.Var;
|
||||
import common.util.WorldPos;
|
||||
|
@ -90,6 +100,7 @@ import server.clipboard.ReorderRegistry;
|
|||
import server.clipboard.RotationRegistry;
|
||||
import server.command.CommandEnvironment;
|
||||
import server.command.Executor;
|
||||
import server.init.TeleportRegistry;
|
||||
import server.network.HandshakeHandler;
|
||||
import server.network.Player;
|
||||
import server.network.User;
|
||||
|
@ -155,6 +166,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
Registry.register();
|
||||
GenBiome.setAsProvider();
|
||||
UniverseRegistry.register();
|
||||
TeleportRegistry.register();
|
||||
RotationRegistry.register();
|
||||
ReorderRegistry.register();
|
||||
final Server server = new Server();
|
||||
|
@ -169,6 +181,185 @@ public final class Server implements IThreadListener, Executor {
|
|||
Region.killIO();
|
||||
Log.flushLog();
|
||||
}
|
||||
|
||||
private static void readDimensions(TagObject tag) {
|
||||
List<Pair<String, String>> galaxies = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> sectors = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> stars = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> planets = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> moons = Lists.newArrayList();
|
||||
List<Pair<String, String>> semis = Lists.newArrayList();
|
||||
List<Pair<String, String>> domains = Lists.newArrayList();
|
||||
List<Triplet<String, String, String>> areas = Lists.newArrayList();
|
||||
|
||||
List<TagObject> list = tag.getList("Dimensions");
|
||||
for(TagObject data : list) {
|
||||
String name = data.getString("Name");
|
||||
String type = data.getString("Type");
|
||||
String display = data.hasString("CustomName") ? data.getString("CustomName") : name;
|
||||
if(type.equals("galaxy"))
|
||||
galaxies.add(new Pair(name, display));
|
||||
else if(type.equals("sector"))
|
||||
sectors.add(new Triplet(name, display, data.getString("Galaxy")));
|
||||
else if(type.equals("domain"))
|
||||
domains.add(new Pair(name, display));
|
||||
else {
|
||||
DimType dim = DimType.getByName(type);
|
||||
if(dim != null) {
|
||||
switch(dim) {
|
||||
case SEMI:
|
||||
semis.add(new Pair(name, display));
|
||||
break;
|
||||
case AREA:
|
||||
areas.add(new Triplet(name, display, data.getString("Domain")));
|
||||
break;
|
||||
case MOON:
|
||||
moons.add(new Triplet(name, display, data.getString("Planet")));
|
||||
break;
|
||||
case PLANET:
|
||||
planets.add(new Triplet(name, display, data.getString("Star")));
|
||||
break;
|
||||
case STAR:
|
||||
stars.add(new Triplet(name, display, data.getString("Sector")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> galaxy : galaxies) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomGalaxy(galaxy.first(), galaxy.second());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Galaxie %s nicht hinzufügen", galaxy.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> sector : sectors) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomSector(sector.first(), sector.second(), sector.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Sektor %s nicht hinzufügen", sector.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> star : stars) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomStar(star.first(), star.second(), (Star)Dimension.create(DimType.STAR), star.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Stern %s nicht hinzufügen", star.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> planet : planets) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomPlanet(planet.first(), planet.second(), (Planet)Dimension.create(DimType.PLANET), planet.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Planet %s nicht hinzufügen", planet.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> moon : moons) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomMoon(moon.first(), moon.second(), (Moon)Dimension.create(DimType.MOON), moon.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Mond %s nicht hinzufügen", moon.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> semi : semis) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomSemi(semi.first(), semi.second(), (Semi)Dimension.create(DimType.SEMI));
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dimension %s nicht hinzufügen", semi.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Pair<String, String> domain : domains) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomDomain(domain.first(), domain.second());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Bereich %s nicht hinzufügen", domain.first());
|
||||
}
|
||||
}
|
||||
|
||||
for(Triplet<String, String, String> area : areas) {
|
||||
try {
|
||||
UniverseRegistry.registerCustomArea(area.first(), area.second(), (Area)Dimension.create(DimType.AREA), area.third());
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Dimension %s nicht hinzufügen", area.first());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static TagObject writeDimensions() {
|
||||
TagObject tag = new TagObject();
|
||||
|
||||
List<TagObject> list = Lists.newArrayList();
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
if(dim.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", dim.getType().getName());
|
||||
data.setString("Name", UniverseRegistry.getName(dim));
|
||||
data.setString("CustomName", dim.getCustomName());
|
||||
switch(dim.getType()) {
|
||||
case AREA:
|
||||
data.setString("Domain", UniverseRegistry.getDomain((Area)dim).id);
|
||||
break;
|
||||
case MOON:
|
||||
data.setString("Planet", UniverseRegistry.getName(UniverseRegistry.getPlanet((Moon)dim)));
|
||||
break;
|
||||
case PLANET:
|
||||
data.setString("Star", UniverseRegistry.getName(UniverseRegistry.getStar((Planet)dim)));
|
||||
break;
|
||||
case STAR:
|
||||
data.setString("Sector", UniverseRegistry.getSector((Star)dim).id);
|
||||
break;
|
||||
}
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Sector sector : UniverseRegistry.getSectors()) {
|
||||
if(sector.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "sector");
|
||||
data.setString("Name", sector.id);
|
||||
data.setString("CustomName", sector.getCustomName());
|
||||
data.setString("Galaxy", UniverseRegistry.getGalaxy(sector).id);
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Galaxy galaxy : UniverseRegistry.getGalaxies()) {
|
||||
if(galaxy.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "galaxy");
|
||||
data.setString("Name", galaxy.id);
|
||||
data.setString("CustomName", galaxy.getCustomName());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
for(Domain domain : UniverseRegistry.getDomains()) {
|
||||
if(domain.isCustom()) {
|
||||
TagObject data = new TagObject();
|
||||
data.setString("Type", "domain");
|
||||
data.setString("Name", domain.id);
|
||||
data.setString("CustomName", domain.getCustomName());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
tag.setList("Dimensions", list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
|
||||
private void saveServerConfig(long time) {
|
||||
TagObject data = new TagObject();
|
||||
|
@ -182,7 +373,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
cfg.setString(cvar, value.get());
|
||||
}
|
||||
data.setObject("Config", cfg);
|
||||
data.setObject("Universe", UniverseRegistry.toTags());
|
||||
data.setObject("Universe", writeDimensions());
|
||||
if(this.keyPair != null) {
|
||||
data.setByteArray("PrivateKey", this.keyPair.getPrivate().getEncoded());
|
||||
data.setByteArray("PublicKey", this.keyPair.getPublic().getEncoded());
|
||||
|
@ -213,7 +404,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
if(svar != null)
|
||||
svar.set(cfg.getString(key), false, false);
|
||||
}
|
||||
UniverseRegistry.fromTags(tag.getObject("Universe"));
|
||||
readDimensions(tag.getObject("Universe"));
|
||||
long lastPlayed = tag.getLong("LastAccess");
|
||||
String version = tag.hasString("Version") ? tag.getString("Version") : null;
|
||||
version = version != null && version.isEmpty() ? "<unbekannt>" : version;
|
||||
|
@ -239,6 +430,34 @@ public final class Server implements IThreadListener, Executor {
|
|||
Log.IO.info("Erstelle neue Welt und Konfiguration");
|
||||
return World.START_TIME;
|
||||
}
|
||||
|
||||
private void loadDimension(Dimension dim) {
|
||||
File file = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "data.cdt");
|
||||
TagObject tag = null;
|
||||
if(file.exists()) {
|
||||
try {
|
||||
tag = TagObject.readGZip(file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten %s nicht laden", file);
|
||||
}
|
||||
}
|
||||
dim.readData(tag == null ? new TagObject() : tag);
|
||||
if(tag == null || !tag.hasLong("Seed"))
|
||||
Log.TICK.info("Startwert für %s: %d" + (Vars.seed.isEmpty() ? "" : " von Basiswert '%s'"), dim.getFormattedName(false), dim.getSeed(), Vars.seed);
|
||||
}
|
||||
|
||||
private void saveDimension(Dimension dim) {
|
||||
TagObject tag = dim.writeData();
|
||||
File file = new File(new File(new File("chunk"), UniverseRegistry.getName(dim)), "data.cdt");
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
TagObject.writeGZip(tag, file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten %s nicht speichern", file);
|
||||
}
|
||||
}
|
||||
|
||||
private void setCallback(Runnable callback, String ... vars) {
|
||||
for(String key : vars) {
|
||||
|
@ -306,6 +525,9 @@ public final class Server implements IThreadListener, Executor {
|
|||
|
||||
public void saveWorldInfo() {
|
||||
this.saveServerConfig(this.space.getDayTime());
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
this.saveDimension(dim);
|
||||
}
|
||||
WorldServer.saveWarps(this.warps);
|
||||
}
|
||||
|
||||
|
@ -383,6 +605,9 @@ public final class Server implements IThreadListener, Executor {
|
|||
public void run(long time) {
|
||||
Region.loadMap();
|
||||
long wtime = this.loadServerConfig();
|
||||
for(Dimension dim : UniverseRegistry.getDimensions()) {
|
||||
this.loadDimension(dim);
|
||||
}
|
||||
if(this.keyPair == null) {
|
||||
Log.SYSTEM.info("Generiere neues Schlüsselpaar");
|
||||
this.keyPair = EncryptUtil.createKeypair();
|
||||
|
|
|
@ -7,9 +7,15 @@ import common.biome.Biome;
|
|||
import common.collect.Iterables;
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
import common.dimension.Area;
|
||||
import common.dimension.DimType;
|
||||
import common.dimension.Dimension;
|
||||
import common.dimension.Planet;
|
||||
import common.dimension.Star;
|
||||
import common.init.Blocks;
|
||||
import common.init.NameRegistry;
|
||||
import common.init.UniverseRegistry;
|
||||
import common.rng.Random;
|
||||
import server.command.ArgumentParser;
|
||||
import server.command.Command;
|
||||
import server.command.CommandEnvironment;
|
||||
|
@ -23,6 +29,53 @@ 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,
|
||||
float offset, float gravity, float temperature, int brightness) {
|
||||
star = star == null ? UniverseRegistry.getName(new Random().pick(Lists.newArrayList(UniverseRegistry.getStars()))) : star;
|
||||
if(!UniverseRegistry.isDimension(star) || UniverseRegistry.getDimension(star).getType() != DimType.STAR || UniverseRegistry.isRegistered(name))
|
||||
return null;
|
||||
Planet dim = new Planet(sky, fog, clouds, orbit, rotation, offset, gravity, temperature, brightness);
|
||||
dim.setTimeQualifier(3);
|
||||
return UniverseRegistry.registerCustomPlanet(name, custom, dim, star);
|
||||
}
|
||||
|
||||
public static void registerPreset(Dimension preset) {
|
||||
Random rand = new Random();
|
||||
String pname;
|
||||
do {
|
||||
pname = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(UniverseRegistry.isRegistered(pname.toLowerCase()));
|
||||
if(preset.getType() == DimType.PLANET) {
|
||||
String galaxy;
|
||||
do {
|
||||
galaxy = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(UniverseRegistry.isRegistered(galaxy.toLowerCase()));
|
||||
String sector;
|
||||
do {
|
||||
sector = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(UniverseRegistry.isRegistered(sector.toLowerCase()));
|
||||
String sname;
|
||||
do {
|
||||
sname = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(UniverseRegistry.isRegistered(sname.toLowerCase()));
|
||||
Star star = new Star(0xff0000 | (rand.range(0x60, 0xa0) << 8),
|
||||
rand.frange(200.0f, 400.0f), rand.frange(5000.0f, 7000.0f),
|
||||
rand.pick(Blocks.lava.getState(), Blocks.magma.getState()), rand.range(64, 212));
|
||||
UniverseRegistry.registerCustomGalaxy(galaxy.toLowerCase(), galaxy);
|
||||
UniverseRegistry.registerCustomSector(sector.toLowerCase(), sector, galaxy.toLowerCase());
|
||||
UniverseRegistry.registerCustomStar(sname.toLowerCase(), sname, star, galaxy.toLowerCase());
|
||||
UniverseRegistry.registerCustomPlanet(pname.toLowerCase(), pname, (Planet)preset, sname.toLowerCase());
|
||||
}
|
||||
else if(preset.getType() == DimType.AREA) {
|
||||
String domain;
|
||||
do {
|
||||
domain = NameRegistry.FANTASY.generate(rand, rand.range(2, 5));
|
||||
} while(UniverseRegistry.isRegistered(domain.toLowerCase()));
|
||||
UniverseRegistry.registerCustomDomain(domain.toLowerCase(), domain);
|
||||
UniverseRegistry.registerCustomArea(pname.toLowerCase(), pname, (Area)preset, domain.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public CommandLoad() {
|
||||
super("load");
|
||||
|
||||
|
@ -69,7 +122,7 @@ public class CommandLoad extends Command {
|
|||
}
|
||||
this.loadingDim = name;
|
||||
if(Converter.convert(dir, name, pos -> env.getServer().schedule(() -> {
|
||||
Planet planet = UniverseRegistry.registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
|
||||
Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
|
||||
planet.setBiome(biome);
|
||||
this.loadingDim = null;
|
||||
exec.log(TextColor.GREEN + "Welt %s wurde erfolgreich in Dimension '%s' konvertiert", dir, display);
|
||||
|
@ -87,7 +140,7 @@ public class CommandLoad extends Command {
|
|||
}
|
||||
return;
|
||||
}
|
||||
Planet planet = UniverseRegistry.registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
|
||||
Planet planet = registerPlanet(star, name, display, sky, fog, clouds, orbit, rotation, (float)offset, (float)gravity, (float)temperature, brightness);
|
||||
planet.setBiome(biome);
|
||||
exec.log(TextColor.GREEN + "Dimension '%s' wurde registriert", display);
|
||||
if(teleport && ((Player)exec).getPresentEntity() != null)
|
||||
|
|
29
server/src/main/java/server/init/TeleportRegistry.java
Normal file
29
server/src/main/java/server/init/TeleportRegistry.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
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 {
|
||||
private static final Map<Integer, Integer> PORTALS = Maps.newHashMap();
|
||||
|
||||
public static Dimension getPortalDest(Dimension src, PortalType portal) {
|
||||
return PORTALS.containsKey((portal.ordinal() << 20) | UniverseRegistry.getId(src)) ? UniverseRegistry.getDimension(PORTALS.get((portal.ordinal() << 20) | UniverseRegistry.getId(src))) :
|
||||
(PORTALS.containsKey(portal.ordinal() | 0x7ff00000) ? UniverseRegistry.getDimension(PORTALS.get(portal.ordinal() | 0x7ff00000)) : src);
|
||||
}
|
||||
|
||||
|
||||
private static void registerPortal(PortalType portal, String src, String dest) {
|
||||
PORTALS.put((portal.ordinal() << 20) | UniverseRegistry.getId(UniverseRegistry.getDimension(src)), UniverseRegistry.getId(UniverseRegistry.getDimension(dest)));
|
||||
}
|
||||
|
||||
private static void registerPortal(PortalType portal, String dest) {
|
||||
PORTALS.put(portal.ordinal() | 0x7ff00000, UniverseRegistry.getId(UniverseRegistry.getDimension(dest)));
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
|
||||
}
|
||||
}
|
|
@ -52,6 +52,7 @@ import common.packet.SPacketBiome;
|
|||
import common.packet.SPacketBlockAction;
|
||||
import common.packet.SPacketBlockBreakAnim;
|
||||
import common.packet.SPacketBlockChange;
|
||||
import common.packet.SPacketCelestials;
|
||||
import common.packet.SPacketMultiBlockChange;
|
||||
import common.rng.Random;
|
||||
import common.rng.WeightedList;
|
||||
|
@ -80,6 +81,7 @@ import server.Server;
|
|||
import server.biome.GenBiome;
|
||||
import server.biome.RngSpawn;
|
||||
import server.clipboard.ClipboardBlock;
|
||||
import server.init.TeleportRegistry;
|
||||
import server.network.Player;
|
||||
import server.vars.SVars;
|
||||
import server.village.VillageCollection;
|
||||
|
@ -169,10 +171,7 @@ public final class WorldServer extends AWorldServer {
|
|||
private boolean populate;
|
||||
|
||||
private boolean updateForced;
|
||||
// private boolean resetWeather;
|
||||
private boolean loadersModified;
|
||||
// private boolean warpsModified;
|
||||
private boolean exterminated;
|
||||
private int emptyTicks;
|
||||
private int blockEvtIdx;
|
||||
private int trackDistance;
|
||||
|
@ -318,47 +317,20 @@ public final class WorldServer extends AWorldServer {
|
|||
this.updateViewRadius();
|
||||
this.chunkDir = new File(new File("chunk"), UniverseRegistry.getName(dim));
|
||||
this.chunkDir.mkdirs();
|
||||
if(!Vars.seed.isEmpty())
|
||||
this.rand.setSeed((long)Vars.seed.hashCode() ^ ~((long)UniverseRegistry.getName(dim).hashCode()));
|
||||
this.seed = this.rand.longv();
|
||||
this.dimension.setSeed(this.seed);
|
||||
TagObject tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "data.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
tag = TagObject.readGZip(dat);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht laden");
|
||||
}
|
||||
if(tag != null) {
|
||||
this.exterminated = tag.getBool("Exterminated");
|
||||
this.time = tag.getLong("Time");
|
||||
if(tag.hasObject("Generator")) {
|
||||
this.dimension.readGenerator(tag.getObject("Generator"));
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = this.dimension.getWeather();
|
||||
this.seed = this.dimension.getSeed();
|
||||
}
|
||||
if(this.dimension.getType().weather && !this.exterminated)
|
||||
this.weather = Weather.getByName(tag.getString("Weather"));
|
||||
if(this.weather == null) {
|
||||
this.weather = this.dimension.getWeather();
|
||||
// this.dataModified = true;
|
||||
}
|
||||
// ...
|
||||
}
|
||||
else {
|
||||
Log.TICK.info("Startwert für %s: %d" + (Vars.seed.isEmpty() ? "" : " von Basiswert '%s'"), this.dimension.getFormattedName(false), this.seed, Vars.seed);
|
||||
}
|
||||
if(this.exterminated)
|
||||
this.weather = Weather.CLEAR;
|
||||
|
||||
this.seed = this.dimension.getSeed();
|
||||
this.time = this.dimension.getTimeExisted();
|
||||
|
||||
this.grng = new Random(this.seed);
|
||||
this.initGenerator(this.exterminated);
|
||||
this.initGenerator(this.dimension.isExterminated());
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
this.updatePhysics();
|
||||
tag = null;
|
||||
this.loadLoaderList();
|
||||
}
|
||||
|
||||
private void loadLoaderList() {
|
||||
TagObject tag = null;
|
||||
try {
|
||||
File dat = new File(this.chunkDir, "loaders.cdt");
|
||||
if(dat.exists() && dat.isFile())
|
||||
|
@ -375,7 +347,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
this.loadersModified = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return this.server;
|
||||
|
@ -408,7 +380,7 @@ public final class WorldServer extends AWorldServer {
|
|||
this.setSkylightSubtracted(light);
|
||||
// if(this.primary)
|
||||
// this.info.tick();
|
||||
this.time += 1L;
|
||||
this.dimension.setTimeExisted(this.time += 1L);
|
||||
// this.dataModified = true;
|
||||
if(Vars.dayCycle) // {
|
||||
this.daytime += Vars.timeFlow;
|
||||
|
@ -894,9 +866,6 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public void saveAllChunks() {
|
||||
// if(this.primary) {
|
||||
//
|
||||
// }
|
||||
if(this.loadersModified) {
|
||||
this.loadersModified = false;
|
||||
TagObject loaders = new TagObject();
|
||||
|
@ -922,26 +891,6 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
}
|
||||
// if(this.warpsModified) {
|
||||
// this.warpsModified = false;
|
||||
// }
|
||||
// if(this.dataModified) {
|
||||
// this.dataModified = false;
|
||||
TagObject data = new TagObject();
|
||||
// data.setLong("Seed", this.seed);
|
||||
data.setObject("Generator", this.dimension.writeGenerator());
|
||||
data.setLong("Time", this.time);
|
||||
data.setBool("Exterminated", this.exterminated);
|
||||
data.setString("Weather", this.weather.getName());
|
||||
// ...
|
||||
File file = new File(this.chunkDir, "data.cdt");
|
||||
try {
|
||||
TagObject.writeGZip(data, file);
|
||||
}
|
||||
catch(Exception e) {
|
||||
Log.IO.error(e, "Konnte Weltdaten nicht speichern");
|
||||
}
|
||||
// }
|
||||
for(int i = 0; i < this.dataList.size(); ++i) {
|
||||
WorldSavedData wdata = this.dataList.get(i);
|
||||
if(wdata.dirty) {
|
||||
|
@ -1083,8 +1032,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public void setWeather(Weather weather) {
|
||||
this.weather = weather;
|
||||
// this.dataModified = true;
|
||||
super.setWeather(weather);
|
||||
this.sendPacket(new SPacketChangeGameState(SPacketChangeGameState.Action.SET_WEATHER,
|
||||
weather.ordinal()));
|
||||
}
|
||||
|
@ -1107,7 +1055,7 @@ public final class WorldServer extends AWorldServer {
|
|||
// }
|
||||
// }
|
||||
|
||||
if((this.dimension.getType().weather && !this.exterminated) || force) {
|
||||
if((this.dimension.getType().weather && !this.dimension.isExterminated()) || force) {
|
||||
float prevDarkness = this.darkness;
|
||||
float prevRain = this.rain;
|
||||
float prevFog = this.fog;
|
||||
|
@ -1169,7 +1117,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
if((this.dimension.getType().days || (this.dimension.getType().weather && !this.exterminated)) || force) {
|
||||
if((this.dimension.getType().days || (this.dimension.getType().weather && !this.dimension.isExterminated())) || force) {
|
||||
float prevTemp = this.temp;
|
||||
|
||||
float temp = this.getBaseTemperature() + this.weather.getTemperature();
|
||||
|
@ -1516,11 +1464,11 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public boolean isExterminated() {
|
||||
return this.exterminated;
|
||||
return this.dimension.isExterminated();
|
||||
}
|
||||
|
||||
public boolean exterminate() {
|
||||
if(this.exterminated)
|
||||
if(this.dimension.isExterminated())
|
||||
return false;
|
||||
this.resetData(true);
|
||||
this.reloadChunks();
|
||||
|
@ -1537,7 +1485,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
private void resetData(boolean exterminated) {
|
||||
this.setWeather(exterminated ? Weather.CLEAR : this.dimension.getWeather());
|
||||
this.setWeather(exterminated ? Weather.CLEAR : this.dimension.getDefaultWeather());
|
||||
this.resetWeather();
|
||||
if(!this.loaderList.isEmpty())
|
||||
this.loadersModified = true;
|
||||
|
@ -1556,9 +1504,15 @@ public final class WorldServer extends AWorldServer {
|
|||
return file.isDirectory() || !file.getName().equals("data.cdt");
|
||||
}
|
||||
}));
|
||||
this.exterminated = exterminated;
|
||||
boolean updated = this.dimension.isExterminated() != exterminated;
|
||||
this.dimension.setExterminated(exterminated);
|
||||
this.initGenerator(exterminated);
|
||||
this.reloadChunks();
|
||||
if(updated)
|
||||
for(Player player : this.server.getPlayers()) {
|
||||
if(player.getEntity() != null)
|
||||
player.sendPacket(new SPacketCelestials(player.getEntity().worldObj.dimension));
|
||||
}
|
||||
}
|
||||
|
||||
private void insertChunk(int x, int z) {
|
||||
|
@ -1792,7 +1746,7 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
|
||||
public void setBiome(BlockPos pos, Biome biome) {
|
||||
if(this.exterminated)
|
||||
if(this.dimension.isExterminated())
|
||||
return;
|
||||
ChunkServer chunk = this.getChunk(pos);
|
||||
if(chunk == null || !chunk.isLoaded())
|
||||
|
@ -2654,6 +2608,10 @@ public final class WorldServer extends AWorldServer {
|
|||
return this.server.getWorld(dimension);
|
||||
}
|
||||
|
||||
public Dimension getPortalDest(PortalType portal) {
|
||||
return TeleportRegistry.getPortalDest(this.dimension, portal);
|
||||
}
|
||||
|
||||
public void markChunkDirty(BlockPos pos) {
|
||||
if(this.isBlockLoaded(pos))
|
||||
this.getChunk(pos).setModified(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue