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 |
Loading…
Add table
Add a link
Reference in a new issue