diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 60578606..630f89e9 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -486,6 +486,10 @@ public class Client implements IThreadListener { public int downfallRange = 4; @Variable(name = "draw_rain_particle_range", category = CVarCategory.RENDER, min = 0, max = 25, display = "Regen-Partikel-Radius") public int rainParticleRange = 10; + @Variable(name = "draw_void_particles", category = CVarCategory.RENDER, display = "Partikel in der Tiefe") + public boolean voidParticles = true; + @Variable(name = "draw_void_fog", category = CVarCategory.RENDER, display = "Nebel in der Tiefe") + public boolean voidFog = true; @Variable(name = "crosshair_size", category = CVarCategory.GUI, min = 0, max = 32, display = "Größe des Fadenkreuzes") private int crosshairSize = 6; @Variable(name = "crosshair_color_notarget", type = IntType.COLOR, category = CVarCategory.GUI, display = "Fadenkreuz-Farbe (ohne Ziel)") @@ -1733,7 +1737,7 @@ public class Client implements IThreadListener { lline = "Licht: " + chunk.getLightSub(blockpos, 0) + " (" + chunk.getLight(LightType.SKY, blockpos) + " Himmel, " + chunk.getLight(LightType.BLOCK, blockpos) + " Blöcke, " + String.format( "%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt), A: " - + String.format("%.3f", this.world.getCelestialAngle(1.0f)); + + String.format("%.3f °", this.world.getCelestialAngle(1.0f)); } else { bline = "Biom: , D: " + @@ -1741,7 +1745,7 @@ public class Client implements IThreadListener { " (" + (this.dimensionName == null ? UniverseRegistry.getName(this.world.dimension) : this.dimensionName) + ")"; lline = "Licht: " + String.format( "%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt, A: " - + String.format("%.3f", this.world.getCelestialAngle(1.0f)); + + String.format("%.3f °", this.world.getCelestialAngle(1.0f)); } float temp = Math.max(this.world.getTempOffset() + (biome != null ? biome.getTemperature(blockpos) : 0.0f), 0.0f); @@ -1778,7 +1782,7 @@ public class Client implements IThreadListener { this.world.dimension.getOrbitalPeriod() ) + "\n" + String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)", - !this.world.dimension.getType().days ? "*" : "", + !this.world.dimension.hasSeasons() ? "*" : "", this.world.getLeavesGen(blockpos).getDisplayName(), temp, World.ABSOLUTE_ZERO + temp, this.world.getWeather().getDisplay(), this.world.getRainStrength(), diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index ec7bf381..ebdd80c6 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -31,6 +31,7 @@ import common.block.tech.BlockChest; import common.block.tech.BlockDispenser; import common.block.tech.BlockFurnace; import common.block.tech.BlockWorkbench; +import common.dimension.DimType; import common.dimension.Dimension; import common.dimension.Space; import common.effect.StatusEffect; @@ -761,7 +762,7 @@ public class ClientPlayer implements IClientPlayer chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes()); this.world.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); - if (!packetIn.hasBiomes() || this.world.dimension.hasNoLight()) // TODO: check + if (!packetIn.hasBiomes() || !this.world.dimension.hasSkyLight()) // TODO: check { chunk.resetRelight(); } @@ -1401,7 +1402,7 @@ public class ClientPlayer implements IClientPlayer chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true); this.world.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15); - if (this.world.dimension.hasNoLight()) // TODO: check + if (!this.world.dimension.hasSkyLight()) // TODO: check { chunk.resetRelight(); } @@ -1900,7 +1901,7 @@ public class ClientPlayer implements IClientPlayer public void handleCelestials(SPacketCelestials packet) { NetHandler.checkThread(packet, this, this.gm, this.world); this.world.setExterminated(packet.getExterminated()); - if(this.world.dimension.getType().celestials) { + if(this.world.dimension.getType() == DimType.PLANET || this.world.dimension.getType() == DimType.MOON) { this.world.dimension.setSunColor(packet.getSunColor()); this.world.dimension.setMoonColors(packet.getMoonColors()); } diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 2301eabc..38a3c592 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -764,7 +764,7 @@ public class EntityRenderer { if (world.dimension.getLightColor() != 0xffffffff) { Vec3 lightColor = new Vec3(world.dimension.getLightColor()); - float light = world.dimension.hasNoLight() ? 1.0f : sky; + float light = world.dimension.hasSkyLight() ? sky : 1.0f; sred = (float)lightColor.xCoord * light; sgreen = (float)lightColor.yCoord * light; sblue = (float)lightColor.zCoord * light; @@ -780,7 +780,7 @@ public class EntityRenderer { float intens = (float)world.getLastLightning() - partialTicks; if(intens > 1.0F) intens = 1.0F; - float light = world.dimension.hasNoLight() ? 1.0f : rsky; + float light = world.dimension.hasSkyLight() ? rsky : 1.0f; sred = sred * (1.0F - intens) + (float)lightColor.xCoord * light * intens; sgreen = sgreen * (1.0F - intens) + (float)lightColor.yCoord * light * intens; sblue = sblue * (1.0F - intens) + (float)lightColor.zCoord * light * intens; @@ -1089,7 +1089,7 @@ public class EntityRenderer { this.setupFog(0, partialTicks); // renderGlobalIn.renderClouds(partialTicks); float alpha = 0.8F * (1.0f - this.gm.world.getSpaceFactor()); - if(this.gm.world.dimension.getType().clouds && alpha > 0.5f) + if(this.gm.world.dimension.hasWeather() && alpha > 0.5f) renderGlobalIn.renderClouds(alpha, partialTicks); GlState.disableFog(); GL11.glPopMatrix(); @@ -1334,32 +1334,40 @@ public class EntityRenderer { { WorldClient world = this.gm.world; Entity entity = this.gm.getRenderViewEntity(); - float dist = 0.25F + 0.75F * (float)this.gm.renderDistance / 32.0F; - dist = 1.0F - (float)Math.pow((double)dist, 0.25D); - Vec3 sky = world.getSkyColor(this.gm.getRenderViewEntity(), partial); - float sr = (float)sky.xCoord; - float sg = (float)sky.yCoord; - float sb = (float)sky.zCoord; - Vec3 fog = world.getFogColor(this.gm.getRenderViewEntity(), partial); + + Vec3 fog = new Vec3(world.dimension.getFogColor()); this.fogColorRed = (float)fog.xCoord; this.fogColorGreen = (float)fog.yCoord; this.fogColorBlue = (float)fog.zCoord; + + if(world.dimension.isExterminated()) { + this.fogColorRed = 0.188f; + this.fogColorGreen = 0.188f; + this.fogColorBlue = 0.188f; + } + + if(world.dimension.hasDaylight()) { + float sun = ExtMath.clampf(ExtMath.cos(world.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F); + this.fogColorRed = this.fogColorRed * (sun * 0.94F + 0.06F); + this.fogColorGreen = this.fogColorGreen * (sun * 0.94F + 0.06F); + this.fogColorBlue = this.fogColorBlue * (sun * 0.91F + 0.09F); + } - if (this.gm.renderDistance >= 4) + float space = world.getSpaceFactor(); + if(space > 0.0f) { + this.fogColorRed = this.fogColorRed * (1.0F - space); + this.fogColorGreen = this.fogColorGreen * (1.0F - space); + this.fogColorBlue = this.fogColorBlue * (1.0F - space); + } + + if (this.gm.renderDistance >= 4 && world.dimension.hasDaylight() && !world.dimension.isBaseDestroyed()) { double neg = -1.0D; - Vec3 pos = ExtMath.sin(world.getCelestialAngleRadians(partial)) > 0.0F ? new Vec3(neg, 0.0D, 0.0D) : new Vec3(1.0D, 0.0D, 0.0D); + Vec3 pos = ExtMath.sin(world.getDayPhase(partial)) > 0.0F ? new Vec3(neg, 0.0D, 0.0D) : new Vec3(1.0D, 0.0D, 0.0D); float shift = (float)entity.getLook(partial).dotProduct(pos); - - if (shift < 0.0F) - { - shift = 0.0F; - } - if (shift > 0.0F) { - float[] sun = world.dimension.getType().days && !world.dimension.isBaseDestroyed() ? - RenderGlobal.calcSunriseSunsetColors(world.getCelestialAngleRadians(partial), partial) : null; + float[] sun = RenderGlobal.calcSunriseSunsetColors(world.getDayPhase(partial), partial); if (sun != null) { shift = shift * sun[3]; @@ -1370,11 +1378,14 @@ public class EntityRenderer { } } - this.fogColorRed += (sr - this.fogColorRed) * dist; - this.fogColorGreen += (sg - this.fogColorGreen) * dist; - this.fogColorBlue += (sb - this.fogColorBlue) * dist; + float dist = 0.25F + 0.75F * (float)this.gm.renderDistance / 32.0F; + dist = 1.0F - (float)Math.pow((double)dist, 0.25D); + Vec3 sky = world.getSkyColor(this.gm.getRenderViewEntity(), partial); + this.fogColorRed += ((float)sky.xCoord - this.fogColorRed) * dist; + this.fogColorGreen += ((float)sky.yCoord - this.fogColorGreen) * dist; + this.fogColorBlue += ((float)sky.zCoord - this.fogColorBlue) * dist; + float rain = world.getRainStrength(); - if (rain > 0.0F) { float rg = 1.0F - rain * 0.5F; @@ -1385,7 +1396,6 @@ public class EntityRenderer { } float dark = world.getDarkness(); - if (dark > 0.0F) { float mul = 1.0F - dark * 0.5F; @@ -1395,27 +1405,11 @@ public class EntityRenderer { } Block block = MatrixState.getLookedBlock(this.gm.world, entity, partial); - -// if (this.cloudFog) -// { -// Vec3 cloud = world.getCloudColour(this.gm.getRenderViewEntity(), partial); -// this.fogColorRed = (float)cloud.xCoord; -// this.fogColorGreen = (float)cloud.yCoord; -// this.fogColorBlue = (float)cloud.zCoord; -// } -// else if (block.getMaterial().isColdLiquid()) { - float cn = 0.4f; // (float)EnchantmentHelper.getRespiration(entity) * 0.2F; - -// if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).hasEffect(Potion.waterBreathing)) -// { -// f12 = f12 * 0.3F + 0.6F; -// } - - this.fogColorRed = 0.02F + cn; - this.fogColorGreen = 0.02F + cn; - this.fogColorBlue = 0.2F + cn; + this.fogColorRed = 0.42F; + this.fogColorGreen = 0.42F; + this.fogColorBlue = 0.6F; } else if (block.getMaterial().isHotLiquid()) { @@ -1428,73 +1422,45 @@ public class EntityRenderer { this.fogColorRed *= mult; this.fogColorGreen *= mult; this.fogColorBlue *= mult; - double vfog = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial); // * world.dimension.getVoidFogYFactor(); - - if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Effect.BLINDNESS)) + + double vision = 1.0; + if(world.dimension.hasVoidFog() && this.gm.voidFog) { + double y = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partial); + if(y < 0.0) + vision += y / 64.0; + } + if (entity instanceof EntityLiving living && living.hasEffect(Effect.BLINDNESS)) { - int blind = ((EntityLiving)entity).getEffect(Effect.BLINDNESS).getRemaining(); + int blind = living.getEffect(Effect.BLINDNESS).getRemaining(); if (blind < 20) - { - vfog *= (double)(1.0F - (float)blind / 20.0F); - } + vision *= (double)(1.0F - (float)blind / 20.0F); else - { - vfog = 0.0D; - } + vision = 0.0D; + } + if (vision < 1.0D) + { + if (vision < 0.0D) + vision = 0.0D; + vision = vision * vision; + this.fogColorRed = (float)((double)this.fogColorRed * vision); + this.fogColorGreen = (float)((double)this.fogColorGreen * vision); + this.fogColorBlue = (float)((double)this.fogColorBlue * vision); } - if (vfog < 1.0D) + if (entity instanceof EntityLiving living && living.hasEffect(Effect.NIGHT_VISION)) { - if (vfog < 0.0D) - { - vfog = 0.0D; - } - - vfog = vfog * vfog; - this.fogColorRed = (float)((double)this.fogColorRed * vfog); - this.fogColorGreen = (float)((double)this.fogColorGreen * vfog); - this.fogColorBlue = (float)((double)this.fogColorBlue * vfog); - } - -// if (this.bossColorModifier > 0.0F) -// { -// float shift = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * partial; -// this.fogColorRed = this.fogColorRed * (1.0F - shift) + this.fogColorRed * 0.7F * shift; -// this.fogColorGreen = this.fogColorGreen * (1.0F - shift) + this.fogColorGreen * 0.6F * shift; -// this.fogColorBlue = this.fogColorBlue * (1.0F - shift) + this.fogColorBlue * 0.6F * shift; -// } - - if (entity instanceof EntityLiving && ((EntityLiving)entity).hasEffect(Effect.NIGHT_VISION)) - { - float vis = this.getNightVisionBrightness((EntityLiving)entity, partial); + float vis = this.getNightVisionBrightness(living, partial); float mul = 1.0F / this.fogColorRed; - if (mul > 1.0F / this.fogColorGreen) - { mul = 1.0F / this.fogColorGreen; - } - if (mul > 1.0F / this.fogColorBlue) - { mul = 1.0F / this.fogColorBlue; - } - this.fogColorRed = this.fogColorRed * (1.0F - vis) + this.fogColorRed * mul * vis; this.fogColorGreen = this.fogColorGreen * (1.0F - vis) + this.fogColorGreen * mul * vis; this.fogColorBlue = this.fogColorBlue * (1.0F - vis) + this.fogColorBlue * mul * vis; } -// if (this.gm.anaglyph) -// { -// float f16 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F; -// float f17 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F; -// float f7 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F; -// this.fogColorRed = f16; -// this.fogColorGreen = f17; -// this.fogColorBlue = f7; -// } - GlState.clearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F); } diff --git a/client/src/main/java/client/renderer/RegionRenderCache.java b/client/src/main/java/client/renderer/RegionRenderCache.java index e8741451..b29b7f08 100755 --- a/client/src/main/java/client/renderer/RegionRenderCache.java +++ b/client/src/main/java/client/renderer/RegionRenderCache.java @@ -146,7 +146,7 @@ public class RegionRenderCache implements IWorldAccess private int getLightForExt(LightType p_175629_1_, BlockPos pos) { - if (p_175629_1_ == LightType.SKY && this.world.dimension.hasNoLight()) + if (p_175629_1_ == LightType.SKY && !this.world.dimension.hasSkyLight()) { return 0; } diff --git a/client/src/main/java/client/renderer/RenderGlobal.java b/client/src/main/java/client/renderer/RenderGlobal.java index d3f0c5d5..d4ece181 100755 --- a/client/src/main/java/client/renderer/RenderGlobal.java +++ b/client/src/main/java/client/renderer/RenderGlobal.java @@ -1137,7 +1137,7 @@ public class RenderGlobal { this.renderSkyBox(this.gm.world.dimension.getSkyBoxTexture()); } - else if (this.gm.world.dimension.getType().sky) + else if (this.gm.world.dimension.hasSky()) { GlState.disableTexture2D(); Vec3 vec3 = this.theWorld.getSkyColor(this.gm.getRenderViewEntity(), partialTicks); @@ -1183,15 +1183,15 @@ public class RenderGlobal GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); ItemRenderer.disableStandardItemLighting(); - float[] afloat = this.theWorld.dimension.getType().days && !this.theWorld.dimension.isBaseDestroyed() ? - RenderGlobal.calcSunriseSunsetColors(this.theWorld.getCelestialAngleRadians(partialTicks), partialTicks) : null; + float[] afloat = this.theWorld.dimension.hasDaylight() && !this.theWorld.dimension.isBaseDestroyed() ? + RenderGlobal.calcSunriseSunsetColors(this.theWorld.getDayPhase(partialTicks), partialTicks) : null; if (afloat != null) { GlState.disableTexture2D(); GlState.shadeModel(GL11.GL_SMOOTH); GL11.glPushMatrix(); GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(ExtMath.sin(this.theWorld.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(ExtMath.sin(this.theWorld.getDayPhase(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F); float f6 = afloat[0]; float f7 = afloat[1]; @@ -1229,8 +1229,8 @@ public class RenderGlobal GL11.glPushMatrix(); float f16 = 1.0F - Math.max(this.theWorld.getRainStrength(), this.theWorld.getFogStrength()); GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(this.theWorld.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F); - if(this.gm.world.dimension.getType().celestials) { + GL11.glRotatef(this.theWorld.getCelestialAngle(partialTicks), 1.0F, 0.0F, 0.0F); + if(this.gm.world.dimension.getType() == DimType.PLANET || this.gm.world.dimension.getType() == DimType.MOON) { float size = 30.0F; int color = this.gm.world.dimension.getSunColor(); if(color != 0xffffffff) { diff --git a/client/src/main/java/client/world/ChunkClient.java b/client/src/main/java/client/world/ChunkClient.java index 3d0a34d5..8a7bb6c2 100644 --- a/client/src/main/java/client/world/ChunkClient.java +++ b/client/src/main/java/client/world/ChunkClient.java @@ -64,7 +64,7 @@ public class ChunkClient extends Chunk { public void setData(byte[] data, int[] extend, boolean biomes) { int pos = 0; - boolean sky = !this.world.dimension.hasNoLight(); + boolean sky = this.world.dimension.hasSkyLight(); if(biomes) { this.clearArrays(); diff --git a/client/src/main/java/client/world/WorldClient.java b/client/src/main/java/client/world/WorldClient.java index 34a43954..14d278fd 100755 --- a/client/src/main/java/client/world/WorldClient.java +++ b/client/src/main/java/client/world/WorldClient.java @@ -314,14 +314,15 @@ public class WorldClient extends AWorldClient State state = this.getState(pos); state.getBlock().randomDisplayTick(this, pos, state, rand); } -// if(this.canShowVoidParticles()) { - for(int n = 0; n < 1000; n++) { - float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f; - float y = -64.0f + rand.floatv() * 65.0f; // * 68.0f; - float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f; - this.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z); + if(this.dimension.hasVoidFog() && this.gm.voidParticles && posY < 32) { + for(int n = 0; n < 1000; n++) { + float x = ((float)posX) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f; + float y = (posY < -32 ? (float)posY - 32.0f : -64.0f) + rand.floatv() * 65.0f; + float z = ((float)posZ) + (rand.floatv() - rand.floatv() - 0.5f) * 32.0f; + if(y < -64.0f || rand.floatv() >= (64.0f + y) / 64.0f) + this.spawnParticle(ParticleType.DEPTH, (double)x, (double)y, (double)z); + } } -// } } public void removeAllEntities() @@ -695,7 +696,7 @@ public class WorldClient extends AWorldClient } public float getSunBrightness(float p_72971_1_) { - float f = this.getCelestialAngleRadians(p_72971_1_); + float f = this.getDayPhase(p_72971_1_); float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.2F); f1 = ExtMath.clampf(f1, 0.0F, 1.0F); f1 = 1.0F - f1; @@ -772,8 +773,8 @@ public class WorldClient extends AWorldClient vec = new Vec3(0x101010); else vec = new Vec3(this.dimension.getSkyColor()); - if(this.dimension.getType().days) { - float mult = ExtMath.clampf(ExtMath.cos(this.getCelestialAngleRadians(partial)) * 2.0F + 0.5F, + if(this.dimension.hasDaylight()) { + float mult = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partial)) * 2.0F + 0.5F, 0.0F, 1.0F); if(this.dimension.getSkyColor() == 0xffffffff) { float temp = ExtMath.clampf(((biome.getTemperature(pos) + 14.0f) / 40.0f + 0.15f) / 3.0F, @@ -829,8 +830,6 @@ public class WorldClient extends AWorldClient public Vec3 getCloudColour(Entity entity, float partialTicks) { Vec3 color = new Vec3(this.dimension.getCloudColor()); - Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY), - ExtMath.floord(entity.posZ))); if(this.dimension.isExterminated()) color = new Vec3(0x000000); float r = (float)color.xCoord; @@ -846,8 +845,8 @@ public class WorldClient extends AWorldClient b = b * shift + mul * (1.0F - shift); } - if(this.dimension.getType().days) { - float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngleRadians(partialTicks)) * 2.0F + 0.5F, + if(this.dimension.hasDaylight()) { + float sun = ExtMath.clampf(ExtMath.cos(this.getDayPhase(partialTicks)) * 2.0F + 0.5F, 0.0F, 1.0F); r = r * (sun * 0.9F + 0.1F); g = g * (sun * 0.9F + 0.1F); @@ -873,42 +872,15 @@ public class WorldClient extends AWorldClient return new Vec3((double)r, (double)g, (double)b); } - public Vec3 getFogColor(Entity entity, float partialTicks) { - Vec3 color = new Vec3(this.dimension.getFogColor()); - Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY), - ExtMath.floord(entity.posZ))); - if(this.dimension.isExterminated()) - color = new Vec3(0x303030); - if(!this.dimension.getType().days) - return color; - float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngleRadians(partialTicks)) * 2.0F + 0.5F, - 0.0F, 1.0F); - float r = (float)color.xCoord; - float g = (float)color.yCoord; - float b = (float)color.zCoord; - r = r * (sun * 0.94F + 0.06F); - g = g * (sun * 0.94F + 0.06F); - b = b * (sun * 0.91F + 0.09F); - - float space = this.getSpaceFactor(); - if(space > 0.0f) { - r = r * (1.0F - space); - g = g * (1.0F - space); - b = b * (1.0F - space); - } - - return new Vec3((double)r, (double)g, (double)b); - } - public float getStarBrightness(float partialTicks) { - float f = this.getCelestialAngleRadians(partialTicks); + float f = this.getDayPhase(partialTicks); float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F); f1 = ExtMath.clampf(f1, 0.0F, 1.0F); return Math.max(f1 * f1 * this.dimension.getStarBrightness(), this.getSpaceFactor()); } public float getDeepStarBrightness(float partialTicks) { - float f = this.getCelestialAngleRadians(partialTicks); + float f = this.getDayPhase(partialTicks); float f1 = 1.0F - (ExtMath.cos(f) * 2.0F + 0.25F); f1 = ExtMath.clampf(f1, 0.0F, 1.0F); return Math.max(f1 * f1 * this.dimension.getDeepStarBrightness(), this.getSpaceFactor()); diff --git a/client/src/main/resources/textures/blocks/plasma_flow.png b/client/src/main/resources/textures/blocks/plasma_flow.png new file mode 100755 index 00000000..c4cbea33 Binary files /dev/null and b/client/src/main/resources/textures/blocks/plasma_flow.png differ diff --git a/client/src/main/resources/textures/blocks/plasma_still.png b/client/src/main/resources/textures/blocks/plasma_still.png new file mode 100755 index 00000000..fc260d5d Binary files /dev/null and b/client/src/main/resources/textures/blocks/plasma_still.png differ diff --git a/common/src/main/java/common/ai/EntityAIMoveIndoors.java b/common/src/main/java/common/ai/EntityAIMoveIndoors.java index a5294db2..600af34f 100755 --- a/common/src/main/java/common/ai/EntityAIMoveIndoors.java +++ b/common/src/main/java/common/ai/EntityAIMoveIndoors.java @@ -27,7 +27,7 @@ public class EntityAIMoveIndoors extends EntityAIBase { BlockPos blockpos = new BlockPos(this.entityObj); - if ((!((AWorldServer)this.entityObj.worldObj).isDaytime() /* || this.entityObj.worldObj.isRaining() && !this.entityObj.worldObj.getBiomeGenForCoords(blockpos).canRain() */) && !this.entityObj.worldObj.dimension.hasNoLight()) + if ((!((AWorldServer)this.entityObj.worldObj).isDaytime() /* || this.entityObj.worldObj.isRaining() && !this.entityObj.worldObj.getBiomeGenForCoords(blockpos).canRain() */) && this.entityObj.worldObj.dimension.hasSkyLight()) { if (this.entityObj.getRNG().zrange(50) != 0) { diff --git a/common/src/main/java/common/block/tech/BlockDaylightDetector.java b/common/src/main/java/common/block/tech/BlockDaylightDetector.java index 207e6fcf..553a9993 100755 --- a/common/src/main/java/common/block/tech/BlockDaylightDetector.java +++ b/common/src/main/java/common/block/tech/BlockDaylightDetector.java @@ -53,11 +53,11 @@ public class BlockDaylightDetector extends Block implements ITileEntityProvider public void updatePower(AWorldServer worldIn, BlockPos pos) { - if (!worldIn.dimension.hasNoLight()) + if (worldIn.dimension.hasSkyLight() && worldIn.dimension.hasDaylight()) { State iblockstate = worldIn.getState(pos); int i = worldIn.getLightFor(LightType.SKY, pos) - worldIn.getSkylightSubtracted(); - float f = worldIn.getCelestialAngleRadians(1.0F); + float f = worldIn.getDayPhase(1.0F); float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F); f = f + (f1 - f) * 0.2F; i = Math.round((float)i * ExtMath.cos(f)); diff --git a/common/src/main/java/common/dimension/Area.java b/common/src/main/java/common/dimension/Area.java index 5dc170ce..33dcc7d8 100755 --- a/common/src/main/java/common/dimension/Area.java +++ b/common/src/main/java/common/dimension/Area.java @@ -23,4 +23,12 @@ public final class Area extends Dimension { public final DimType getType() { return DimType.AREA; } + + public boolean hasVoidFog() { + return true; + } + + public boolean hasSky() { + return false; + } } diff --git a/common/src/main/java/common/dimension/DimType.java b/common/src/main/java/common/dimension/DimType.java index c1153109..de85cec1 100755 --- a/common/src/main/java/common/dimension/DimType.java +++ b/common/src/main/java/common/dimension/DimType.java @@ -5,31 +5,18 @@ import java.util.Map; import common.collect.Maps; public enum DimType { - STAR("star", true, false, false, false, false, true), - PLANET("planet", true, true, true, true, true, true), - MOON("moon", true, false, false, true, false, true), - SPACE("space", false, false, false, false, false, true), - SEMI("semi", false, false, true, false, true, true), - AREA("area", false, false, false, false, false, false); + STAR("star"), + PLANET("planet"), + MOON("moon"), + SEMI("semi"), + AREA("area"); private static final Map LOOKUP = Maps.newHashMap(); private final String name; - public final boolean celestial; - public final boolean days; - public final boolean weather; - public final boolean celestials; - public final boolean clouds; - public final boolean sky; - private DimType(String name, boolean time, boolean days, boolean weather, boolean celestials, boolean clouds, boolean sky) { + private DimType(String name) { this.name = name; - this.celestial = time; - this.days = days; - this.weather = weather; - this.celestials = celestials; - this.clouds = clouds; - this.sky = sky; } public String getName() { diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index 0f20299f..1ffd79d7 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -20,7 +20,7 @@ import common.world.State; import common.world.Weather; import common.world.World; -public abstract class Dimension extends Nameable { +public abstract class Dimension extends Section { public class GeneratorSettings { public float coordinateScale = 684.412F; public float heightScale = 684.412F; @@ -779,6 +779,35 @@ public abstract class Dimension extends Nameable { public boolean isBaseDestroyed() { return false; } + + public boolean hasVoidFog() { + return false; + } + + public boolean hasSeasons() { + return false; + } + + public boolean hasDaylight() { + return false; + } + + public boolean hasSkyLight() { + return false; + } + + public boolean isCelestial() { + return false; + } + + public boolean hasWeather() { + return false; + } + + public boolean hasSky() { + return true; + } + public final int getSunColor() { return this.sunColor != 0xffffffff ? this.sunColor : this.calcSunColor(); @@ -857,10 +886,6 @@ public abstract class Dimension extends Nameable { return this.populated; } - - public final boolean hasNoLight() { - return !this.getType().days; - } public final void setBaseNames(String[] names) { this.baseNames = names; @@ -869,6 +894,8 @@ public abstract class Dimension extends Nameable { public final String[] getBaseNames() { if(this.baseNames != null) return this.baseNames; + if(this == Space.INSTANCE) + return new String[0]; String planet = null; String star = null; Dimension dim = this; @@ -898,7 +925,7 @@ public abstract class Dimension extends Nameable { public static Dimension create(DimType type) { - if(type == null || type == DimType.SPACE) + if(type == null) return null; switch(type) { case STAR: @@ -916,6 +943,8 @@ public abstract class Dimension extends Nameable { } public final Dimension makeCustomCopy() { + if(this == Space.INSTANCE) + return null; Dimension dim = create(this.getType()); TagObject tag = new TagObject(); this.toTags(tag); @@ -938,7 +967,7 @@ public abstract class Dimension extends Nameable { tag.setBool("Exterminated", this.exterminated); if(this.isCustom()) this.toTags(tag); - if(!this.exterminated && this.getType().weather) + if(!this.exterminated && this.hasWeather()) tag.setString("Weather", this.weather.getName()); return tag; } @@ -962,7 +991,7 @@ public abstract class Dimension extends Nameable { if(this.exterminated) { this.weather = Weather.CLEAR; } - else if(this.getType().weather) { + else if(this.hasWeather()) { this.weather = Weather.getByName(tag.getString("Weather")); if(this.weather == null) this.weather = this.defaultWeather; diff --git a/common/src/main/java/common/dimension/Domain.java b/common/src/main/java/common/dimension/Domain.java index c4ca8bdd..471afb11 100755 --- a/common/src/main/java/common/dimension/Domain.java +++ b/common/src/main/java/common/dimension/Domain.java @@ -1,14 +1,7 @@ package common.dimension; -public final class Domain extends Nameable implements Comparable { - public final String id; - - public Domain(String id, boolean custom) { +public final class Domain extends Section { + public Domain(boolean custom) { super(custom); - this.id = id; - } - - public int compareTo(Domain other) { - return other == null ? -1 : this.id.compareTo(other.id); } } diff --git a/common/src/main/java/common/dimension/Galaxy.java b/common/src/main/java/common/dimension/Galaxy.java index 812e9e13..69ee9dc8 100755 --- a/common/src/main/java/common/dimension/Galaxy.java +++ b/common/src/main/java/common/dimension/Galaxy.java @@ -1,14 +1,7 @@ package common.dimension; -public final class Galaxy extends Nameable implements Comparable { - public final String id; - - public Galaxy(String id, boolean custom) { +public final class Galaxy extends Section { + public Galaxy(boolean custom) { super(custom); - this.id = id; - } - - public int compareTo(Galaxy other) { - return other == null ? -1 : this.id.compareTo(other.id); } } diff --git a/common/src/main/java/common/dimension/Moon.java b/common/src/main/java/common/dimension/Moon.java index 3f1d5d0d..a7918e81 100755 --- a/common/src/main/java/common/dimension/Moon.java +++ b/common/src/main/java/common/dimension/Moon.java @@ -51,4 +51,12 @@ public final class Moon extends Dimension { public boolean isBaseDestroyed() { return (this.getSunColor() & 0xff000000) != 0; } + + public boolean hasVoidFog() { + return true; + } + + public boolean isCelestial() { + return true; + } } diff --git a/common/src/main/java/common/dimension/Planet.java b/common/src/main/java/common/dimension/Planet.java index dd584d6a..aa763c29 100755 --- a/common/src/main/java/common/dimension/Planet.java +++ b/common/src/main/java/common/dimension/Planet.java @@ -64,4 +64,28 @@ public final class Planet extends Dimension { public boolean isBaseDestroyed() { return (this.getSunColor() & 0xff000000) != 0; } + + public boolean hasVoidFog() { + return true; + } + + public boolean hasSeasons() { + return this.getOrbitOffset() != 0.0f; + } + + public boolean hasDaylight() { + return true; + } + + public boolean hasSkyLight() { + return true; + } + + public boolean isCelestial() { + return true; + } + + public boolean hasWeather() { + return true; + } } diff --git a/common/src/main/java/common/dimension/Nameable.java b/common/src/main/java/common/dimension/Section.java similarity index 81% rename from common/src/main/java/common/dimension/Nameable.java rename to common/src/main/java/common/dimension/Section.java index e1893f60..25b4f32f 100755 --- a/common/src/main/java/common/dimension/Nameable.java +++ b/common/src/main/java/common/dimension/Section.java @@ -1,11 +1,11 @@ package common.dimension; -public abstract class Nameable { +public abstract class Section { private final boolean custom; private String display = null; - protected Nameable(boolean custom) { + protected Section(boolean custom) { this.custom = custom; } diff --git a/common/src/main/java/common/dimension/Sector.java b/common/src/main/java/common/dimension/Sector.java index 045edde4..ceca69cc 100755 --- a/common/src/main/java/common/dimension/Sector.java +++ b/common/src/main/java/common/dimension/Sector.java @@ -1,14 +1,7 @@ package common.dimension; -public final class Sector extends Nameable implements Comparable { - public final String id; - - public Sector(String id, boolean custom) { +public final class Sector extends Section { + public Sector(boolean custom) { super(custom); - this.id = id; - } - - public int compareTo(Sector other) { - return other == null ? -1 : this.id.compareTo(other.id); } } diff --git a/common/src/main/java/common/dimension/Semi.java b/common/src/main/java/common/dimension/Semi.java index 9d91441f..b1595078 100755 --- a/common/src/main/java/common/dimension/Semi.java +++ b/common/src/main/java/common/dimension/Semi.java @@ -19,4 +19,12 @@ public final class Semi extends Dimension { public final DimType getType() { return DimType.SEMI; } + + public boolean hasVoidFog() { + return true; + } + + public boolean hasWeather() { + return true; + } } diff --git a/common/src/main/java/common/dimension/Space.java b/common/src/main/java/common/dimension/Space.java index 819bd030..9656d671 100755 --- a/common/src/main/java/common/dimension/Space.java +++ b/common/src/main/java/common/dimension/Space.java @@ -13,134 +13,6 @@ public final class Space extends Dimension { } public final DimType getType() { - return DimType.SPACE; + return null; } - -// public String getDimensionName() { -// return "space"; -// } -// -// public int getDimensionId() { -// return Constants.SPACE_WORLD; -// } - -// public Biome getBiome() { -// return Biome.space; -// } -// -// public final float getGravity() { -// return 0.0f; -// } -// -// public IBlockState getCaveFiller() { -// return Blocks.air.getDefaultState(); -// } -// -// public IBlockState getFiller() { -// return Blocks.air.getDefaultState(); -// } -// -// public IBlockState getTop() { -// return Blocks.air.getDefaultState(); -// } -// -// public IBlockState getSurface() { -// return Blocks.air.getDefaultState(); -// } -// -// public IBlockState getAltFiller() { -// return Blocks.air.getDefaultState(); -// } -// -// public IBlockState getLavaFiller() { -// return null; -// } -// -// public boolean hasRavines() { -// return false; -// } - -// public ChunkGenerator createChunkGenerator(Random rand) { -// return new GeneratorFlat(new IBlockState[0]); -// } -// -// public BlockReplacer createBlockReplacer(Random rand) { -// return null; -// } - -// public int getBrightness() { -// return 15; -// } -// -// public final int getSkyColor() { -// return 0x000000; -// } -// -// public IBlockState getWorldFloor() { -// return null; -// } -// -// public final boolean hasSnow() { -// return false; -// } -// -// public final boolean hasCaves() { -// return false; -// } - -// public final float getCloudHeight(float height) { -// return height; -// } - -// public float getStarBrightness() { -// return 1.0f; -// } -// -// public float getDeepStarBrightness() { -// return 1.0f; -// } -// -// public float getLavaChance() { -// return 0.0f; -// } -// -// public float getWaterChance() { -// return 0.0f; -// } -// -// public boolean hasDungeons() { -// return false; -// } -// -// public IBlockState getSurfaceLiquid() { -// return Blocks.air.getDefaultState(); -// } -// -// public int getSeaLevel() { -// return 0; -// } -// -// public final int getTimeQualifier() { -// return 8; -// } -// -// public final long getOrbitalPeriod() { -// return 1L; -// } -// -// public final long getRotationalPeriod() { -// return 1L; -// } -// -// public final float getOrbitOffset() { -// return 0.0f; -// } -// -// public final int getLevelBelow() { -// return this.getDimensionId(); -// } -// -// public float getTemperature() { -// return 2.7f; -// } } diff --git a/common/src/main/java/common/dimension/Star.java b/common/src/main/java/common/dimension/Star.java index 2eda0035..b788dc82 100755 --- a/common/src/main/java/common/dimension/Star.java +++ b/common/src/main/java/common/dimension/Star.java @@ -22,4 +22,8 @@ public final class Star extends Dimension { public final DimType getType() { return DimType.STAR; } + + public boolean isCelestial() { + return true; + } } diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 0c78c2c8..c062bcb4 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -12,6 +12,7 @@ import common.block.liquid.BlockLiquid; import common.color.TextColor; import common.dimension.DimType; import common.dimension.Dimension; +import common.dimension.Space; import common.enchantment.Enchantment; import common.enchantment.EnchantmentHelper; import common.entity.effect.EntityLightning; @@ -356,7 +357,7 @@ public abstract class Entity } protected void onVoidUpdate() { - if(!this.worldObj.client && this.worldObj.dimension.getType() != DimType.SPACE) { + if(!this.worldObj.client && this.worldObj.dimension != Space.INSTANCE) { // this.worldObj.profiler.start("descent"); Dimension current = this.worldObj.dimension; Dimension dim = Vars.voidPortal ? ((AWorldServer)this.worldObj).getPortalDest(PortalType.VOID) : current; diff --git a/common/src/main/java/common/entity/npc/EntitySlime.java b/common/src/main/java/common/entity/npc/EntitySlime.java index 5c3c997e..9fead9ce 100755 --- a/common/src/main/java/common/entity/npc/EntitySlime.java +++ b/common/src/main/java/common/entity/npc/EntitySlime.java @@ -385,7 +385,7 @@ public class EntitySlime extends EntityNPC // { Biome biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos); - if (biomegenbase == Biome.SWAMPLAND && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getCurrentMoonPhaseFactor() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8)) + if (biomegenbase == Biome.SWAMPLAND && this.posY > 50.0D && this.posY < 70.0D && this.rand.floatv() < 0.5F && this.rand.floatv() < this.worldObj.getMoonPhase() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8)) { return super.getCanSpawnHere(); } diff --git a/common/src/main/java/common/init/UniverseRegistry.java b/common/src/main/java/common/init/UniverseRegistry.java index 22e0f5b0..226474cf 100755 --- a/common/src/main/java/common/init/UniverseRegistry.java +++ b/common/src/main/java/common/init/UniverseRegistry.java @@ -15,94 +15,114 @@ import common.dimension.Dimension; import common.dimension.Domain; import common.dimension.Galaxy; import common.dimension.Moon; +import common.dimension.Section; import common.dimension.Planet; import common.dimension.Sector; import common.dimension.Semi; import common.dimension.Space; import common.dimension.Star; import common.world.Weather; -import common.world.World; - import java.util.Set; public abstract class UniverseRegistry { + private static final List
SECTIONS = Lists.newArrayList(); private static final List DIMENSIONS = Lists.newArrayList(); private static final Map ID_MAP = Maps.newTreeMap(); private static final Map IDS = new IdentityHashMap(); - private static final Map NAME_MAP = Maps.newTreeMap(); - private static final Map NAMES = new IdentityHashMap(); + private static final Map NAME_MAP = Maps.newTreeMap(); + private static final Map NAMES = new IdentityHashMap(); private static final Set NAME_LIST = Sets.newTreeSet(); - private static final Map SECTORS = Maps.newHashMap(); - private static final Map GALAXIES = Maps.newHashMap(); - private static final Map DOMAINS = Maps.newHashMap(); - - private static final Map MOON_MAP = Maps.newHashMap(); - private static final Map> MOONS_MAP = Maps.newHashMap(); - private static final Map PLANET_MAP = Maps.newHashMap(); - private static final Map> PLANETS_MAP = Maps.newHashMap(); - private static final Map STAR_MAP = Maps.newHashMap(); - private static final Map> STARS_MAP = Maps.newHashMap(); - private static final Map SECTOR_MAP = Maps.newHashMap(); - private static final Map> SECTORS_MAP = Maps.newHashMap(); - private static final Map AREA_MAP = Maps.newHashMap(); - private static final Map> AREAS_MAP = Maps.newHashMap(); - private static final Set SEMI_SET = Sets.newHashSet(); + private static final Map MOON_PLANET = Maps.newHashMap(); + private static final Map> PLANET_MOONS = Maps.newHashMap(); + private static final Map PLANET_STAR = Maps.newHashMap(); + private static final Map> STAR_PLANETS = Maps.newHashMap(); + private static final Map STAR_SECTOR = Maps.newHashMap(); + private static final Map> SECTOR_STARS = Maps.newHashMap(); + private static final Map SECTOR_GALAXY = Maps.newHashMap(); + private static final Map> GALAXY_SECTORS = Maps.newHashMap(); + private static final Map AREA_DOMAIN = Maps.newHashMap(); + private static final Map> DOMAIN_AREAS = Maps.newHashMap(); + private static final Set SEMI = Sets.newHashSet(); public static List getDimensions() { return DIMENSIONS; } + public static List
getSections() { + return SECTIONS; + } + public static Collection getGalaxies() { - return GALAXIES.values(); + return GALAXY_SECTORS.keySet(); } public static Collection getSectors() { - return SECTORS.values(); + return SECTOR_GALAXY.keySet(); } public static Collection getDomains() { - return DOMAINS.values(); + return DOMAIN_AREAS.keySet(); } public static Collection getStars() { - return STAR_MAP.keySet(); + return STAR_SECTOR.keySet(); } public static Collection getPlanets() { - return PLANET_MAP.keySet(); + return PLANET_STAR.keySet(); } public static Collection getMoons() { - return MOON_MAP.keySet(); + return MOON_PLANET.keySet(); } public static Collection getAreas() { - return AREA_MAP.keySet(); + return AREA_DOMAIN.keySet(); } public static Collection getSemis() { - return SEMI_SET; + return SEMI; } public static List getSectors(Galaxy galaxy) { - return SECTORS_MAP.get(galaxy); + return GALAXY_SECTORS.get(galaxy); } public static List getStars(Sector sector) { - return STARS_MAP.get(sector); + return SECTOR_STARS.get(sector); } public static List getPlanets(Star star) { - return PLANETS_MAP.get(star); + return STAR_PLANETS.get(star); } public static List getMoons(Planet planet) { - return MOONS_MAP.get(planet); + return PLANET_MOONS.get(planet); } public static List getAreas(Domain domain) { - return AREAS_MAP.get(domain); + return DOMAIN_AREAS.get(domain); + } + + public static Star getStar(Planet planet) { + return PLANET_STAR.get(planet); + } + + public static Planet getPlanet(Moon moon) { + return MOON_PLANET.get(moon); + } + + public static Sector getSector(Star star) { + return STAR_SECTOR.get(star); + } + + public static Galaxy getGalaxy(Sector sector) { + return SECTOR_GALAXY.get(sector); + } + + public static Domain getDomain(Area area) { + return AREA_DOMAIN.get(area); } public static Dimension getDimension(int dim) { @@ -116,31 +136,15 @@ public abstract class UniverseRegistry { return id == null ? -1 : id; } - public static String getName(Dimension dim) { + public static String getName(Section dim) { return dim == null ? null : NAMES.get(dim); } - public static Star getStar(Planet planet) { - return PLANET_MAP.get(planet); - } - - public static Planet getPlanet(Moon moon) { - 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) instanceof Dimension dim ? dim : null; + } + + public static Section getSection(String name) { return NAME_MAP.get(name); } @@ -149,50 +153,71 @@ public abstract class UniverseRegistry { } public static boolean isRegistered(String name) { - return GALAXIES.containsKey(name) || SECTORS.containsKey(name) || DOMAINS.containsKey(name) || NAME_MAP.containsKey(name); + return NAME_MAP.containsKey(name); } public static boolean isType(String name, DimType type) { - return NAME_MAP.containsKey(name) && NAME_MAP.get(name).getType() == type; + return NAME_MAP.containsKey(name) && NAME_MAP.get(name) instanceof Dimension dim && dim.getType() == type; } public static Galaxy registerCustomGalaxy(String name, String display) { - return registerGalaxyInt(name, display, true); + Galaxy galaxy = new Galaxy(true); + registerGalaxyInt(name, display, galaxy); + return galaxy; } public static Sector registerCustomSector(String name, String display, String galaxy) { - return registerSectorInt(name, display, galaxy, true); + Section base = NAME_MAP.get(galaxy); + if(!(base instanceof Galaxy baseGalaxy)) + throw new IllegalArgumentException("Galaxie " + galaxy + " existiert nicht"); + Sector sector = new Sector(true); + registerSectorInt(name, display, sector, baseGalaxy); + return sector; } public static Domain registerCustomDomain(String name, String display) { - return registerDomainInt(name, display, true); + Domain domain = new Domain(true); + registerDomainInt(name, display, domain); + return domain; } public static Star registerCustomStar(String name, String display, Star dim, String sector) { + Section base = NAME_MAP.get(sector); + if(!(base instanceof Sector baseSector)) + throw new IllegalArgumentException("Sektor " + sector + " existiert nicht"); if(!dim.isCustom()) dim = (Star)dim.makeCustomCopy(); - registerStarInt(name, display, dim, sector); + registerStarInt(name, display, dim, baseSector); return dim; } public static Planet registerCustomPlanet(String name, String display, Planet dim, String star) { + Section base = NAME_MAP.get(star); + if(!(base instanceof Star baseStar)) + throw new IllegalArgumentException("Stern " + star + " existiert nicht"); if(!dim.isCustom()) dim = (Planet)dim.makeCustomCopy(); - registerPlanetInt(name, display, dim, star); + registerPlanetInt(name, display, dim, baseStar); return dim; } public static Moon registerCustomMoon(String name, String display, Moon dim, String planet) { + Section base = NAME_MAP.get(planet); + if(!(base instanceof Planet basePlanet)) + throw new IllegalArgumentException("Planet " + planet + " existiert nicht"); if(!dim.isCustom()) dim = (Moon)dim.makeCustomCopy(); - registerMoonInt(name, display, dim, planet); + registerMoonInt(name, display, dim, basePlanet); return dim; } public static Area registerCustomArea(String name, String display, Area dim, String domain) { + Section base = NAME_MAP.get(domain); + if(!(base instanceof Domain baseDomain)) + throw new IllegalArgumentException("Bereich " + domain + " existiert nicht"); if(!dim.isCustom()) dim = (Area)dim.makeCustomCopy(); - registerAreaInt(name, display, dim, domain); + registerAreaInt(name, display, dim, baseDomain); return dim; } @@ -202,158 +227,126 @@ public abstract class UniverseRegistry { registerSemiInt(name, display, dim); return dim; } - - private static void checkRegistered(String name) { - if(isRegistered(name)) + + + private static void register(String name, String display, Section obj) { + if(NAME_MAP.containsKey(name)) throw new IllegalArgumentException("Objekt " + name + " ist bereits registriert"); - } - - private static Galaxy registerGalaxyInt(String name, String display, boolean custom) { - checkRegistered(name); - Galaxy galaxy = new Galaxy(name, custom); - galaxy.setDisplay(display); - GALAXIES.put(name, galaxy); - SECTORS_MAP.put(galaxy, Lists.newArrayList()); - return galaxy; + obj.setDisplay(display); + NAME_MAP.put(name, obj); + NAMES.put(obj, name); + SECTIONS.add(obj); + if(obj instanceof Dimension dim) { + NAME_LIST.add(name); + ID_MAP.put(DIMENSIONS.size(), dim); + IDS.put(dim, DIMENSIONS.size()); + DIMENSIONS.add(dim); + } } - private static Sector registerSectorInt(String name, String display, String galaxy, boolean custom) { - checkRegistered(name); - Galaxy base = GALAXIES.get(galaxy); - if(base == null) - throw new IllegalArgumentException("Galaxie " + galaxy + " existiert nicht"); - Sector sector = new Sector(name, custom); - sector.setDisplay(display); - SECTORS.put(name, sector); - SECTOR_MAP.put(sector, base); - STARS_MAP.put(sector, Lists.newArrayList()); - SECTORS_MAP.get(base).add(sector); - return sector; + private static void registerGalaxyInt(String name, String display, Galaxy galaxy) { + register(name, display, galaxy); + GALAXY_SECTORS.put(galaxy, Lists.newArrayList()); } - private static Domain registerDomainInt(String name, String display, boolean custom) { - checkRegistered(name); - Domain domain = new Domain(name, custom); - domain.setDisplay(display); - DOMAINS.put(name, domain); - AREAS_MAP.put(domain, Lists.newArrayList()); - return domain; + private static void registerSectorInt(String name, String display, Sector sector, Galaxy galaxy) { + register(name, display, sector); + SECTOR_GALAXY.put(sector, galaxy); + SECTOR_STARS.put(sector, Lists.newArrayList()); + GALAXY_SECTORS.get(galaxy).add(sector); } - private static void registerDimension(String name, String display, Dimension dim) { - checkRegistered(name); - dim.setDisplay(display); - NAME_MAP.put(name, dim); - NAMES.put(dim, name); - NAME_LIST.add(name); - ID_MAP.put(DIMENSIONS.size(), dim); - IDS.put(dim, DIMENSIONS.size()); - DIMENSIONS.add(dim); + private static void registerDomainInt(String name, String display, Domain domain) { + register(name, display, domain); + DOMAIN_AREAS.put(domain, Lists.newArrayList()); } - private static void registerStarInt(String name, String display, Dimension dim, String sector) { - Sector base = SECTORS.get(sector); - if(base == null) - throw new IllegalArgumentException("Sektor " + sector + " existiert nicht"); - registerDimension(name, display, dim); - STAR_MAP.put((Star)dim, base); - PLANETS_MAP.put((Star)dim, Lists.newArrayList()); - STARS_MAP.get(base).add((Star)dim); + private static void registerStarInt(String name, String display, Star star, Sector sector) { + register(name, display, star); + STAR_SECTOR.put(star, sector); + STAR_PLANETS.put(star, Lists.newArrayList()); + SECTOR_STARS.get(sector).add(star); } - private static void registerPlanetInt(String name, String display, Dimension dim, String star) { - Dimension base = NAME_MAP.get(star); - if(base == null || base.getType() != DimType.STAR) - throw new IllegalArgumentException("Stern " + star + " existiert nicht"); - registerDimension(name, display, dim); - PLANET_MAP.put((Planet)dim, ((Star)base)); - MOONS_MAP.put((Planet)dim, Lists.newArrayList()); - PLANETS_MAP.get((Star)base).add((Planet)dim); + private static void registerPlanetInt(String name, String display, Planet planet, Star star) { + register(name, display, planet); + PLANET_STAR.put(planet, star); + PLANET_MOONS.put(planet, Lists.newArrayList()); + STAR_PLANETS.get(star).add(planet); } - private static void registerMoonInt(String name, String display, Dimension dim, String planet) { - Dimension base = NAME_MAP.get(planet); - if(base == null || base.getType() != DimType.PLANET) - throw new IllegalArgumentException("Planet " + planet + " existiert nicht"); - registerDimension(name, display, dim); - MOON_MAP.put((Moon)dim, ((Planet)base)); - MOONS_MAP.get((Planet)base).add((Moon)dim); + private static void registerMoonInt(String name, String display, Moon moon, Planet planet) { + register(name, display, moon); + MOON_PLANET.put(moon, planet); + PLANET_MOONS.get(planet).add(moon); } - private static void registerAreaInt(String name, String display, Dimension dim, String domain) { - Domain base = DOMAINS.get(domain); - if(base == null) - throw new IllegalArgumentException("Bereich " + domain + " existiert nicht"); - registerDimension(name, display, dim); - AREA_MAP.put((Area)dim, base); - AREAS_MAP.get(base).add((Area)dim); + private static void registerAreaInt(String name, String display, Area area, Domain domain) { + register(name, display, area); + AREA_DOMAIN.put(area, domain); + DOMAIN_AREAS.get(domain).add(area); } - private static void registerSemiInt(String name, String display, Dimension dim) { - registerDimension(name, display, dim); - SEMI_SET.add((Semi)dim); + private static void registerSemiInt(String name, String display, Semi semi) { + register(name, display, semi); + SEMI.add(semi); } - private static String lastGalaxy; - private static String lastSector; - private static String lastDomain; - private static String lastStar; - private static String lastPlanet; + private static Galaxy lastGalaxy; + private static Sector lastSector; + private static Domain lastDomain; + private static Star lastStar; + private static Planet lastPlanet; private static String fromDisplay(String display) { return display.toLowerCase().replace("'", "").replace(' ', '_'); } private static void registerGalaxy(String name, String display, Runnable sub) { - registerGalaxyInt(name, display, false); - lastGalaxy = name; + registerGalaxyInt(name, display, lastGalaxy = new Galaxy(false)); sub.run(); lastGalaxy = null; } private static void registerSector(String name, String display, Runnable sub) { - registerSectorInt(name, display, lastGalaxy, false); - lastSector = name; + registerSectorInt(name, display, lastSector = new Sector(false), lastGalaxy); sub.run(); lastSector = null; } private static void registerDomain(String name, String display, Runnable sub) { - registerDomainInt(name, display, false); - lastDomain = name; + registerDomainInt(name, display, lastDomain = new Domain(false)); sub.run(); lastDomain = null; } private static void registerStar(String name, String display, Dimension dim, Runnable sub) { - registerStarInt(name, display, dim, lastSector); - lastStar = name; + registerStarInt(name, display, lastStar = (Star)dim, lastSector); sub.run(); lastStar = null; } private static void registerPlanet(String name, String display, Dimension dim) { - registerPlanetInt(name, display, dim, lastStar); + registerPlanetInt(name, display, (Planet)dim, lastStar); } private static void registerPlanet(String name, String display, Dimension dim, Runnable sub) { - registerPlanet(name, display, dim); - lastPlanet = name; + registerPlanetInt(name, display, lastPlanet = (Planet)dim, lastStar); sub.run(); lastPlanet = null; } private static void registerMoon(String name, String display, Dimension dim) { - registerMoonInt(name, display, dim, lastPlanet); + registerMoonInt(name, display, (Moon)dim, lastPlanet); } private static void registerArea(String name, String display, Dimension dim) { - registerAreaInt(name, display, dim, lastDomain); + registerAreaInt(name, display, (Area)dim, lastDomain); } private static void registerSemi(String name, String display, Dimension dim) { - registerSemiInt(name, display, dim); + registerSemiInt(name, display, (Semi)dim); } private static void registerGalaxy(String display, Runnable sub) { @@ -405,7 +398,7 @@ public abstract class UniverseRegistry { } public static void register() { - registerDimension("space", "Der Weltraum", Space.INSTANCE); + register("space", "Der Weltraum", Space.INSTANCE); registerGalaxy("milkyway", "Galaxie Milchstraße", () -> { registerSector("Solar", () -> { diff --git a/common/src/main/java/common/item/tool/ItemSpaceNavigator.java b/common/src/main/java/common/item/tool/ItemSpaceNavigator.java index 6f657879..cc74ea6f 100755 --- a/common/src/main/java/common/item/tool/ItemSpaceNavigator.java +++ b/common/src/main/java/common/item/tool/ItemSpaceNavigator.java @@ -16,13 +16,13 @@ public class ItemSpaceNavigator extends ItemMagnetic { public String getHotbarText(EntityNPC player, ItemStack stack) { BlockPos pos = player.getPosition(); - return TextColor.ORANGE + player.worldObj.formatImperialTime(player, false) + " / " + + return TextColor.ORANGE + player.worldObj.formatTime(player, false) + " / " + String.format("%s bei %d, %d, %d", player.worldObj.dimension.getDisplay() + TextColor.ORANGE, pos.getX(), pos.getY(), pos.getZ()); } public void addInformation(ItemStack stack, EntityNPC player, List tooltip) { - tooltip.add(TextColor.ORANGE + player.worldObj.formatImperialTime(player, true)); + tooltip.add(TextColor.ORANGE + player.worldObj.formatTime(player, true)); String[] dims = player.worldObj.dimension.getBaseNames(); for(int z = dims.length - 1; z >= 0; z--) { tooltip.add(TextColor.ORANGE + dims[z]); diff --git a/common/src/main/java/common/item/tool/ItemWeatherToken.java b/common/src/main/java/common/item/tool/ItemWeatherToken.java index ed145aeb..beefc9cc 100755 --- a/common/src/main/java/common/item/tool/ItemWeatherToken.java +++ b/common/src/main/java/common/item/tool/ItemWeatherToken.java @@ -21,7 +21,7 @@ public class ItemWeatherToken extends ItemMagnetic { public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn) { - if(worldIn.dimension.getType().weather) { + if(worldIn.dimension.hasWeather()) { // if (!playerIn.creative) itemStackIn.decrSize(); worldIn.playSoundAtEntity(playerIn, SoundEvent.SPELL, 0.5F); diff --git a/common/src/main/java/common/packet/SPacketRespawn.java b/common/src/main/java/common/packet/SPacketRespawn.java index 950496c4..94ec72dc 100755 --- a/common/src/main/java/common/packet/SPacketRespawn.java +++ b/common/src/main/java/common/packet/SPacketRespawn.java @@ -32,7 +32,7 @@ public class SPacketRespawn implements Packet { else { this.dimType = dim.getType(); this.dimData = dim.writeData(); - if(this.dimType.celestials) { + if(this.dimType == DimType.PLANET || this.dimType == DimType.MOON) { this.sunColor = dim.getSunColor(); this.moonColors = dim.getMoonColors(); } @@ -57,9 +57,9 @@ public class SPacketRespawn implements Packet { public void readPacketData(PacketBuffer buf) throws IOException { this.dimId = buf.readVarInt(); if(this.dimId >= -1) { - this.dimType = buf.readEnumValue(DimType.class); + this.dimType = buf.readEnumOrNull(DimType.class); this.dimData = buf.readTag(); - if(this.dimType.celestials) { + if(this.dimType == DimType.PLANET || this.dimType == DimType.MOON) { this.sunColor = buf.readInt(); this.moonColors = new int[buf.readVarInt()]; for(int z = 0; z < this.moonColors.length; z++) { @@ -82,9 +82,9 @@ public class SPacketRespawn implements Packet { public void writePacketData(PacketBuffer buf) throws IOException { buf.writeVarInt(this.dimId); if(this.dimId >= -1) { - buf.writeEnumValue(this.dimType); + buf.writeEnumOrNull(this.dimType); buf.writeTag(this.dimData); - if(this.dimType.celestials) { + if(this.dimType == DimType.PLANET || this.dimType == DimType.MOON) { buf.writeInt(this.sunColor); buf.writeVarInt(this.moonColors.length); for(int z = 0; z < this.moonColors.length; z++) { @@ -109,7 +109,7 @@ public class SPacketRespawn implements Packet { return null; Dimension dim = this.dimId >= 0 ? UniverseRegistry.getDimension(this.dimId) : Dimension.create(this.dimType); dim.readData(this.dimData); - if(this.dimType.celestials) { + if(this.dimType == DimType.PLANET || this.dimType == DimType.MOON) { dim.setSunColor(this.sunColor); dim.setMoonColors(this.moonColors); } diff --git a/common/src/main/java/common/world/Chunk.java b/common/src/main/java/common/world/Chunk.java index 153de731..f17fbc74 100755 --- a/common/src/main/java/common/world/Chunk.java +++ b/common/src/main/java/common/world/Chunk.java @@ -103,7 +103,7 @@ public abstract class Chunk { } } - if(!this.world.dimension.hasNoLight() && top != Integer.MIN_VALUE) { + if(this.world.dimension.hasSkyLight() && top != Integer.MIN_VALUE) { int l = 15; int y = top + 16 - 1; @@ -216,7 +216,7 @@ public abstract class Chunk { int cx = this.xPos * 16 + x; int cz = this.zPos * 16 + z; - if(!this.world.dimension.hasNoLight()) { + if(this.world.dimension.hasSkyLight()) { if(cy < h) { for(int n = cy; n < h; ++n) { BlockArray stor = this.getArray(n >> 4); @@ -275,7 +275,7 @@ public abstract class Chunk { this.minHeight = sh; } - if(!this.world.dimension.hasNoLight()) { + if(this.world.dimension.hasSkyLight()) { for(Facing face : Facing.Plane.HORIZONTAL) { this.updateNeighbor(cx + face.getFrontOffsetX(), cz + face.getFrontOffsetZ(), sy, ey); } @@ -336,7 +336,7 @@ public abstract class Chunk { return null; } - stor = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight(), y < 0 ? this.filler : null); + stor = new BlockArray(y >> 4 << 4, this.world.dimension.hasSkyLight(), y < 0 ? this.filler : null); this.setArray(stor); up = y >= h; } @@ -414,7 +414,7 @@ public abstract class Chunk { int z = pos.getZ() & 15; BlockArray stor = this.getArray(y >> 4); if(type == LightType.SKY) { - int l = stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) : (this.world.dimension.hasNoLight() ? 0 : stor.getSky(x, y & 15, z)); + int l = stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) : (this.world.dimension.hasSkyLight() ? stor.getSky(x, y & 15, z) : 0); if(y < 0) { int max = y < -64 ? 0 : (y + 64) / 4; l = l > max ? max : l; @@ -433,7 +433,7 @@ public abstract class Chunk { BlockArray stor = this.getArray(y >> 4); if(stor == null) { - stor = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight(), y < 0 ? this.filler : null); + stor = new BlockArray(y >> 4 << 4, this.world.dimension.hasSkyLight(), y < 0 ? this.filler : null); this.setArray(stor); this.genSkyLight(); } @@ -441,7 +441,7 @@ public abstract class Chunk { this.modified = true; if(type == LightType.SKY) { - if(!this.world.dimension.hasNoLight()) { + if(this.world.dimension.hasSkyLight()) { stor.setSky(x, y & 15, z, value); } } @@ -455,13 +455,13 @@ public abstract class Chunk { int y = pos.getY(); int z = pos.getZ() & 15; BlockArray stor = this.getArray(y >> 4); - int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasNoLight() ? 0 : stor.getSky(x, y & 15, z)); + int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasSkyLight() ? stor.getSky(x, y & 15, z) : 0); if(y < 0) { int max = y < -64 ? 0 : (y + 64) / 4; l = l > max ? max : l; } if(stor == null) - return !this.world.dimension.hasNoLight() && amount < l ? l - amount : 0; + return this.world.dimension.hasSkyLight() && amount < l ? l - amount : 0; l = l - amount; int b = stor.getLight(x, y & 15, z); return b > l ? b : l; @@ -658,7 +658,7 @@ public abstract class Chunk { } public void update(boolean noGaps) { - if(this.gapUpdate && !this.world.dimension.hasNoLight() && !noGaps) { + if(this.gapUpdate && this.world.dimension.hasSkyLight() && !noGaps) { this.recheckGaps(this.world.client); } @@ -735,7 +735,7 @@ public abstract class Chunk { this.lightInit = true; BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4); - if(!this.world.dimension.hasNoLight()) { + if(this.world.dimension.hasSkyLight()) { if(this.world.isAreaLoaded(pos.add(-1, 0, -1), pos.add(16, this.world.getSeaLevel(), 16))) { label92: diff --git a/common/src/main/java/common/world/World.java b/common/src/main/java/common/world/World.java index f85e1fba..542065fc 100755 --- a/common/src/main/java/common/world/World.java +++ b/common/src/main/java/common/world/World.java @@ -166,15 +166,15 @@ public abstract class World implements IWorldAccess { return 6; } - public String formatImperialTime(Dimension home, boolean days) { + public String formatTime(Dimension home, boolean days) { String qualifier = home != null ? (home.getType() == DimType.PLANET ? this.getTimeQualifier((Planet)home) + "." : "?.") : ""; long time = this.daytime; String gtime; - if((home == null || !home.getType().celestial) && !this.dimension.getType().celestial) { + if((home == null || !home.isCelestial()) && !this.dimension.isCelestial()) { gtime = "???.???.M?"; } else { - long yearTime = (home != null && home.getType().celestial ? home : this.dimension).getOrbitalPeriod(); + long yearTime = (home != null && home.isCelestial() ? home : this.dimension).getOrbitalPeriod(); long year = time / yearTime; long frac = (time * 1000L / yearTime) % 1000L; gtime = String.format("%03d.%03d.M%d", frac, year % 1000L, year / 1000L + 1L); @@ -182,7 +182,7 @@ public abstract class World implements IWorldAccess { if(!days) return qualifier + gtime; String ltime; - if(!this.dimension.getType().celestial) { + if(!this.dimension.isCelestial()) { ltime = " T???.??? D???.???.G?"; } else { @@ -194,8 +194,8 @@ public abstract class World implements IWorldAccess { return qualifier + gtime + ltime; } - public String formatImperialTime(EntityNPC player, boolean days) { - return this.formatImperialTime(player == null ? null : player.getOrigin().getDimension(), days); + public String formatTime(EntityNPC player, boolean days) { + return this.formatTime(player == null ? null : player.getOrigin().getDimension(), days); } public abstract Biome getBiomeGenForCoords(BlockPos pos); @@ -328,7 +328,7 @@ public abstract class World implements IWorldAccess { x2 = i; } - if(!this.dimension.hasNoLight()) { + if(this.dimension.hasSkyLight()) { for(int j = x2; j <= z2; ++j) { this.checkLightFor(LightType.SKY, new BlockPos(x1, j, z1)); } @@ -483,7 +483,7 @@ public abstract class World implements IWorldAccess { } public int getLightFromNeighborsFor(LightType type, BlockPos pos) { - if(this.dimension.hasNoLight() && type == LightType.SKY) { + if(!this.dimension.hasSkyLight() && type == LightType.SKY) { return 0; } else { @@ -934,9 +934,9 @@ public abstract class World implements IWorldAccess { return list; } - private float calculateCelestialAngle(long worldTime, float partialTicks) { + private float calcRotationPhase(long worldTime, float partial) { int i = (int)(worldTime % this.dimension.getRotationalPeriod()); - float f = ((float)i + partialTicks) / (float)this.dimension.getRotationalPeriod() - 0.5F; + float f = ((float)i + partial) / (float)this.dimension.getRotationalPeriod() - 0.5F; if(f < 0.0F) { ++f; @@ -951,8 +951,8 @@ public abstract class World implements IWorldAccess { return f; } - public int calculateSkylightSubtracted(boolean current) { - float f = !this.dimension.getType().days || (current && this.dimension.isBaseDestroyed()) ? 0.5f : this.calculateCelestialAngle(current ? this.daytime : + public int calcSkylightSubtracted(boolean current) { + float f = !this.dimension.hasDaylight() || (current && this.dimension.isBaseDestroyed()) ? 0.5f : this.calcRotationPhase(current ? this.daytime : (this.dimension.getRotationalPeriod() / 4L), 1.0f); float f1 = 1.0F - (ExtMath.cos(f * (float)Math.PI * 2.0F) * 2.0F + 0.5F); f1 = ExtMath.clampf(f1, 0.0F, 1.0F); @@ -963,8 +963,8 @@ public abstract class World implements IWorldAccess { return (int)(f1 * 11.0F); } - public float getCelestialAngle(float partialTicks) { - return !this.dimension.getType().days ? 0.5f : this.calculateCelestialAngle(this.daytime, Vars.dayCycle ? partialTicks : 0.0f); + public float getCelestialAngle(float partial) { + return !this.dimension.isCelestial() ? 180.0f : (this.calcRotationPhase(this.daytime, Vars.dayCycle ? partial : 0.0f) * 360.0F); } public int getMoonPhase(int moon) { @@ -972,12 +972,12 @@ public abstract class World implements IWorldAccess { return (int)(this.daytime / this.dimension.getRotationalPeriod() % 8L + 8L + this.rand.zrange(8)) % 8; } - public float getCurrentMoonPhaseFactor() { + public float getMoonPhase() { return MOON_PHASES[this.getMoonPhase(0)]; } - public float getCelestialAngleRadians(float partialTicks) { - return (this.dimension.isBaseDestroyed() ? 0.5f : this.getCelestialAngle(partialTicks)) * (float)Math.PI * 2.0F; + public float getDayPhase(float partial) { + return !this.dimension.hasDaylight() || this.dimension.isBaseDestroyed() ? (float)Math.PI : (this.calcRotationPhase(this.daytime, Vars.dayCycle ? partial : 0.0f) * (float)Math.PI * 2.0F); } public BlockPos getPrecipitationHeight(BlockPos pos) { @@ -1545,7 +1545,7 @@ public abstract class World implements IWorldAccess { } protected void calculateInitialSkylight() { - int light = this.calculateSkylightSubtracted(false); + int light = this.calcSkylightSubtracted(false); if(light != this.subtract) this.subtract = light; } @@ -1601,7 +1601,7 @@ public abstract class World implements IWorldAccess { } public LeavesType getLeavesGen(BlockPos pos) { - return this.canFreezeAt(pos) ? LeavesType.SNOWY : ((!this.dimension.getType().days || this.dimension.getOrbitOffset() == 0.0f) ? + return this.canFreezeAt(pos) ? LeavesType.SNOWY : (!this.dimension.hasSeasons() ? this.dimension.getLeavesType() : LeavesType.values()[(int)((this.daytime % this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]); } @@ -1654,7 +1654,7 @@ public abstract class World implements IWorldAccess { public boolean checkLight(BlockPos pos) { boolean flag = false; - if(!this.dimension.hasNoLight()) { + if(this.dimension.hasSkyLight()) { flag |= this.checkLightFor(LightType.SKY, pos); } @@ -2017,7 +2017,7 @@ public abstract class World implements IWorldAccess { public double getSpaceFactor(double x, double y, double z) { if(this.dimension.getType() == DimType.SEMI) return ExtMath.clampd((y - (double)World.MAX_SIZE_Y) / 16384.0, 0.0, 1.0); - else if(!this.dimension.getType().celestial) + else if(!this.dimension.isCelestial()) return 0.0; double r = (double)this.dimension.getSize(); double xm = (Math.abs(x) - r) / 16384.0; diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index 81352b69..01de8f26 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -33,6 +33,7 @@ import common.dimension.Dimension; import common.dimension.Domain; import common.dimension.Galaxy; import common.dimension.Moon; +import common.dimension.Section; import common.dimension.Planet; import common.dimension.Sector; import common.dimension.Semi; @@ -302,57 +303,41 @@ public final class Server implements IThreadListener, Executor { private static void writeDimensions(TagObject tag) { List list = Lists.newArrayList(); - for(Dimension dim : UniverseRegistry.getDimensions()) { - if(dim.isCustom()) { + for(Section obj : UniverseRegistry.getSections()) { + if(obj.isCustom()) { TagObject data = new TagObject(); - data.setString("Type", dim.getType().getName()); - data.setString("Name", UniverseRegistry.getName(dim)); - data.setString("CustomName", dim.getDisplay()); - 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; - } + data.setString("Name", UniverseRegistry.getName(obj)); + data.setString("CustomName", obj.getDisplay()); + if(obj instanceof Dimension dim) { + data.setString("Type", dim.getType().getName()); + switch(dim.getType()) { + case AREA: + data.setString("Domain", UniverseRegistry.getName(UniverseRegistry.getDomain((Area)obj))); + break; + case MOON: + data.setString("Planet", UniverseRegistry.getName(UniverseRegistry.getPlanet((Moon)obj))); + break; + case PLANET: + data.setString("Star", UniverseRegistry.getName(UniverseRegistry.getStar((Planet)obj))); + break; + case STAR: + data.setString("Sector", UniverseRegistry.getName(UniverseRegistry.getSector((Star)obj))); + break; + } + } + else if(obj instanceof Sector sector) { + data.setString("Type", "sector"); + data.setString("Galaxy", UniverseRegistry.getName(UniverseRegistry.getGalaxy(sector))); + } + else if(obj instanceof Galaxy galaxy) { + data.setString("Type", "galaxy"); + } + else if(obj instanceof Domain domain) { + data.setString("Type", "domain"); + } 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.getDisplay()); - 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.getDisplay()); - 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.getDisplay()); - list.add(data); - } - } if(!list.isEmpty()) tag.setList("Dimensions", list); } diff --git a/server/src/main/java/server/command/commands/CommandTime.java b/server/src/main/java/server/command/commands/CommandTime.java index e112ea7a..93ca9cd1 100644 --- a/server/src/main/java/server/command/commands/CommandTime.java +++ b/server/src/main/java/server/command/commands/CommandTime.java @@ -90,7 +90,7 @@ public class CommandTime extends Command { dim.setDayTime(time); dim.resetWeather(); } - exec.log("Zeit auf %s gesetzt", world.formatImperialTime(exec.isPlayer() ? ((Player)exec).getPresentEntity() : null, false)); + exec.log("Zeit auf %s gesetzt", world.formatTime(exec.isPlayer() ? ((Player)exec).getPresentEntity() : null, false)); return time; } } diff --git a/server/src/main/java/server/command/commands/CommandWeather.java b/server/src/main/java/server/command/commands/CommandWeather.java index 7a6ad08b..6bba687c 100644 --- a/server/src/main/java/server/command/commands/CommandWeather.java +++ b/server/src/main/java/server/command/commands/CommandWeather.java @@ -19,7 +19,7 @@ public class CommandWeather extends Command { } public void exec(CommandEnvironment env, Executor exec, Weather weather, WorldServer world, boolean transition) { - if(!world.dimension.getType().weather) + if(!world.dimension.hasWeather()) throw new RunException("Welt %s hat kein Wetter", world.dimension.getDisplay()); else if(world.isExterminated()) throw new RunException("Welt %s ist zerstört", world.dimension.getDisplay()); diff --git a/server/src/main/java/server/network/Player.java b/server/src/main/java/server/network/Player.java index f16bee36..f431a540 100755 --- a/server/src/main/java/server/network/Player.java +++ b/server/src/main/java/server/network/Player.java @@ -992,11 +992,11 @@ public class Player extends User implements Executor, IPlayer { if (list.size() == 1) { - this.sendPacket(getPacket(list.get(0), true, null, !this.entity.worldObj.dimension.hasNoLight())); + this.sendPacket(getPacket(list.get(0), true, null, this.entity.worldObj.dimension.hasSkyLight())); } else { - this.sendPacket(getPacket(list, !this.entity.worldObj.dimension.hasNoLight())); + this.sendPacket(getPacket(list, this.entity.worldObj.dimension.hasSkyLight())); } for (TileEntity tileentity : list1) diff --git a/server/src/main/java/server/world/ChunkServer.java b/server/src/main/java/server/world/ChunkServer.java index 80172a9e..7f7e46e7 100644 --- a/server/src/main/java/server/world/ChunkServer.java +++ b/server/src/main/java/server/world/ChunkServer.java @@ -27,7 +27,7 @@ public class ChunkServer extends Chunk { public ChunkServer(World world, char[] data, int height, boolean base, boolean ceil, Random rand, Biome[] biomes, int x, int z) { this(world, x, z); - boolean sky = !world.dimension.hasNoLight(); + boolean sky = world.dimension.hasSkyLight(); for(int bx = 0; bx < 16; ++bx) { for(int bz = 0; bz < 16; ++bz) { for(int by = 0; by < height; ++by) { diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 2de88353..63d47e2c 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -561,7 +561,7 @@ public class Region { chunk.setInhabited(tag.getLong("InhabitedTime")); List sects = tag.getList("Sections"); BlockArray[] sections = new BlockArray[sects.size()]; - boolean light = !world.dimension.hasNoLight(); + boolean light = world.dimension.hasSkyLight(); for(int n = 0; n < sects.size(); ++n) { TagObject sect = sects.get(n); @@ -685,7 +685,7 @@ public class Region { tag.setLong("InhabitedTime", chunk.getInhabited()); Set sections = chunk.getStorage(); List sects = Lists.newArrayList(); - boolean light = !world.dimension.hasNoLight(); + boolean light = world.dimension.hasSkyLight(); for(BlockArray storage : sections) { if(storage != null) { diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index 156ae78e..6bd70050 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -365,7 +365,7 @@ public final class WorldServer extends AWorldServer { this.dropped.remove(v); } } - int light = this.calculateSkylightSubtracted(true); + int light = this.calcSkylightSubtracted(true); if(light != this.getSkylightSubtracted()) this.setSkylightSubtracted(light); // if(this.primary) @@ -1008,7 +1008,7 @@ public final class WorldServer extends AWorldServer { // } // } - if((this.dimension.getType().weather && !this.dimension.isExterminated()) || force) { + if((this.dimension.hasWeather() && !this.dimension.isExterminated()) || force) { float prevDarkness = this.darkness; float prevRain = this.rain; float prevFog = this.fog; @@ -1070,7 +1070,7 @@ public final class WorldServer extends AWorldServer { } } - if((this.dimension.getType().days || (this.dimension.getType().weather && !this.dimension.isExterminated())) || force) { + if((this.dimension.hasWeather() && !this.dimension.isExterminated()) || force) { float prevTemp = this.temp; float temp = this.getBaseTemperature() + this.weather.getTemperature(); @@ -2633,7 +2633,7 @@ public final class WorldServer extends AWorldServer { ChunkServer chunk = WorldServer.this.getChunk(this.position.x, this.position.z); if(chunk.isPopulated()) { - player.connection.sendPacket(Player.getPacket(chunk, true, new int[0], !WorldServer.this.dimension.hasNoLight())); + player.connection.sendPacket(Player.getPacket(chunk, true, new int[0], WorldServer.this.dimension.hasSkyLight())); } this.watching.remove(player); @@ -2725,7 +2725,7 @@ public final class WorldServer extends AWorldServer { } } this.sendToAllPlayersWatchingChunk(Player.getPacket(WorldServer.this.getChunk(this.position.x, this.position.z), - this.biomes, extend, !WorldServer.this.dimension.hasNoLight())); + this.biomes, extend, WorldServer.this.dimension.hasSkyLight())); if(this.biomes) { List list = WorldServer.this.getTileEntitiesIn(x, Integer.MIN_VALUE, z, x + 16, Integer.MAX_VALUE, z + 16); diff --git a/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java b/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java index 5c3243e4..82279503 100755 --- a/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java +++ b/server/src/main/java/server/worldgen/foliage/FeatureDoublePlant.java @@ -22,7 +22,7 @@ public class FeatureDoublePlant { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 254) && this.type.canPlaceBlockAt(worldIn, blockpos)) + if (worldIn.isAirBlock(blockpos) && (worldIn.dimension.hasSkyLight() || blockpos.getY() < 254) && this.type.canPlaceBlockAt(worldIn, blockpos)) { this.type.placeAt(worldIn, blockpos, 2); flag = true; diff --git a/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java b/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java index d3990ecd..398318d0 100755 --- a/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java +++ b/server/src/main/java/server/worldgen/foliage/WorldGenFlowers.java @@ -29,7 +29,7 @@ public class WorldGenFlowers extends FeatureGenerator { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.state)) + if (worldIn.isAirBlock(blockpos) && (worldIn.dimension.hasSkyLight() || blockpos.getY() < 511) && this.flower.canBlockStay(worldIn, blockpos, this.state)) { worldIn.setState(blockpos, this.state, 2); } diff --git a/server/src/main/java/server/worldgen/foliage/WorldGenMushroom.java b/server/src/main/java/server/worldgen/foliage/WorldGenMushroom.java index 07b999b7..7ea6decb 100755 --- a/server/src/main/java/server/worldgen/foliage/WorldGenMushroom.java +++ b/server/src/main/java/server/worldgen/foliage/WorldGenMushroom.java @@ -21,7 +21,7 @@ public class WorldGenMushroom extends FeatureGenerator { BlockPos blockpos = position.add(rand.zrange(8) - rand.zrange(8), rand.zrange(4) - rand.zrange(4), rand.zrange(8) - rand.zrange(8)); - if (worldIn.isAirBlock(blockpos) && (!worldIn.dimension.hasNoLight() || blockpos.getY() < 511) && this.field_175908_a.canBlockStay(worldIn, blockpos, this.field_175908_a.getState())) + if (worldIn.isAirBlock(blockpos) && (worldIn.dimension.hasSkyLight() || blockpos.getY() < 511) && this.field_175908_a.canBlockStay(worldIn, blockpos, this.field_175908_a.getState())) { worldIn.setState(blockpos, this.field_175908_a.getState(), 2); }