Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c0135b4acb | ||
![]() |
77b05e1b09 | ||
![]() |
e78878c8cc | ||
![]() |
8834e2bdcd | ||
![]() |
6aae6f32e4 | ||
![]() |
aa772848ed |
73 changed files with 530 additions and 1966 deletions
|
@ -95,7 +95,6 @@ import client.window.Wheel;
|
||||||
import client.window.Window;
|
import client.window.Window;
|
||||||
import client.window.WindowEvent;
|
import client.window.WindowEvent;
|
||||||
import client.world.WorldClient;
|
import client.world.WorldClient;
|
||||||
import common.biome.Biome;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
|
@ -157,9 +156,7 @@ import common.util.LazyLoadBase;
|
||||||
import common.util.Util;
|
import common.util.Util;
|
||||||
import common.util.HitPosition.ObjectType;
|
import common.util.HitPosition.ObjectType;
|
||||||
import common.world.Chunk;
|
import common.world.Chunk;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelException;
|
import io.netty.channel.ChannelException;
|
||||||
|
@ -427,8 +424,9 @@ public class Client implements IThreadListener {
|
||||||
public int soundBufferSize = 2048;
|
public int soundBufferSize = 2048;
|
||||||
@Variable(name = "snd_frame_size", category = CVarCategory.SOUND, min = 2, max = 8192, display = "PCM-Intervall")
|
@Variable(name = "snd_frame_size", category = CVarCategory.SOUND, min = 2, max = 8192, display = "PCM-Intervall")
|
||||||
public int soundFrameSize = 32;
|
public int soundFrameSize = 32;
|
||||||
|
|
||||||
private String serverInfo;
|
private String serverInfo;
|
||||||
|
private String tickInfo;
|
||||||
private int lastTickTime = -1;
|
private int lastTickTime = -1;
|
||||||
private AudioInterface audio;
|
private AudioInterface audio;
|
||||||
private boolean cfgDirty;
|
private boolean cfgDirty;
|
||||||
|
@ -1653,10 +1651,11 @@ public class Client implements IThreadListener {
|
||||||
this.serverInfo = info;
|
this.serverInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastTick(int time) {
|
public void setLastTick(int time, String info) {
|
||||||
if(this.lastTickTime >= 0) {
|
if(this.lastTickTime >= 0) {
|
||||||
this.lastTicked = System.currentTimeMillis();
|
this.lastTicked = System.currentTimeMillis();
|
||||||
this.lastTickTime = time;
|
this.lastTickTime = time;
|
||||||
|
this.tickInfo = info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1730,30 +1729,20 @@ public class Client implements IThreadListener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Biome biome = null;
|
String light;
|
||||||
String bline;
|
|
||||||
String lline;
|
|
||||||
if(this.world.isBlockLoaded(blockpos)) {
|
if(this.world.isBlockLoaded(blockpos)) {
|
||||||
Chunk chunk = this.world.getChunk(blockpos);
|
Chunk chunk = this.world.getChunk(blockpos);
|
||||||
biome = chunk.getBiome(blockpos, null);
|
light = "Licht: " + chunk.getLightSub(blockpos, 0) + " ("
|
||||||
bline = "Biom: " + biome.display + " (" + biome.id + ")" + /* (this.debugHideInfo ? "" : */ (", D: " +
|
+ chunk.getLight(blockpos) + " Blöcke, " + String.format(
|
||||||
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
|
||||||
" (" + this.world.dimension.getDimensionId() + ")");
|
|
||||||
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: "
|
"%.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 {
|
else {
|
||||||
bline = "Biom: <?>, D: " +
|
light = "Licht: " + String.format(
|
||||||
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
|
||||||
" (" + this.world.dimension.getDimensionId() + ")";
|
|
||||||
lline = "Licht: " + String.format(
|
|
||||||
"%.1f", this.world.getSunBrightness(1.0f) * 15.0f) + " Welt, A: "
|
"%.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 = this.world.getTempOffset() + (biome != null ? biome.getTemperature(blockpos) : 0.0f);
|
|
||||||
long ticked = System.currentTimeMillis() - this.lastTicked;
|
long ticked = System.currentTimeMillis() - this.lastTicked;
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -1778,8 +1767,10 @@ public class Client implements IThreadListener {
|
||||||
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
String.format(" (Zoom x%.1f)", this.zoomLevel) : "") + "\n" +
|
||||||
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
String.format("Richtung: %s (%.1f / %.1f)", dirStr,
|
||||||
ExtMath.wrapf(entity.rotYaw), ExtMath.wrapf(entity.rotPitch)) + "\n" +
|
ExtMath.wrapf(entity.rotYaw), ExtMath.wrapf(entity.rotPitch)) + "\n" +
|
||||||
bline + "\n" +
|
"Dimension: " + (this.world.isExterminated() ? "[zerstört] " : "") +
|
||||||
lline + "\n" +
|
TextColor.stripCodes(this.world.dimension.getFormattedName(false)) +
|
||||||
|
" (" + this.world.dimension.getDimensionId() + ")" + "\n" +
|
||||||
|
light + "\n" +
|
||||||
String.format("Zeit: %d T, R %d / %d T, U %d / %d T",
|
String.format("Zeit: %d T, R %d / %d T, U %d / %d T",
|
||||||
this.world.getDayTime(),
|
this.world.getDayTime(),
|
||||||
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
this.world.getDayTime() % this.world.dimension.getRotationalPeriod(),
|
||||||
|
@ -1787,10 +1778,7 @@ public class Client implements IThreadListener {
|
||||||
this.world.getDayTime() % this.world.dimension.getOrbitalPeriod(),
|
this.world.getDayTime() % this.world.dimension.getOrbitalPeriod(),
|
||||||
this.world.dimension.getOrbitalPeriod()
|
this.world.dimension.getOrbitalPeriod()
|
||||||
) + "\n" +
|
) + "\n" +
|
||||||
String.format("Laub: %s%s, T: %.2f K / %.2f °C, %s (R %.1f, %.1f)",
|
String.format("Wetter: %s (R %.1f, %.1f)",
|
||||||
!this.world.dimension.getType().days ? "*" : "",
|
|
||||||
this.world.getLeavesGen(blockpos).getDisplayName(),
|
|
||||||
temp, World.ABSOLUTE_ZERO + temp,
|
|
||||||
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
|
this.world.getWeather().getDisplay(), this.world.getRainStrength(),
|
||||||
this.world.getDarkness()
|
this.world.getDarkness()
|
||||||
) + "\n" +
|
) + "\n" +
|
||||||
|
@ -1800,7 +1788,8 @@ public class Client implements IThreadListener {
|
||||||
String.format("Letzte Zeitsynch.: + %d.%d s",
|
String.format("Letzte Zeitsynch.: + %d.%d s",
|
||||||
ticked / 1000L, (ticked / 100L) % 10L
|
ticked / 1000L, (ticked / 100L) % 10L
|
||||||
) +
|
) +
|
||||||
(this.serverInfo != null ? "\n" + this.serverInfo : "")
|
(this.serverInfo != null ? "\n" + this.serverInfo : "") +
|
||||||
|
(this.tickInfo != null ? "\n" + this.tickInfo : "")
|
||||||
// IWorldServer world = this.server.getWorld(this.theWorld.dimension.getDimensionId());
|
// IWorldServer world = this.server.getWorld(this.theWorld.dimension.getDimensionId());
|
||||||
// if(world != null)
|
// if(world != null)
|
||||||
// list.add("Seed: " + world.getSeed());
|
// list.add("Seed: " + world.getSeed());
|
||||||
|
@ -1867,7 +1856,7 @@ public class Client implements IThreadListener {
|
||||||
"Eigens.: " + (entity.dead ? "D" : " ") + (entity.noClip ? "N" : " ") + (entity.onGround ? "G" : " ")
|
"Eigens.: " + (entity.dead ? "D" : " ") + (entity.noClip ? "N" : " ") + (entity.onGround ? "G" : " ")
|
||||||
+ (entity.canBeCollidedWith() ? "C" : " ") + (entity.canBePushed() ? "P" : " ")
|
+ (entity.canBeCollidedWith() ? "C" : " ") + (entity.canBePushed() ? "P" : " ")
|
||||||
+ (entity.isBurning() ? "B" : " ") // + (entity.isInvisible() ? "I" : " ") // + (entity.isSilent() ? "S" : " ")
|
+ (entity.isBurning() ? "B" : " ") // + (entity.isInvisible() ? "I" : " ") // + (entity.isSilent() ? "S" : " ")
|
||||||
+ (entity.isWet() ? "W" : " ") + (entity.canAttackWithItem() ? "A" : " ")
|
+ (entity.canAttackWithItem() ? "A" : " ")
|
||||||
+ (entity.passenger != null ? "H" : " ") + (entity.vehicle != null ? "R" : " ") + (entity instanceof EntityLiving ?
|
+ (entity.passenger != null ? "H" : " ") + (entity.vehicle != null ? "R" : " ") + (entity instanceof EntityLiving ?
|
||||||
("+" /* + (((EntityLivingBase)entity).isEntityUndead() ? "U" : " ") */ // + (((EntityLivingBase)entity).isChild() ? "C" : " ")
|
("+" /* + (((EntityLivingBase)entity).isEntityUndead() ? "U" : " ") */ // + (((EntityLivingBase)entity).isChild() ? "C" : " ")
|
||||||
+ (((EntityLiving)entity).doesEntityNotTriggerPressurePlate() ? "P" : " ")) : "") + "\n" +
|
+ (((EntityLiving)entity).doesEntityNotTriggerPressurePlate() ? "P" : " ")) : "") + "\n" +
|
||||||
|
@ -2609,6 +2598,7 @@ public class Client implements IThreadListener {
|
||||||
if(Client.this.lastTickTime >= 0) {
|
if(Client.this.lastTickTime >= 0) {
|
||||||
Client.this.performAction(Action.STOP_PROFILING);
|
Client.this.performAction(Action.STOP_PROFILING);
|
||||||
Client.this.lastTickTime = -1;
|
Client.this.lastTickTime = -1;
|
||||||
|
Client.this.tickInfo = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Client.this.performAction(Action.START_PROFILING);
|
Client.this.performAction(Action.START_PROFILING);
|
||||||
|
|
|
@ -94,7 +94,6 @@ import common.packet.S39PacketPlayerAbilities;
|
||||||
import common.packet.S3APacketTabComplete;
|
import common.packet.S3APacketTabComplete;
|
||||||
import common.packet.S43PacketUpdateEntityNBT;
|
import common.packet.S43PacketUpdateEntityNBT;
|
||||||
import common.packet.SPacketAnimation;
|
import common.packet.SPacketAnimation;
|
||||||
import common.packet.SPacketBiomes;
|
|
||||||
import common.packet.SPacketBlockAction;
|
import common.packet.SPacketBlockAction;
|
||||||
import common.packet.SPacketBlockBreakAnim;
|
import common.packet.SPacketBlockBreakAnim;
|
||||||
import common.packet.SPacketBlockChange;
|
import common.packet.SPacketBlockChange;
|
||||||
|
@ -753,7 +752,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
||||||
{
|
{
|
||||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
||||||
|
|
||||||
if (packetIn.hasBiomes())
|
if (packetIn.isResend())
|
||||||
{
|
{
|
||||||
if (packetIn.getExtractedSize() == 0)
|
if (packetIn.getExtractedSize() == 0)
|
||||||
{
|
{
|
||||||
|
@ -766,23 +765,15 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
||||||
|
|
||||||
// this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
// this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
||||||
Chunk chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
|
Chunk chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
|
||||||
chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedSize(), packetIn.hasBiomes());
|
chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedSize(), packetIn.isResend());
|
||||||
this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
||||||
|
|
||||||
if (!packetIn.hasBiomes() || this.clientWorldController.dimension.hasNoLight()) // TODO: check
|
if (!packetIn.isResend() || this.clientWorldController.dimension.hasNoLight()) // TODO: check
|
||||||
{
|
{
|
||||||
chunk.resetRelight();
|
chunk.resetRelight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleBiomes(SPacketBiomes packetIn)
|
|
||||||
{
|
|
||||||
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
|
|
||||||
Chunk chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
|
|
||||||
chunk.setBiomes(packetIn.getBiomes());
|
|
||||||
this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the block and metadata and generates a blockupdate (and notify the clients)
|
* Updates the block and metadata and generates a blockupdate (and notify the clients)
|
||||||
*/
|
*/
|
||||||
|
@ -998,7 +989,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
||||||
public void handleServerTick(SPacketServerTick packet)
|
public void handleServerTick(SPacketServerTick packet)
|
||||||
{
|
{
|
||||||
NetHandler.checkThread(packet, this, this.gameController);
|
NetHandler.checkThread(packet, this, this.gameController);
|
||||||
this.gameController.setLastTick(packet.getTime());
|
this.gameController.setLastTick(packet.getTime(), packet.getServerinfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void handleCompass(SPacketCompass packetIn)
|
// public void handleCompass(SPacketCompass packetIn)
|
||||||
|
@ -1441,9 +1432,6 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
|
||||||
case FOG_STRENGTH:
|
case FOG_STRENGTH:
|
||||||
this.clientWorldController.setFogStrength(packetIn.getFloat(true));
|
this.clientWorldController.setFogStrength(packetIn.getFloat(true));
|
||||||
break;
|
break;
|
||||||
case TEMPERATURE:
|
|
||||||
this.clientWorldController.setTemperature(packetIn.getFloat(false));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import client.renderer.particle.EffectRenderer;
|
||||||
import client.renderer.texture.DynamicTexture;
|
import client.renderer.texture.DynamicTexture;
|
||||||
import client.renderer.texture.TextureMap;
|
import client.renderer.texture.TextureMap;
|
||||||
import client.world.WorldClient;
|
import client.world.WorldClient;
|
||||||
import common.biome.Biome;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.entity.Entity;
|
import common.entity.Entity;
|
||||||
import common.entity.npc.EntityNPC;
|
import common.entity.npc.EntityNPC;
|
||||||
|
@ -1143,11 +1142,10 @@ public class EntityRenderer {
|
||||||
|
|
||||||
for (int l = 0; l < k; ++l)
|
for (int l = 0; l < k; ++l)
|
||||||
{
|
{
|
||||||
BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i)));
|
BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.zrange(i) - this.random.zrange(i), 0, this.random.zrange(i) - this.random.zrange(i)), blockpos.getY() + 48, 64);
|
||||||
Biome biomegenbase = world.getBiomeGenForCoords(blockpos1);
|
|
||||||
BlockPos blockpos2 = blockpos1.down();
|
BlockPos blockpos2 = blockpos1.down();
|
||||||
Block block = world.getState(blockpos2).getBlock();
|
Block block = world.getState(blockpos2).getBlock();
|
||||||
float temp = World.ABSOLUTE_ZERO + world.getTempOffset() + biomegenbase.getTemperature(blockpos1);
|
float temp = 10.0f; // world.getTemperatureC(blockpos1); TODO: fix particles
|
||||||
|
|
||||||
if (blockpos1.getY() <= blockpos.getY() + i && blockpos1.getY() >= blockpos.getY() - i && /* biomegenbase.canRain() && */ temp > 0.0F)
|
if (blockpos1.getY() <= blockpos.getY() + i && blockpos1.getY() >= blockpos.getY() - i && /* biomegenbase.canRain() && */ temp > 0.0F)
|
||||||
{
|
{
|
||||||
|
@ -1189,7 +1187,7 @@ public class EntityRenderer {
|
||||||
{
|
{
|
||||||
this.rainSoundCounter = 0;
|
this.rainSoundCounter = 0;
|
||||||
|
|
||||||
if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos).getY() > ExtMath.floorf((float)blockpos.getY()))
|
if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos, blockpos.getY() + 46, 48).getY() > ExtMath.floorf((float)blockpos.getY()))
|
||||||
{
|
{
|
||||||
this.gm.world.playSound(d0, d1, d2, n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.2f : 0.1F);
|
this.gm.world.playSound(d0, d1, d2, n >= j ? this.pickMoltenSound() : SoundEvent.RAIN, n >= j ? 0.2f : 0.1F);
|
||||||
}
|
}
|
||||||
|
@ -1253,11 +1251,10 @@ public class EntityRenderer {
|
||||||
double d3 = (double)this.rainXCoords[i2] * 0.5D;
|
double d3 = (double)this.rainXCoords[i2] * 0.5D;
|
||||||
double d4 = (double)this.rainYCoords[i2] * 0.5D;
|
double d4 = (double)this.rainYCoords[i2] * 0.5D;
|
||||||
blockpos$mutableblockpos.set(l1, 0, k1);
|
blockpos$mutableblockpos.set(l1, 0, k1);
|
||||||
Biome biomegenbase = world.getBiomeGenForCoords(blockpos$mutableblockpos);
|
|
||||||
|
|
||||||
// if (biomegenbase.canRain() || biomegenbase.isSnowyBiome())
|
// if (biomegenbase.canRain() || biomegenbase.isSnowyBiome())
|
||||||
// {
|
// {
|
||||||
int j2 = world.getPrecipitationHeight(blockpos$mutableblockpos).getY();
|
int j2 = world.getPrecipitationHeight(blockpos$mutableblockpos, ExtMath.floord(d1) + 48, 64).getY();
|
||||||
int k2 = j - i1;
|
int k2 = j - i1;
|
||||||
int l2 = j + i1;
|
int l2 = j + i1;
|
||||||
|
|
||||||
|
@ -1282,7 +1279,7 @@ public class EntityRenderer {
|
||||||
{
|
{
|
||||||
this.random.setSeed((long)(l1 * l1 * 3121 + l1 * 45238971 ^ k1 * k1 * 418711 + k1 * 13761));
|
this.random.setSeed((long)(l1 * l1 * 3121 + l1 * 45238971 ^ k1 * k1 * 418711 + k1 * 13761));
|
||||||
blockpos$mutableblockpos.set(l1, k2, k1);
|
blockpos$mutableblockpos.set(l1, k2, k1);
|
||||||
float f2 = World.ABSOLUTE_ZERO + world.getTempOffset() + biomegenbase.getTemperature(blockpos$mutableblockpos);
|
float f2 = 10.0f; // world.getTemperatureC(blockpos$mutableblockpos); TODO: fix particles
|
||||||
|
|
||||||
if(f2 >= 194.0f)
|
if(f2 >= 194.0f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,6 @@ package client.renderer;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import common.biome.Biome;
|
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
|
@ -11,7 +10,6 @@ import common.util.Vec3i;
|
||||||
import common.world.Chunk;
|
import common.world.Chunk;
|
||||||
import common.world.ChunkCache;
|
import common.world.ChunkCache;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
|
@ -114,29 +112,19 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
||||||
|
|
||||||
public int getLight(BlockPos pos, int lightValue)
|
public int getLight(BlockPos pos, int lightValue)
|
||||||
{
|
{
|
||||||
int i = this.getLightForExt(LightType.SKY, pos);
|
int j = this.getLightForExt(pos);
|
||||||
int j = this.getLightForExt(LightType.BLOCK, pos);
|
|
||||||
|
|
||||||
if (j < lightValue)
|
if (j < lightValue)
|
||||||
{
|
{
|
||||||
j = lightValue;
|
j = lightValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i << 20 | j << 4;
|
return 15 << 20 | j << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiomeGenForCoords(BlockPos pos)
|
private int getLightForExt(BlockPos pos)
|
||||||
{
|
{
|
||||||
return this.worldObj.getBiomeGenForCoords(pos);
|
if (pos.getY() >= 0 && pos.getY() < 512)
|
||||||
}
|
|
||||||
|
|
||||||
private int getLightForExt(LightType p_175629_1_, BlockPos pos)
|
|
||||||
{
|
|
||||||
if (p_175629_1_ == LightType.SKY && this.worldObj.dimension.hasNoLight())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (pos.getY() >= 0 && pos.getY() < 512)
|
|
||||||
{
|
{
|
||||||
if (this.getState(pos).getBlock().getSumBrightness())
|
if (this.getState(pos).getBlock().getSumBrightness())
|
||||||
{
|
{
|
||||||
|
@ -144,7 +132,7 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
||||||
|
|
||||||
for (Facing enumfacing : Facing.values())
|
for (Facing enumfacing : Facing.values())
|
||||||
{
|
{
|
||||||
int k = this.getLightFor(p_175629_1_, pos.offset(enumfacing));
|
int k = this.getLightFor(pos.offset(enumfacing));
|
||||||
|
|
||||||
if (k > l)
|
if (k > l)
|
||||||
{
|
{
|
||||||
|
@ -163,12 +151,12 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
||||||
{
|
{
|
||||||
int i = (pos.getX() >> 4) - this.chunkX;
|
int i = (pos.getX() >> 4) - this.chunkX;
|
||||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||||
return this.chunkArray[i][j].getLight(p_175629_1_, pos);
|
return this.chunkArray[i][j].getLight(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return p_175629_1_.defValue;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,17 +169,17 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
|
||||||
// return this.getBlockState(pos).getBlock().getMaterial() == Material.air;
|
// return this.getBlockState(pos).getBlock().getMaterial() == Material.air;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public int getLightFor(LightType p_175628_1_, BlockPos pos)
|
public int getLightFor(BlockPos pos)
|
||||||
{
|
{
|
||||||
if (pos.getY() >= 0 && pos.getY() < 512)
|
if (pos.getY() >= 0 && pos.getY() < 512)
|
||||||
{
|
{
|
||||||
int i = (pos.getX() >> 4) - this.chunkX;
|
int i = (pos.getX() >> 4) - this.chunkX;
|
||||||
int j = (pos.getZ() >> 4) - this.chunkZ;
|
int j = (pos.getZ() >> 4) - this.chunkZ;
|
||||||
return this.chunkArray[i][j].getLight(p_175628_1_, pos);
|
return this.chunkArray[i][j].getLight(pos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return p_175628_1_.defValue;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package client.renderer.entity;
|
package client.renderer.entity;
|
||||||
|
|
||||||
import client.renderer.GlState;
|
|
||||||
import client.renderer.layers.LayerWolfCollar;
|
import client.renderer.layers.LayerWolfCollar;
|
||||||
import client.renderer.model.ModelBase;
|
import client.renderer.model.ModelBase;
|
||||||
import common.entity.animal.EntityWolf;
|
import common.entity.animal.EntityWolf;
|
||||||
|
@ -25,21 +24,7 @@ public class RenderWolf extends RenderLiving<EntityWolf>
|
||||||
{
|
{
|
||||||
return livingBase.getTailRotation();
|
return livingBase.getTailRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the desired {@code T} type Entity.
|
|
||||||
*/
|
|
||||||
public void doRender(EntityWolf entity, double x, double y, double z, float partialTicks)
|
|
||||||
{
|
|
||||||
if (entity.isWolfWet())
|
|
||||||
{
|
|
||||||
float f = entity.getBrightness(partialTicks) * entity.getShadingWhileWet(partialTicks);
|
|
||||||
GlState.color(f, f, f, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
super.doRender(entity, x, y, z, partialTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -157,10 +157,7 @@ public class ModelWolf extends ModelBase
|
||||||
this.wolfLeg4.rotateAngleX = ExtMath.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_;
|
this.wolfLeg4.rotateAngleX = ExtMath.cos(p_78086_2_ * 0.6662F) * 1.4F * p_78086_3_;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.wolfHeadMain.rotateAngleZ = entitywolf.getInterestedAngle(partialTickTime) + entitywolf.getShakeAngle(partialTickTime, 0.0F);
|
this.wolfHeadMain.rotateAngleZ = entitywolf.getInterestedAngle(partialTickTime);
|
||||||
this.wolfMane.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.08F);
|
|
||||||
this.wolfBody.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.16F);
|
|
||||||
this.wolfTail.rotateAngleZ = entitywolf.getShakeAngle(partialTickTime, -0.2F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,23 +10,12 @@ import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.BoundingBox;
|
import common.util.BoundingBox;
|
||||||
import common.world.Chunk;
|
import common.world.Chunk;
|
||||||
import common.world.LightType;
|
|
||||||
|
|
||||||
public class EmptyChunk extends Chunk {
|
public class EmptyChunk extends Chunk {
|
||||||
public EmptyChunk(WorldClient world) {
|
public EmptyChunk(WorldClient world) {
|
||||||
super(world, 0, 0);
|
super(world, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight(int x, int z) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void genHeights() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void genSkyLight() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Block getBlock(BlockPos pos) {
|
public Block getBlock(BlockPos pos) {
|
||||||
return Blocks.air;
|
return Blocks.air;
|
||||||
}
|
}
|
||||||
|
@ -39,11 +28,11 @@ public class EmptyChunk extends Chunk {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLight(LightType type, BlockPos pos) {
|
public int getLight(BlockPos pos) {
|
||||||
return type.defValue;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLight(LightType type, BlockPos pos, int value) {
|
public void setLight(BlockPos pos, int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLightSub(BlockPos pos, int amount) {
|
public int getLightSub(BlockPos pos, int amount) {
|
||||||
|
@ -56,10 +45,6 @@ public class EmptyChunk extends Chunk {
|
||||||
public void removeEntity(Entity entity) {
|
public void removeEntity(Entity entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSeeSky(BlockPos pos) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) {
|
public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package client.world;
|
package client.world;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import client.Client;
|
import client.Client;
|
||||||
import client.renderer.particle.EntityFX;
|
import client.renderer.particle.EntityFX;
|
||||||
import client.renderer.particle.EntityFirework;
|
import client.renderer.particle.EntityFirework;
|
||||||
import common.biome.Biome;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
|
import common.collect.Maps;
|
||||||
import common.collect.Sets;
|
import common.collect.Sets;
|
||||||
import common.dimension.Dimension;
|
import common.dimension.Dimension;
|
||||||
import common.entity.Entity;
|
import common.entity.Entity;
|
||||||
|
@ -30,7 +31,6 @@ import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ChunkPos;
|
import common.util.ChunkPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.LongHashMap;
|
|
||||||
import common.util.Vec3;
|
import common.util.Vec3;
|
||||||
import common.util.BlockPos.MutableBlockPos;
|
import common.util.BlockPos.MutableBlockPos;
|
||||||
import common.world.Chunk;
|
import common.world.Chunk;
|
||||||
|
@ -45,12 +45,13 @@ public class WorldClient extends AWorldClient
|
||||||
private final Set<Entity> entityList = Sets.<Entity>newHashSet();
|
private final Set<Entity> entityList = Sets.<Entity>newHashSet();
|
||||||
private final Set<Entity> spawnQueue = Sets.<Entity>newHashSet();
|
private final Set<Entity> spawnQueue = Sets.<Entity>newHashSet();
|
||||||
private final Set<ChunkPos> previousActive = Sets.<ChunkPos>newHashSet();
|
private final Set<ChunkPos> previousActive = Sets.<ChunkPos>newHashSet();
|
||||||
private final LongHashMap<Chunk> chunkMapping = new LongHashMap();
|
private final Map<ChunkPos, Chunk> chunkMapping = Maps.newHashMap();
|
||||||
private final List<Chunk> chunkListing = Lists.<Chunk>newArrayList();
|
private final List<Chunk> chunkListing = Lists.<Chunk>newArrayList();
|
||||||
private final Chunk blankChunk = new EmptyChunk(this);
|
private final Chunk blankChunk = new EmptyChunk(this);
|
||||||
// public final Profiler profiler;
|
// public final Profiler profiler;
|
||||||
protected int lastLightning;
|
protected int lastLightning;
|
||||||
protected Vec3 lightColor = new Vec3(0xffffff);
|
protected Vec3 lightColor = new Vec3(0xffffff);
|
||||||
|
protected boolean exterminated;
|
||||||
|
|
||||||
public WorldClient(Client gm, boolean debug, Dimension dim)
|
public WorldClient(Client gm, boolean debug, Dimension dim)
|
||||||
{
|
{
|
||||||
|
@ -85,7 +86,7 @@ public class WorldClient extends AWorldClient
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
for (Chunk chunk : this.chunkListing)
|
for (Chunk chunk : this.chunkListing)
|
||||||
{
|
{
|
||||||
chunk.update(System.currentTimeMillis() - time > 5L);
|
chunk.update();
|
||||||
}
|
}
|
||||||
if (System.currentTimeMillis() - time > 100L)
|
if (System.currentTimeMillis() - time > 100L)
|
||||||
{
|
{
|
||||||
|
@ -127,12 +128,13 @@ public class WorldClient extends AWorldClient
|
||||||
|
|
||||||
public void doPreChunk(int x, int z, boolean load)
|
public void doPreChunk(int x, int z, boolean load)
|
||||||
{
|
{
|
||||||
|
ChunkPos pos = new ChunkPos(x, z);
|
||||||
if (load)
|
if (load)
|
||||||
{
|
{
|
||||||
if(this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z)) != null)
|
if(this.chunkMapping.get(pos) != null)
|
||||||
this.doPreChunk(x, z, false);
|
this.doPreChunk(x, z, false);
|
||||||
Chunk chunk = new Chunk(this, x, z);
|
Chunk chunk = new Chunk(this, x, z);
|
||||||
this.chunkMapping.add(LongHashMap.packInt(x, z), chunk);
|
this.chunkMapping.put(pos, chunk);
|
||||||
this.chunkListing.add(chunk);
|
this.chunkListing.add(chunk);
|
||||||
chunk.setLoaded(true);
|
chunk.setLoaded(true);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +145,7 @@ public class WorldClient extends AWorldClient
|
||||||
{
|
{
|
||||||
chunk.onChunkUnload();
|
chunk.onChunkUnload();
|
||||||
}
|
}
|
||||||
this.chunkMapping.remove(LongHashMap.packInt(x, z));
|
this.chunkMapping.remove(pos);
|
||||||
this.chunkListing.remove(chunk);
|
this.chunkListing.remove(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,13 +355,13 @@ public class WorldClient extends AWorldClient
|
||||||
|
|
||||||
public Chunk getChunk(int x, int z)
|
public Chunk getChunk(int x, int z)
|
||||||
{
|
{
|
||||||
Chunk chunk = this.chunkMapping.getValueByKey(LongHashMap.packInt(x, z));
|
Chunk chunk = this.chunkMapping.get(new ChunkPos(x, z));
|
||||||
return chunk == null ? this.blankChunk : chunk;
|
return chunk == null ? this.blankChunk : chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInfo()
|
public String getInfo()
|
||||||
{
|
{
|
||||||
return "Chunk-Cache: M " + this.chunkMapping.getNumHashElements() + ", L " + this.chunkListing.size();
|
return "Chunk-Cache: M " + this.chunkMapping.size() + ", L " + this.chunkListing.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playSound(SoundEvent sound, double x, double y, double z, float volume)
|
public void playSound(SoundEvent sound, double x, double y, double z, float volume)
|
||||||
|
@ -757,19 +759,16 @@ public class WorldClient extends AWorldClient
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vec3 getSkyColor(Entity entity, float partial) {
|
public Vec3 getSkyColor(Entity entity, float partial) {
|
||||||
BlockPos pos = new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
|
|
||||||
ExtMath.floord(entity.posZ));
|
|
||||||
Biome biome = this.getBiomeGenForCoords(pos);
|
|
||||||
Vec3 vec;
|
Vec3 vec;
|
||||||
if(biome.skyColor != 0xffffffff)
|
if(this.exterminated)
|
||||||
vec = new Vec3(biome.skyColor);
|
vec = new Vec3(0x101010);
|
||||||
else
|
else
|
||||||
vec = new Vec3(this.dimension.getSkyColor());
|
vec = new Vec3(this.dimension.getSkyColor());
|
||||||
if(this.dimension.getType().days) {
|
if(this.dimension.getType().days) {
|
||||||
float mult = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partial) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
|
float mult = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partial) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
|
||||||
0.0F, 1.0F);
|
0.0F, 1.0F);
|
||||||
if(this.dimension.getSkyColor() == 0xffffffff) {
|
if(this.dimension.getSkyColor() == 0xffffffff) {
|
||||||
float temp = ExtMath.clampf(((biome.getTemperature(pos) + 14.0f) / 40.0f + 0.15f) / 3.0F,
|
float temp = ExtMath.clampf(((0.0f /* temp */ + 14.0f) / 40.0f + 0.15f) / 3.0F,
|
||||||
-1.0F, 1.0F);
|
-1.0F, 1.0F);
|
||||||
Vec3 sky = new Vec3(hsvToRGB(0.62222224F - temp * 0.05F, 0.5F + temp * 0.1F, 1.0F));
|
Vec3 sky = new Vec3(hsvToRGB(0.62222224F - temp * 0.05F, 0.5F + temp * 0.1F, 1.0F));
|
||||||
vec = new Vec3(vec.xCoord * sky.xCoord * mult, vec.yCoord * sky.yCoord * mult, vec.zCoord * sky.zCoord * mult);
|
vec = new Vec3(vec.xCoord * sky.xCoord * mult, vec.yCoord * sky.yCoord * mult, vec.zCoord * sky.zCoord * mult);
|
||||||
|
@ -815,10 +814,8 @@ public class WorldClient extends AWorldClient
|
||||||
|
|
||||||
public Vec3 getCloudColour(Entity entity, float partialTicks) {
|
public Vec3 getCloudColour(Entity entity, float partialTicks) {
|
||||||
Vec3 color = new Vec3(this.dimension.getCloudColor());
|
Vec3 color = new Vec3(this.dimension.getCloudColor());
|
||||||
Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
|
if(this.exterminated)
|
||||||
ExtMath.floord(entity.posZ)));
|
color = new Vec3(0x000000);
|
||||||
if(biome.cloudColor != 0xffffffff)
|
|
||||||
color = new Vec3(biome.cloudColor);
|
|
||||||
float r = (float)color.xCoord;
|
float r = (float)color.xCoord;
|
||||||
float g = (float)color.yCoord;
|
float g = (float)color.yCoord;
|
||||||
float b = (float)color.zCoord;
|
float b = (float)color.zCoord;
|
||||||
|
@ -854,10 +851,8 @@ public class WorldClient extends AWorldClient
|
||||||
|
|
||||||
public Vec3 getFogColor(Entity entity, float partialTicks) {
|
public Vec3 getFogColor(Entity entity, float partialTicks) {
|
||||||
Vec3 color = new Vec3(this.dimension.getFogColor());
|
Vec3 color = new Vec3(this.dimension.getFogColor());
|
||||||
Biome biome = this.getBiomeGenForCoords(new BlockPos(ExtMath.floord(entity.posX), ExtMath.floord(entity.posY),
|
if(this.exterminated)
|
||||||
ExtMath.floord(entity.posZ)));
|
color = new Vec3(0x303030);
|
||||||
if(biome.fogColor != 0xffffffff)
|
|
||||||
color = new Vec3(biome.fogColor);
|
|
||||||
if(!this.dimension.getType().days)
|
if(!this.dimension.getType().days)
|
||||||
return color;
|
return color;
|
||||||
float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partialTicks) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
|
float sun = ExtMath.clampf(ExtMath.cos(this.getCelestialAngle(partialTicks) * (float)Math.PI * 2.0F) * 2.0F + 0.5F,
|
||||||
|
@ -930,4 +925,12 @@ public class WorldClient extends AWorldClient
|
||||||
public boolean hasNoChunks() {
|
public boolean hasNoChunks() {
|
||||||
return this.chunkListing.isEmpty();
|
return this.chunkListing.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExterminated(boolean exterminated) {
|
||||||
|
this.exterminated = exterminated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExterminated() {
|
||||||
|
return this.exterminated;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
package common.ai;
|
|
||||||
|
|
||||||
import common.entity.types.EntityLiving;
|
|
||||||
import common.rng.Random;
|
|
||||||
import common.util.BlockPos;
|
|
||||||
import common.util.Vec3;
|
|
||||||
import common.world.World;
|
|
||||||
import common.world.AWorldServer;
|
|
||||||
|
|
||||||
public class EntityAIFleeSun extends EntityAIBase
|
|
||||||
{
|
|
||||||
private EntityLiving theCreature;
|
|
||||||
private double shelterX;
|
|
||||||
private double shelterY;
|
|
||||||
private double shelterZ;
|
|
||||||
private double movementSpeed;
|
|
||||||
private World theWorld;
|
|
||||||
|
|
||||||
public EntityAIFleeSun(EntityLiving theCreatureIn, double movementSpeedIn)
|
|
||||||
{
|
|
||||||
this.theCreature = theCreatureIn;
|
|
||||||
this.movementSpeed = movementSpeedIn;
|
|
||||||
this.theWorld = theCreatureIn.worldObj;
|
|
||||||
this.setMutexBits(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the EntityAIBase should begin execution.
|
|
||||||
*/
|
|
||||||
public boolean shouldExecute()
|
|
||||||
{
|
|
||||||
if (!((AWorldServer)this.theWorld).isDaytime())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!this.theCreature.isBurning())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (!this.theWorld.canSeeSky(new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ)))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vec3 vec3 = this.findPossibleShelter();
|
|
||||||
|
|
||||||
if (vec3 == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.shelterX = vec3.xCoord;
|
|
||||||
this.shelterY = vec3.yCoord;
|
|
||||||
this.shelterZ = vec3.zCoord;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether an in-progress EntityAIBase should continue executing
|
|
||||||
*/
|
|
||||||
public boolean continueExecuting()
|
|
||||||
{
|
|
||||||
return !this.theCreature.getNavigator().noPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a one shot task or start executing a continuous task
|
|
||||||
*/
|
|
||||||
public void startExecuting()
|
|
||||||
{
|
|
||||||
this.theCreature.getNavigator().tryMoveToXYZ(this.shelterX, this.shelterY, this.shelterZ, this.movementSpeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Vec3 findPossibleShelter()
|
|
||||||
{
|
|
||||||
Random random = this.theCreature.getRNG();
|
|
||||||
BlockPos blockpos = new BlockPos(this.theCreature.posX, this.theCreature.getEntityBoundingBox().minY, this.theCreature.posZ);
|
|
||||||
|
|
||||||
for (int i = 0; i < 10; ++i)
|
|
||||||
{
|
|
||||||
BlockPos blockpos1 = blockpos.add(random.zrange(20) - 10, random.zrange(6) - 3, random.zrange(20) - 10);
|
|
||||||
|
|
||||||
if (!this.theWorld.canSeeSky(blockpos1) && this.theCreature.getBlockPathWeight(blockpos1) < 0.0F)
|
|
||||||
{
|
|
||||||
return new Vec3((double)blockpos1.getX(), (double)blockpos1.getY(), (double)blockpos1.getZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package common.ai;
|
|
||||||
|
|
||||||
import common.entity.types.EntityLiving;
|
|
||||||
import common.pathfinding.PathNavigateGround;
|
|
||||||
import common.world.AWorldServer;
|
|
||||||
|
|
||||||
public class EntityAIRestrictSun extends EntityAIBase
|
|
||||||
{
|
|
||||||
private EntityLiving theEntity;
|
|
||||||
|
|
||||||
public EntityAIRestrictSun(EntityLiving creature)
|
|
||||||
{
|
|
||||||
this.theEntity = creature;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the EntityAIBase should begin execution.
|
|
||||||
*/
|
|
||||||
public boolean shouldExecute()
|
|
||||||
{
|
|
||||||
return ((AWorldServer)this.theEntity.worldObj).isDaytime();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute a one shot task or start executing a continuous task
|
|
||||||
*/
|
|
||||||
public void startExecuting()
|
|
||||||
{
|
|
||||||
((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the task
|
|
||||||
*/
|
|
||||||
public void resetTask()
|
|
||||||
{
|
|
||||||
((PathNavigateGround)this.theEntity.getNavigator()).setAvoidSun(false);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,12 +5,10 @@ import java.util.Map;
|
||||||
|
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
import common.color.Colorizer;
|
|
||||||
import common.log.Log;
|
import common.log.Log;
|
||||||
import common.rng.PerlinGen;
|
import common.rng.PerlinGen;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
|
||||||
|
|
||||||
public enum Biome {
|
public enum Biome {
|
||||||
NONE(0, "none", "<Keins>", 0x000000),
|
NONE(0, "none", "<Keins>", 0x000000),
|
||||||
|
@ -19,16 +17,16 @@ public enum Biome {
|
||||||
EXTREMEHILLS(3, "extremeHills", "Extremes Bergland", 0x606060, -12.0f, 30.0f),
|
EXTREMEHILLS(3, "extremeHills", "Extremes Bergland", 0x606060, -12.0f, 30.0f),
|
||||||
FOREST(4, "forest", "Wald", 0x056621, 8.0f, 80.0f),
|
FOREST(4, "forest", "Wald", 0x056621, 8.0f, 80.0f),
|
||||||
TAIGA(5, "taiga", "Taiga", 0x0b6659, -10.0f, 80.0f),
|
TAIGA(5, "taiga", "Taiga", 0x0b6659, -10.0f, 80.0f),
|
||||||
SWAMPLAND(6, "swampland", "Sumpf", 0x07f9b2, 12.0f, 90.0f, 0xe0ffae, 0xffffffff, 6975545),
|
SWAMPLAND(6, "swampland", "Sumpf", 0x07f9b2, 12.0f, 90.0f),
|
||||||
RIVER(7, "river", "Fluss", 0x0000ff),
|
RIVER(7, "river", "Fluss", 0x0000ff),
|
||||||
EXTERMINATED(8, "exterminated", "Ausgelöscht", 0x000000, 150.0f, 0.0f, 0x202020, 0x303030, 0x303030, 0x101010, 0x303030, 0x000000),
|
EXTERMINATED(8, "exterminated", "Ausgelöscht", 0x000000, 150.0f, 0.0f),
|
||||||
SPACE(9, "space", "Leere des Weltraums", 0x000000, 0.0f, 0.0f),
|
SPACE(9, "space", "Leere des Weltraums", 0x000000, 0.0f, 0.0f),
|
||||||
FROZENSEA(10, "frozenSea", "Vereister See", 0x9090a0, -20.0f),
|
FROZENSEA(10, "frozenSea", "Vereister See", 0x9090a0, -20.0f),
|
||||||
FROZENRIVER(11, "frozenRiver", "Vereister Fluss", 0xa0a0ff, -20.0f),
|
FROZENRIVER(11, "frozenRiver", "Vereister Fluss", 0xa0a0ff, -20.0f),
|
||||||
ICEPLAINS(12, "icePlains", "Eisebene", 0xffffff, -20.0f),
|
ICEPLAINS(12, "icePlains", "Eisebene", 0xffffff, -20.0f),
|
||||||
ICEMOUNTAINS(13, "iceMountains", "Vereistes Bergland", 0xa0a0a0, -20.0f),
|
ICEMOUNTAINS(13, "iceMountains", "Vereistes Bergland", 0xa0a0a0, -20.0f),
|
||||||
MUSHROOMPLAINS(14, "mushroomPlains", "Pilzland", 0xff00ff, 16.0f, 100.0f),
|
MUSHROOMPLAINS(14, "mushroomPlains", "Pilzland", 0xff00ff, 16.0f, 100.0f),
|
||||||
BLACKENED(15, "blackened", "Schwarz", 0x000000, 0.0f, 0.0f, 0x000000, 0x303030, 0x303030),
|
BLACKENED(15, "blackened", "Schwarz", 0x000000, 0.0f, 0.0f),
|
||||||
BEACH(16, "beach", "Strand", 0xfade55, 12.0f, 40.0f),
|
BEACH(16, "beach", "Strand", 0xfade55, 12.0f, 40.0f),
|
||||||
DESERTHILLS(17, "desertHills", "Wüsten-Bergland", 0xd25f12, 60.0f, 0.0f),
|
DESERTHILLS(17, "desertHills", "Wüsten-Bergland", 0xd25f12, 60.0f, 0.0f),
|
||||||
FORESTHILLS(18, "forestHills", "Wald-Bergland", 0x22551c, 8.0f, 80.0f),
|
FORESTHILLS(18, "forestHills", "Wald-Bergland", 0x22551c, 8.0f, 80.0f),
|
||||||
|
@ -50,17 +48,17 @@ public enum Biome {
|
||||||
EXTREMEHILLSPLUS(34, "extremeHillsPlus", "Extremes Bergland +", 0x507050, -12.0f, 30.0f),
|
EXTREMEHILLSPLUS(34, "extremeHillsPlus", "Extremes Bergland +", 0x507050, -12.0f, 30.0f),
|
||||||
SAVANNA(35, "savanna", "Savanne", 0xbdb25f, 28.0f, 0.0f),
|
SAVANNA(35, "savanna", "Savanne", 0xbdb25f, 28.0f, 0.0f),
|
||||||
SAVANNAPLATEAU(36, "savannaPlateau", "Savannen-Plateau", 0xa79d64, 20.0f, 0.0f),
|
SAVANNAPLATEAU(36, "savannaPlateau", "Savannen-Plateau", 0xa79d64, 20.0f, 0.0f),
|
||||||
MESA(37, "mesa", "Mesa", 0xd94515, 0.0f, 0.0f, 0xffffff, 9470285, 10387789),
|
MESA(37, "mesa", "Mesa", 0xd94515, 0.0f, 0.0f),
|
||||||
MESAPLATEAUF(38, "mesaPlateauF", "Mesa-Waldplateau", 0xb09765, 0.0f, 0.0f, 0xffffff, 9470285, 10387789),
|
MESAPLATEAUF(38, "mesaPlateauF", "Mesa-Waldplateau", 0xb09765, 0.0f, 0.0f),
|
||||||
MESAPLATEAU(39, "mesaPlateau", "Mesa-Plateau", 0xca8c65, 0.0f, 0.0f, 0xffffff, 9470285, 10387789),
|
MESAPLATEAU(39, "mesaPlateau", "Mesa-Plateau", 0xca8c65, 0.0f, 0.0f),
|
||||||
SNOWLAND(40, "snowLand", "Eisland", 0xffffff, 0.0f, 100.0f),
|
SNOWLAND(40, "snowLand", "Eisland", 0xffffff, 0.0f, 100.0f),
|
||||||
TIAN(41, "tian", "Tian", 0x808080, 0.0f, 80.0f),
|
TIAN(41, "tian", "Tian", 0x808080, 0.0f, 80.0f),
|
||||||
ELVENFOREST(42, "elvenForest", "Elbenwald", 0x059821, 8.0f, 90.0f),
|
ELVENFOREST(42, "elvenForest", "Elbenwald", 0x059821, 8.0f, 90.0f),
|
||||||
UPPERHELL(43, "upperHell", "Übergang in die Hölle", 0xff0000, 0.0f, 0.0f, 0x000000, 0x000000, 0x000000),
|
UPPERHELL(43, "upperHell", "Übergang in die Hölle", 0xff0000, 0.0f, 0.0f),
|
||||||
LOWERHELL(44, "lowerHell", "Abgrund der Hölle", 0xff0000, 0.0f, 0.0f, 0x000000, 0x000000, 0x000000),
|
LOWERHELL(44, "lowerHell", "Abgrund der Hölle", 0xff0000, 0.0f, 0.0f),
|
||||||
HELLHILLS(45, "hellHills", "Bergland der Hölle", 0xff0000, 0.0f, 0.0f, 0x000000, 0x000000, 0x000000),
|
HELLHILLS(45, "hellHills", "Bergland der Hölle", 0xff0000, 0.0f, 0.0f),
|
||||||
SOULPLAINS(46, "soulPlains", "Seelenland", 0xff0000, 0.0f, 0.0f, 0x000000, 0x000000, 0x000000),
|
SOULPLAINS(46, "soulPlains", "Seelenland", 0xff0000, 0.0f, 0.0f),
|
||||||
ASHLAND(47, "ashLand", "Verbrannt", 0xff0000, 0.0f, 0.0f, 0x000000, 0x000000, 0x000000),
|
ASHLAND(47, "ashLand", "Verbrannt", 0xff0000, 0.0f, 0.0f),
|
||||||
MOON(48, "moon", "Mondoberfläche", 0xa0a0a0, 0.0f, 0.0f),
|
MOON(48, "moon", "Mondoberfläche", 0xa0a0a0, 0.0f, 0.0f),
|
||||||
CHAOS(49, "chaos", "Chaos", 0xff00ff),
|
CHAOS(49, "chaos", "Chaos", 0xff00ff),
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ public enum Biome {
|
||||||
EXTREMEHILLSM(131, "extremeHillsM", "Extremes Bergland M", 0x606060, -12.0f, 30.0f),
|
EXTREMEHILLSM(131, "extremeHillsM", "Extremes Bergland M", 0x606060, -12.0f, 30.0f),
|
||||||
FLOWERFOREST(132, "flowerForest", "Blumenwald", 0x6a7425, 8.0f, 80.0f),
|
FLOWERFOREST(132, "flowerForest", "Blumenwald", 0x6a7425, 8.0f, 80.0f),
|
||||||
TAIGAM(133, "taigaM", "Taiga M", 0x0b6659, -10.0f, 80.0f),
|
TAIGAM(133, "taigaM", "Taiga M", 0x0b6659, -10.0f, 80.0f),
|
||||||
SWAMPLANDM(134, "swamplandM", "Sumpf M", 0x07f9b2, 12.0f, 90.0f, 0xe0ffae, 0xffffffff, 6975545),
|
SWAMPLANDM(134, "swamplandM", "Sumpf M", 0x07f9b2, 12.0f, 90.0f),
|
||||||
ICEPLAINSSPIKES(140, "icePlainsSpikes", "Eisebene + Spitzen", 0xd2ffff, -20.0f),
|
ICEPLAINSSPIKES(140, "icePlainsSpikes", "Eisebene + Spitzen", 0xd2ffff, -20.0f),
|
||||||
JUNGLEM(149, "jungleM", "Urwald M", 0x537b09, 18.0f, 90.0f),
|
JUNGLEM(149, "jungleM", "Urwald M", 0x537b09, 18.0f, 90.0f),
|
||||||
JUNGLEEDGEM(151, "jungleEdgeM", "Urwald Gr. M", 0x628b17, 18.0f, 80.0f),
|
JUNGLEEDGEM(151, "jungleEdgeM", "Urwald Gr. M", 0x628b17, 18.0f, 80.0f),
|
||||||
|
@ -81,28 +79,20 @@ public enum Biome {
|
||||||
EXTREMEHILLSPLUSM(162, "extremeHillsPlusM", "Extremes Bergland + M", 0x507050, -12.0f, 30.0f),
|
EXTREMEHILLSPLUSM(162, "extremeHillsPlusM", "Extremes Bergland + M", 0x507050, -12.0f, 30.0f),
|
||||||
SAVANNAM(163, "savannaM", "Savanne M", 0xbdb25f, 24.0f, 0.0f),
|
SAVANNAM(163, "savannaM", "Savanne M", 0xbdb25f, 24.0f, 0.0f),
|
||||||
SAVANNAPLATEAUM(164, "savannaPlateauM", "Savannen-Plateau M", 0xa79d64, 20.0f, 0.0f),
|
SAVANNAPLATEAUM(164, "savannaPlateauM", "Savannen-Plateau M", 0xa79d64, 20.0f, 0.0f),
|
||||||
MESABRYCE(165, "mesaBryce", "Mesa (Bryce)", 0xd94515, 0.0f, 0.0f, 0xffffff, 9470285, 10387789),
|
MESABRYCE(165, "mesaBryce", "Mesa (Bryce)", 0xd94515, 0.0f, 0.0f),
|
||||||
MESAPLATEAUFM(166, "mesaPlateauFM", "Mesa-Waldplateau M", 0xb09765, 0.0f, 0.0f, 0xffffff, 9470285, 10387789),
|
MESAPLATEAUFM(166, "mesaPlateauFM", "Mesa-Waldplateau M", 0xb09765, 0.0f, 0.0f),
|
||||||
MESAPLATEAUM(167, "mesaPlateauM", "Mesa-Plateau M", 0xca8c65, 0.0f, 0.0f, 0xffffff, 9470285, 10387789);
|
MESAPLATEAUM(167, "mesaPlateauM", "Mesa-Plateau M", 0xca8c65, 0.0f, 0.0f);
|
||||||
|
|
||||||
public static final Biome DEF_BIOME = FOREST;
|
public static final Biome DEF_BIOME = FOREST;
|
||||||
private static final PerlinGen TEMP_NOISE = new PerlinGen(new Random(836430928262265276L), 1);
|
private static final PerlinGen TEMP_NOISE = new PerlinGen(new Random(836430928262265276L), 1);
|
||||||
private static final PerlinGen COLOR_NOISE = new PerlinGen(new Random(6549321755809421L), 1);
|
|
||||||
private static final Biome[] BIOMES = new Biome[256];
|
private static final Biome[] BIOMES = new Biome[256];
|
||||||
private static final Map<String, Biome> LOOKUP = Maps.newTreeMap();
|
private static final Map<String, Biome> LOOKUP = Maps.newTreeMap();
|
||||||
|
|
||||||
public final int id;
|
public final int id;
|
||||||
public final String name;
|
public final String name;
|
||||||
public final String display;
|
public final String display;
|
||||||
public final int color;
|
|
||||||
public final float temperature;
|
public final float temperature;
|
||||||
public final float humidity;
|
public final float humidity;
|
||||||
public final int waterColor;
|
|
||||||
public final int grassColor;
|
|
||||||
public final int foliageColor;
|
|
||||||
public final int skyColor;
|
|
||||||
public final int fogColor;
|
|
||||||
public final int cloudColor;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for(Biome biome : values()) {
|
for(Biome biome : values()) {
|
||||||
|
@ -159,35 +149,20 @@ public enum Biome {
|
||||||
return biome;
|
return biome;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Biome(int id, String name, String display, int color, float temperature, float humidity, int waterColor, int grassColor, int foliageColor, int skyColor, int fogColor, int cloudColor) {
|
private Biome(int id, String name, String display, int color, float temperature, float humidity) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.display = display;
|
this.display = display;
|
||||||
this.temperature = temperature;
|
this.temperature = temperature;
|
||||||
this.humidity = humidity;
|
this.humidity = humidity;
|
||||||
this.color = color;
|
|
||||||
this.waterColor = waterColor;
|
|
||||||
this.grassColor = grassColor;
|
|
||||||
this.foliageColor = foliageColor;
|
|
||||||
this.skyColor = skyColor;
|
|
||||||
this.fogColor = fogColor;
|
|
||||||
this.cloudColor = cloudColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Biome(int id, String name, String display, int color, float temperature, float humidity, int waterColor, int grassColor, int foliageColor) {
|
|
||||||
this(id, name, display, color, temperature, humidity, waterColor, grassColor, foliageColor, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Biome(int id, String name, String display, int color, float temperature, float humidity) {
|
|
||||||
this(id, name, display, color, temperature, humidity, 0xffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Biome(int id, String name, String display, int color, float temperature) {
|
private Biome(int id, String name, String display, int color, float temperature) {
|
||||||
this(id, name, display, color, temperature, 50.0f, 0xffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
|
this(id, name, display, color, temperature, 50.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Biome(int id, String name, String display, int color) {
|
private Biome(int id, String name, String display, int color) {
|
||||||
this(id, name, display, color, 0.0f, 50.0f, 0xffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff);
|
this(id, name, display, color, 0.0f, 50.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final float getTemperature(BlockPos pos) {
|
public final float getTemperature(BlockPos pos) {
|
||||||
|
@ -206,30 +181,4 @@ public enum Biome {
|
||||||
public boolean isHighHumidity() {
|
public boolean isHighHumidity() {
|
||||||
return this.humidity > 85.0f;
|
return this.humidity > 85.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skycolor = ((temp + 14) / 40 + 0.15) / 3
|
|
||||||
|
|
||||||
public int getGrassColorAtPos(BlockPos pos) {
|
|
||||||
if(this.grassColor != 0xffffffff)
|
|
||||||
return this.grassColor;
|
|
||||||
if(this == SWAMPLAND || this == SWAMPLANDM) {
|
|
||||||
double d0 = COLOR_NOISE.generate((double)pos.getX() * 0.0225D, (double)pos.getZ() * 0.0225D);
|
|
||||||
return d0 < -0.1D ? 5011004 : 6975545;
|
|
||||||
}
|
|
||||||
if(this == ELVENFOREST)
|
|
||||||
return Colorizer.getGrassColor(1.0f, this.humidity * 0.01f);
|
|
||||||
double d0 = (double)ExtMath.clampf((this.getTemperature(pos) + 14.0f) / 40.0f + 0.15f, 0.0F, 1.0F);
|
|
||||||
double d1 = (double)ExtMath.clampf(this.humidity * 0.01f, 0.0F, 1.0F);
|
|
||||||
return this == ROOFEDFOREST || this == ROOFEDFORESTM ? (Colorizer.getGrassColor(d0, d1) & 16711422) + 2634762 >> 1 : Colorizer.getGrassColor(d0, d1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFoliageColorAtPos(BlockPos pos) {
|
|
||||||
if(this.foliageColor != 0xffffffff)
|
|
||||||
return this.foliageColor;
|
|
||||||
if(this == ELVENFOREST)
|
|
||||||
return Colorizer.getFoliageColor(1.0f, this.humidity * 0.01f);
|
|
||||||
double d0 = (double)ExtMath.clampf((this.getTemperature(pos) + 14.0f) / 40.0f + 0.15f, 0.0F, 1.0F);
|
|
||||||
double d1 = (double)ExtMath.clampf(this.humidity * 0.01f, 0.0F, 1.0F);
|
|
||||||
return Colorizer.getFoliageColor(d0, d1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class BlockCrops extends BlockBush implements IGrowable
|
||||||
|
|
||||||
public boolean canBlockStay(World worldIn, BlockPos pos, State state)
|
public boolean canBlockStay(World worldIn, BlockPos pos, State state)
|
||||||
{
|
{
|
||||||
return (worldIn.getLight(pos) >= 8 || worldIn.canSeeSky(pos)) && this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
|
return this.canPlaceBlockOn(worldIn.getState(pos.down()).getBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Item getSeed()
|
protected Item getSeed()
|
||||||
|
|
|
@ -21,7 +21,6 @@ import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -58,7 +57,7 @@ public class BlockDaylightDetector extends BlockContainer
|
||||||
if (!worldIn.dimension.hasNoLight())
|
if (!worldIn.dimension.hasNoLight())
|
||||||
{
|
{
|
||||||
State iblockstate = worldIn.getState(pos);
|
State iblockstate = worldIn.getState(pos);
|
||||||
int i = worldIn.getLightFor(LightType.SKY, pos) - worldIn.getSkylightSubtracted();
|
int i = 15 - worldIn.getSkylightSubtracted();
|
||||||
float f = worldIn.getCelestialAngleRadians(1.0F);
|
float f = worldIn.getCelestialAngleRadians(1.0F);
|
||||||
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
|
float f1 = f < (float)Math.PI ? 0.0F : ((float)Math.PI * 2F);
|
||||||
f = f + (f1 - f) * 0.2F;
|
f = f + (f1 - f) * 0.2F;
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class BlockFire extends Block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean canDie(World worldIn, BlockPos pos)
|
protected boolean canDie(AWorldServer worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
return worldIn.isRainingAt(pos, true) || worldIn.isRainingAt(pos.west(), true) || worldIn.isRainingAt(pos.east(), true) || worldIn.isRainingAt(pos.north(), true) || worldIn.isRainingAt(pos.south(), true);
|
return worldIn.isRainingAt(pos, true) || worldIn.isRainingAt(pos.west(), true) || worldIn.isRainingAt(pos.east(), true) || worldIn.isRainingAt(pos.north(), true) || worldIn.isRainingAt(pos.south(), true);
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ public class BlockFire extends Block
|
||||||
return integer == null ? 0 : integer.intValue();
|
return integer == null ? 0 : integer.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void catchOnFire(World worldIn, BlockPos pos, int chance, Random random, int age)
|
private void catchOnFire(AWorldServer worldIn, BlockPos pos, int chance, Random random, int age)
|
||||||
{
|
{
|
||||||
int i = this.getFlammability(worldIn.getState(pos).getBlock());
|
int i = this.getFlammability(worldIn.getState(pos).getBlock());
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import common.model.BlockLayer;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -46,7 +45,7 @@ public class BlockIce extends BlockBreakable
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (worldIn.doesWaterVaporize(pos))
|
if (((AWorldServer)worldIn).doesWaterVaporize(pos))
|
||||||
{
|
{
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
return;
|
return;
|
||||||
|
@ -73,7 +72,7 @@ public class BlockIce extends BlockBreakable
|
||||||
|
|
||||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (Config.iceMelt && ((worldIn.getLightFor(LightType.BLOCK, pos) > 11 - this.getLightOpacity()) || !worldIn.canFreezeAt(pos)))
|
if (Config.iceMelt && ((worldIn.getLightFor(pos) > 11 - this.getLightOpacity()) || !worldIn.canFreezeAt(pos)))
|
||||||
{
|
{
|
||||||
if (worldIn.doesWaterVaporize(pos))
|
if (worldIn.doesWaterVaporize(pos))
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,6 @@ import common.item.ItemStack;
|
||||||
import common.material.Material;
|
import common.material.Material;
|
||||||
import common.model.Model;
|
import common.model.Model;
|
||||||
import common.model.ModelProvider;
|
import common.model.ModelProvider;
|
||||||
import common.model.ParticleType;
|
|
||||||
import common.properties.IProperty;
|
import common.properties.IProperty;
|
||||||
import common.properties.PropertyBool;
|
import common.properties.PropertyBool;
|
||||||
import common.properties.PropertyEnum;
|
import common.properties.PropertyEnum;
|
||||||
|
@ -215,13 +214,13 @@ public class BlockLeaves extends BlockLeavesBase
|
||||||
|
|
||||||
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
public void randomDisplayTick(AWorldClient worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (worldIn.isRainingAt(pos.up(), true) && !worldIn.isBlockSolid(pos.down()) && rand.chance(15)) // == 1
|
// if (worldIn.isRainingAt(pos.up(), true) && !worldIn.isBlockSolid(pos.down()) && rand.chance(15)) // == 1 TODO: fix particles
|
||||||
{
|
// {
|
||||||
double d0 = (double)((float)pos.getX() + rand.floatv());
|
// double d0 = (double)((float)pos.getX() + rand.floatv());
|
||||||
double d1 = (double)pos.getY() - 0.05D;
|
// double d1 = (double)pos.getY() - 0.05D;
|
||||||
double d2 = (double)((float)pos.getZ() + rand.floatv());
|
// double d2 = (double)((float)pos.getZ() + rand.floatv());
|
||||||
worldIn.spawnParticle(ParticleType.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
// worldIn.spawnParticle(ParticleType.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void destroy(World worldIn, BlockPos pos)
|
private void destroy(World worldIn, BlockPos pos)
|
||||||
|
|
|
@ -215,7 +215,7 @@ public abstract class BlockLiquid extends Block
|
||||||
*/
|
*/
|
||||||
public int tickRate(World worldIn, BlockPos pos)
|
public int tickRate(World worldIn, BlockPos pos)
|
||||||
{
|
{
|
||||||
return this.flowRate >= 0 ? this.flowRate : (worldIn.isLavaFaster(pos) ? (-this.flowRate / 3) : (-this.flowRate));
|
return this.flowRate >= 0 ? this.flowRate : (!worldIn.client && ((AWorldServer)worldIn).isLavaFaster(pos) ? (-this.flowRate / 3) : (-this.flowRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMixedBrightnessForBlock(IWorldAccess worldIn, BlockPos pos)
|
public int getMixedBrightnessForBlock(IWorldAccess worldIn, BlockPos pos)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package common.block;
|
package common.block;
|
||||||
|
|
||||||
|
import common.color.Colorizer;
|
||||||
import common.init.Blocks;
|
import common.init.Blocks;
|
||||||
import common.init.Config;
|
import common.init.Config;
|
||||||
import common.init.Items;
|
import common.init.Items;
|
||||||
|
@ -154,7 +155,7 @@ public class BlockReed extends Block
|
||||||
|
|
||||||
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||||
{
|
{
|
||||||
return worldIn.getBiomeGenForCoords(pos).getGrassColorAtPos(pos);
|
return Colorizer.getGrassColor(1.0f, 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockLayer getBlockLayer()
|
public BlockLayer getBlockLayer()
|
||||||
|
|
|
@ -20,7 +20,6 @@ import common.util.BoundingBox;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.world.IBlockAccess;
|
import common.world.IBlockAccess;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
@ -137,7 +136,7 @@ public class BlockSnow extends Block
|
||||||
|
|
||||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (Config.snowMelt && ((worldIn.getLightFor(LightType.BLOCK, pos) > 11) || !worldIn.canFreezeAt(pos)))
|
if (Config.snowMelt && ((worldIn.getLightFor(pos) > 11) || !worldIn.canFreezeAt(pos)))
|
||||||
{
|
{
|
||||||
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
|
|
|
@ -7,7 +7,6 @@ import common.item.Item;
|
||||||
import common.material.Material;
|
import common.material.Material;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ public class BlockSnowBlock extends Block
|
||||||
|
|
||||||
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
public void updateTick(AWorldServer worldIn, BlockPos pos, State state, Random rand)
|
||||||
{
|
{
|
||||||
if (Config.snowFullMelt && worldIn.getLightFor(LightType.BLOCK, pos) > 11)
|
if (Config.snowFullMelt && worldIn.getLightFor(pos) > 11)
|
||||||
{
|
{
|
||||||
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
this.dropBlockAsItem(worldIn, pos, worldIn.getState(pos), 0);
|
||||||
worldIn.setBlockToAir(pos);
|
worldIn.setBlockToAir(pos);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class BlockTallGrass extends BlockBush implements IGrowable
|
||||||
|
|
||||||
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||||
{
|
{
|
||||||
return worldIn.getBiomeGenForCoords(pos).getGrassColorAtPos(pos);
|
return Colorizer.getGrassColor(1.0f, 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -226,7 +226,7 @@ public class BlockVine extends Block
|
||||||
|
|
||||||
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
public int colorMultiplier(IWorldAccess worldIn, BlockPos pos, int renderPass)
|
||||||
{
|
{
|
||||||
return worldIn.getBiomeGenForCoords(pos).getFoliageColorAtPos(pos);
|
return Colorizer.getFoliageColor(1.0f, 0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package common.color;
|
package common.color;
|
||||||
|
|
||||||
import common.biome.Biome;
|
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.world.IWorldAccess;
|
import common.world.IWorldAccess;
|
||||||
|
|
||||||
|
@ -8,22 +7,22 @@ public enum Colorizer {
|
||||||
NONE(0xffffff), BASIC(0x37b500), PINE(0x3f993f), BIRCH(0x68a723);
|
NONE(0xffffff), BASIC(0x37b500), PINE(0x3f993f), BIRCH(0x68a723);
|
||||||
|
|
||||||
private interface ColorResolver {
|
private interface ColorResolver {
|
||||||
int getColorAtPos(Biome biome, BlockPos pos);
|
int getColorAtPos(BlockPos pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ColorResolver GRASS_COLOR = new ColorResolver() {
|
private static final ColorResolver GRASS_COLOR = new ColorResolver() {
|
||||||
public int getColorAtPos(Biome biome, BlockPos pos) {
|
public int getColorAtPos(BlockPos pos) {
|
||||||
return biome.getGrassColorAtPos(pos);
|
return Colorizer.getGrassColor(1.0f, 0.9f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ColorResolver FOLIAGE_COLOR = new ColorResolver() {
|
private static final ColorResolver FOLIAGE_COLOR = new ColorResolver() {
|
||||||
public int getColorAtPos(Biome biome, BlockPos pos) {
|
public int getColorAtPos(BlockPos pos) {
|
||||||
return biome.getFoliageColorAtPos(pos);
|
return Colorizer.getFoliageColor(1.0f, 0.9f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final ColorResolver WATER_COLOR_MULTIPLIER = new ColorResolver() {
|
private static final ColorResolver WATER_COLOR_MULTIPLIER = new ColorResolver() {
|
||||||
public int getColorAtPos(Biome biome, BlockPos pos) {
|
public int getColorAtPos(BlockPos pos) {
|
||||||
return biome.waterColor;
|
return 0xffffff;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static final int[] GRASS = new int[65536];
|
private static final int[] GRASS = new int[65536];
|
||||||
|
@ -60,7 +59,7 @@ public enum Colorizer {
|
||||||
int b = 0;
|
int b = 0;
|
||||||
|
|
||||||
for(BlockPos.MutableBlockPos loc : BlockPos.getAllInBoxMutable(pos.add(-1, 0, -1), pos.add(1, 0, 1))) {
|
for(BlockPos.MutableBlockPos loc : BlockPos.getAllInBoxMutable(pos.add(-1, 0, -1), pos.add(1, 0, 1))) {
|
||||||
int c = resolver.getColorAtPos(access.getBiomeGenForCoords(loc), loc);
|
int c = resolver.getColorAtPos(loc);
|
||||||
r += (c & 16711680) >> 16;
|
r += (c & 16711680) >> 16;
|
||||||
g += (c & 65280) >> 8;
|
g += (c & 65280) >> 8;
|
||||||
b += c & 255;
|
b += c & 255;
|
||||||
|
|
|
@ -342,7 +342,7 @@ public abstract class Entity
|
||||||
this.setOnFireFromLava();
|
this.setOnFireFromLava();
|
||||||
this.fallDistance *= 0.5F;
|
this.fallDistance *= 0.5F;
|
||||||
}
|
}
|
||||||
else if(this.worldObj.canBurnAt(this.getPosition()) && this.isInDownfall()) {
|
else if(!this.worldObj.client && ((AWorldServer)this.worldObj).canBurnAt(this.getPosition()) && this.isInDownfall()) {
|
||||||
this.setOnFireFromMolten();
|
this.setOnFireFromMolten();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,7 +773,7 @@ public abstract class Entity
|
||||||
|
|
||||||
this.doBlockCollisions();
|
this.doBlockCollisions();
|
||||||
|
|
||||||
boolean flag2 = this.isWet();
|
boolean flag2 = !this.worldObj.client && this.isWet();
|
||||||
|
|
||||||
if (this.worldObj.isFlammableWithin(this.getEntityBoundingBox().contract(0.001D, 0.001D, 0.001D)))
|
if (this.worldObj.isFlammableWithin(this.getEntityBoundingBox().contract(0.001D, 0.001D, 0.001D)))
|
||||||
{
|
{
|
||||||
|
@ -949,17 +949,14 @@ public abstract class Entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if this entity is either in water or on an open air block in rain (used in wolves).
|
|
||||||
*/
|
|
||||||
public boolean isWet()
|
public boolean isWet()
|
||||||
{
|
{
|
||||||
return this.inLiquid || this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY, this.posZ), true) || this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY + (double)this.height, this.posZ), true);
|
return this.inLiquid || ((AWorldServer)this.worldObj).isRainingAt(new BlockPos(this.posX, this.posY, this.posZ), true) || ((AWorldServer)this.worldObj).isRainingAt(new BlockPos(this.posX, this.posY + (double)this.height, this.posZ), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInDownfall()
|
public boolean isInDownfall()
|
||||||
{
|
{
|
||||||
return this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY, this.posZ), false) || this.worldObj.isRainingAt(new BlockPos(this.posX, this.posY + (double)this.height, this.posZ), false);
|
return ((AWorldServer)this.worldObj).isRainingAt(new BlockPos(this.posX, this.posY, this.posZ), false) || ((AWorldServer)this.worldObj).isRainingAt(new BlockPos(this.posX, this.posY + (double)this.height, this.posZ), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,6 +38,7 @@ import common.pathfinding.PathNavigateGround;
|
||||||
import common.potion.Potion;
|
import common.potion.Potion;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityHorse extends EntityAnimal implements IInvBasic
|
public class EntityHorse extends EntityAnimal implements IInvBasic
|
||||||
|
@ -390,7 +391,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
|
||||||
{
|
{
|
||||||
int i = ExtMath.floord(this.posX);
|
int i = ExtMath.floord(this.posX);
|
||||||
int j = ExtMath.floord(this.posZ);
|
int j = ExtMath.floord(this.posZ);
|
||||||
this.worldObj.getBiomeGenForCoords(new BlockPos(i, 0, j));
|
((AWorldServer)this.worldObj).getBiomeGenForCoords(new BlockPos(i, 0, j));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import common.nbt.NBTTagCompound;
|
||||||
import common.pathfinding.PathNavigateGround;
|
import common.pathfinding.PathNavigateGround;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
import common.world.AWorldServer;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntitySheep extends EntityAnimal
|
public class EntitySheep extends EntityAnimal
|
||||||
|
@ -347,7 +348,7 @@ public class EntitySheep extends EntityAnimal
|
||||||
public Object onInitialSpawn(Object livingdata)
|
public Object onInitialSpawn(Object livingdata)
|
||||||
{
|
{
|
||||||
livingdata = super.onInitialSpawn(livingdata);
|
livingdata = super.onInitialSpawn(livingdata);
|
||||||
this.setFleeceColor(getRandomSheepColor(this.worldObj.rand, this.worldObj.getBiomeGenForCoords(this.getPosition())));
|
this.setFleeceColor(getRandomSheepColor(this.worldObj.rand, ((AWorldServer)this.worldObj).getBiomeGenForCoords(this.getPosition())));
|
||||||
return livingdata;
|
return livingdata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,30 +30,15 @@ import common.init.SoundEvent;
|
||||||
import common.item.Item;
|
import common.item.Item;
|
||||||
import common.item.ItemFood;
|
import common.item.ItemFood;
|
||||||
import common.item.ItemStack;
|
import common.item.ItemStack;
|
||||||
import common.model.ParticleType;
|
|
||||||
import common.nbt.NBTTagCompound;
|
import common.nbt.NBTTagCompound;
|
||||||
import common.pathfinding.PathNavigateGround;
|
import common.pathfinding.PathNavigateGround;
|
||||||
import common.util.ExtMath;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
|
|
||||||
public class EntityWolf extends EntityTameable
|
public class EntityWolf extends EntityTameable
|
||||||
{
|
{
|
||||||
/** Float used to smooth the rotation of the wolf head */
|
|
||||||
private float headRotationCourse;
|
private float headRotationCourse;
|
||||||
private float headRotationCourseOld;
|
private float headRotationCourseOld;
|
||||||
|
|
||||||
/** true is the wolf is wet else false */
|
|
||||||
private boolean isWet;
|
|
||||||
|
|
||||||
/** True if the wolf is shaking else False */
|
|
||||||
private boolean isShaking;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This time increases while wolf is shaking and emitting water particles.
|
|
||||||
*/
|
|
||||||
private float timeWolfIsShaking;
|
|
||||||
private float prevTimeWolfIsShaking;
|
|
||||||
|
|
||||||
public EntityWolf(World worldIn)
|
public EntityWolf(World worldIn)
|
||||||
{
|
{
|
||||||
super(worldIn);
|
super(worldIn);
|
||||||
|
@ -204,15 +189,7 @@ public class EntityWolf extends EntityTameable
|
||||||
public void onLivingUpdate()
|
public void onLivingUpdate()
|
||||||
{
|
{
|
||||||
super.onLivingUpdate();
|
super.onLivingUpdate();
|
||||||
|
|
||||||
if (!this.worldObj.client && this.isWet && !this.isShaking && !this.hasPath() && this.onGround)
|
|
||||||
{
|
|
||||||
this.isShaking = true;
|
|
||||||
this.timeWolfIsShaking = 0.0F;
|
|
||||||
this.prevTimeWolfIsShaking = 0.0F;
|
|
||||||
this.worldObj.setEntityState(this, (byte)8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.worldObj.client && this.getAttackTarget() == null && this.isAngry())
|
if (!this.worldObj.client && this.getAttackTarget() == null && this.isAngry())
|
||||||
{
|
{
|
||||||
this.setAngry(false);
|
this.setAngry(false);
|
||||||
|
@ -235,79 +212,8 @@ public class EntityWolf extends EntityTameable
|
||||||
{
|
{
|
||||||
this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F;
|
this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isWet())
|
|
||||||
{
|
|
||||||
this.isWet = true;
|
|
||||||
this.isShaking = false;
|
|
||||||
this.timeWolfIsShaking = 0.0F;
|
|
||||||
this.prevTimeWolfIsShaking = 0.0F;
|
|
||||||
}
|
|
||||||
else if ((this.isWet || this.isShaking) && this.isShaking)
|
|
||||||
{
|
|
||||||
if (this.timeWolfIsShaking == 0.0F)
|
|
||||||
{
|
|
||||||
this.playSound(SoundEvent.WOLF_SHAKE, this.getSoundVolume());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.prevTimeWolfIsShaking = this.timeWolfIsShaking;
|
|
||||||
this.timeWolfIsShaking += 0.05F;
|
|
||||||
|
|
||||||
if (this.prevTimeWolfIsShaking >= 2.0F)
|
|
||||||
{
|
|
||||||
this.isWet = false;
|
|
||||||
this.isShaking = false;
|
|
||||||
this.prevTimeWolfIsShaking = 0.0F;
|
|
||||||
this.timeWolfIsShaking = 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.timeWolfIsShaking > 0.4F)
|
|
||||||
{
|
|
||||||
float f = (float)this.getEntityBoundingBox().minY;
|
|
||||||
int i = (int)(ExtMath.sin((this.timeWolfIsShaking - 0.4F) * (float)Math.PI) * 7.0F);
|
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j)
|
|
||||||
{
|
|
||||||
float f1 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
|
||||||
float f2 = (this.rand.floatv() * 2.0F - 1.0F) * this.width * 0.5F;
|
|
||||||
this.worldObj.spawnParticle(ParticleType.WATER_SPLASH, this.posX + (double)f1, (double)(f + 0.8F), this.posZ + (double)f2, this.motionX, this.motionY, this.motionZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* True if the wolf is wet
|
|
||||||
*/
|
|
||||||
public boolean isWolfWet()
|
|
||||||
{
|
|
||||||
return this.isWet;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used when calculating the amount of shading to apply while the wolf is wet.
|
|
||||||
*/
|
|
||||||
public float getShadingWhileWet(float p_70915_1_)
|
|
||||||
{
|
|
||||||
return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getShakeAngle(float p_70923_1_, float p_70923_2_)
|
|
||||||
{
|
|
||||||
float f = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F;
|
|
||||||
|
|
||||||
if (f < 0.0F)
|
|
||||||
{
|
|
||||||
f = 0.0F;
|
|
||||||
}
|
|
||||||
else if (f > 1.0F)
|
|
||||||
{
|
|
||||||
f = 1.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ExtMath.sin(f * (float)Math.PI) * ExtMath.sin(f * (float)Math.PI * 11.0F) * 0.15F * (float)Math.PI;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getInterestedAngle(float p_70917_1_)
|
public float getInterestedAngle(float p_70917_1_)
|
||||||
{
|
{
|
||||||
return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float)Math.PI;
|
return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float)Math.PI;
|
||||||
|
@ -475,21 +381,7 @@ public class EntityWolf extends EntityTameable
|
||||||
|
|
||||||
return super.interact(player);
|
return super.interact(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleStatusUpdate(byte id)
|
|
||||||
{
|
|
||||||
if (id == 8)
|
|
||||||
{
|
|
||||||
this.isShaking = true;
|
|
||||||
this.timeWolfIsShaking = 0.0F;
|
|
||||||
this.prevTimeWolfIsShaking = 0.0F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
super.handleStatusUpdate(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTailRotation()
|
public float getTailRotation()
|
||||||
{
|
{
|
||||||
return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - (float)this.dataWatcher.getWatchableObjectInt(18)) * 0.02F) * (float)Math.PI : ((float)Math.PI / 5F));
|
return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - (float)this.dataWatcher.getWatchableObjectInt(18)) * 0.02F) * (float)Math.PI : ((float)Math.PI / 5F));
|
||||||
|
|
|
@ -396,7 +396,7 @@ public class EntitySlime extends EntityNPC
|
||||||
// {
|
// {
|
||||||
// if (this.worldObj.getDifficulty() != Difficulty.PEACEFUL)
|
// if (this.worldObj.getDifficulty() != Difficulty.PEACEFUL)
|
||||||
// {
|
// {
|
||||||
Biome biomegenbase = this.worldObj.getBiomeGenForCoords(blockpos);
|
Biome biomegenbase = ((AWorldServer)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.getCurrentMoonPhaseFactor() && this.worldObj.getLightFromNeighbors(new BlockPos(this)) <= this.rand.zrange(8))
|
||||||
{
|
{
|
||||||
|
|
|
@ -454,7 +454,7 @@ public class EntityArrow extends Entity implements IProjectile, IObjectData
|
||||||
f4 = 0.6F;
|
f4 = 0.6F;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isWet())
|
if (!this.worldObj.client && this.isWet())
|
||||||
{
|
{
|
||||||
this.extinguish();
|
this.extinguish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,16 +388,11 @@ public class EntityHook extends Entity implements IObjectData
|
||||||
int l = 1;
|
int l = 1;
|
||||||
BlockPos blockpos = (new BlockPos(this)).up();
|
BlockPos blockpos = (new BlockPos(this)).up();
|
||||||
|
|
||||||
if (this.rand.floatv() < 0.25F && this.worldObj.isRainingAt(blockpos, true))
|
if (this.rand.floatv() < 0.25F && worldserver.isRainingAt(blockpos, true))
|
||||||
{
|
{
|
||||||
l = 2;
|
l = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.rand.floatv() < 0.5F && !this.worldObj.canSeeSky(blockpos))
|
|
||||||
{
|
|
||||||
--l;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.ticksCatchable > 0)
|
if (this.ticksCatchable > 0)
|
||||||
{
|
{
|
||||||
--this.ticksCatchable;
|
--this.ticksCatchable;
|
||||||
|
|
|
@ -314,7 +314,7 @@ public abstract class EntityLiving extends Entity
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (this.isEntityAlive() && this.isWet())
|
if (!this.worldObj.client && this.isEntityAlive() && this.isWet())
|
||||||
{
|
{
|
||||||
this.extinguish();
|
this.extinguish();
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,38 +249,32 @@ public class ItemBucket extends Item
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else if(!worldIn.client)
|
||||||
{
|
{
|
||||||
if (worldIn.doesWaterVaporize(pos) && this.liquid.getMaterial() == Material.water)
|
if (((AWorldServer)worldIn).doesWaterVaporize(pos) && this.liquid.getMaterial() == Material.water)
|
||||||
{
|
{
|
||||||
int i = pos.getX();
|
int i = pos.getX();
|
||||||
int j = pos.getY();
|
int j = pos.getY();
|
||||||
int k = pos.getZ();
|
int k = pos.getZ();
|
||||||
worldIn.playSound(SoundEvent.FIZZ, (double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), 0.5F);
|
worldIn.playSound(SoundEvent.FIZZ, (double)((float)i + 0.5F), (double)((float)j + 0.5F), (double)((float)k + 0.5F), 0.5F);
|
||||||
|
((AWorldServer)worldIn).spawnParticle(ParticleType.SMOKE_LARGE, (double)i, (double)j, (double)k, 8, 1.0D, 1.0D, 1.0D, 0.0f);
|
||||||
for (int l = 0; l < 8; ++l)
|
|
||||||
{
|
|
||||||
worldIn.spawnParticle(ParticleType.SMOKE_LARGE, (double)i + Math.random(), (double)j + Math.random(), (double)k + Math.random(), 0.0D, 0.0D, 0.0D);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!worldIn.client && flag && !material.isLiquid())
|
if (flag && !material.isLiquid())
|
||||||
{
|
{
|
||||||
worldIn.destroyBlock(pos, true);
|
worldIn.destroyBlock(pos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.recursive) {
|
if(this.recursive) {
|
||||||
if(!worldIn.client)
|
setRecursive((AWorldServer)worldIn, pos, 4, FluidRegistry.getStaticBlock(this.liquid));
|
||||||
setRecursive((AWorldServer)worldIn, pos, 4, FluidRegistry.getStaticBlock(this.liquid));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
worldIn.setState(pos, this.liquid.getState(), 3);
|
worldIn.setState(pos, this.liquid.getState(), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ import common.packet.S39PacketPlayerAbilities;
|
||||||
import common.packet.S3APacketTabComplete;
|
import common.packet.S3APacketTabComplete;
|
||||||
import common.packet.S43PacketUpdateEntityNBT;
|
import common.packet.S43PacketUpdateEntityNBT;
|
||||||
import common.packet.SPacketAnimation;
|
import common.packet.SPacketAnimation;
|
||||||
import common.packet.SPacketBiomes;
|
|
||||||
import common.packet.SPacketBlockAction;
|
import common.packet.SPacketBlockAction;
|
||||||
import common.packet.SPacketBlockBreakAnim;
|
import common.packet.SPacketBlockBreakAnim;
|
||||||
import common.packet.SPacketBlockChange;
|
import common.packet.SPacketBlockChange;
|
||||||
|
@ -100,7 +99,6 @@ public interface IClientPlayer {
|
||||||
void handlePlayerPosLook(SPacketPlayerPosLook packetIn);
|
void handlePlayerPosLook(SPacketPlayerPosLook packetIn);
|
||||||
void handleMultiBlockChange(SPacketMultiBlockChange packetIn);
|
void handleMultiBlockChange(SPacketMultiBlockChange packetIn);
|
||||||
void handleChunkData(SPacketChunkData packetIn);
|
void handleChunkData(SPacketChunkData packetIn);
|
||||||
void handleBiomes(SPacketBiomes packetIn);
|
|
||||||
void handleBlockChange(SPacketBlockChange packetIn);
|
void handleBlockChange(SPacketBlockChange packetIn);
|
||||||
void handleDisconnect(SPacketDisconnect packetIn);
|
void handleDisconnect(SPacketDisconnect packetIn);
|
||||||
void handleCollectItem(SPacketCollectItem packetIn);
|
void handleCollectItem(SPacketCollectItem packetIn);
|
||||||
|
|
|
@ -58,16 +58,14 @@ public class PacketBuffer
|
||||||
|
|
||||||
public BlockPos readBlockPos()
|
public BlockPos readBlockPos()
|
||||||
{
|
{
|
||||||
// return new BlockPos(this.readInt(), this.readInt(), this.readInt());
|
return new BlockPos(this.readInt(), this.readInt(), this.readInt());
|
||||||
return BlockPos.fromLong(this.readLong());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeBlockPos(BlockPos pos)
|
public void writeBlockPos(BlockPos pos)
|
||||||
{
|
{
|
||||||
this.writeLong(pos.toLong());
|
this.writeInt(pos.getX());
|
||||||
// this.writeInt(pos.getX());
|
this.writeInt(pos.getY());
|
||||||
// this.writeInt(pos.getY());
|
this.writeInt(pos.getZ());
|
||||||
// this.writeInt(pos.getZ());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public Text readChatComponent() throws IOException
|
// public Text readChatComponent() throws IOException
|
||||||
|
|
|
@ -56,7 +56,6 @@ import common.packet.S39PacketPlayerAbilities;
|
||||||
import common.packet.S3APacketTabComplete;
|
import common.packet.S3APacketTabComplete;
|
||||||
import common.packet.S43PacketUpdateEntityNBT;
|
import common.packet.S43PacketUpdateEntityNBT;
|
||||||
import common.packet.SPacketAnimation;
|
import common.packet.SPacketAnimation;
|
||||||
import common.packet.SPacketBiomes;
|
|
||||||
import common.packet.SPacketBlockAction;
|
import common.packet.SPacketBlockAction;
|
||||||
import common.packet.SPacketBlockBreakAnim;
|
import common.packet.SPacketBlockBreakAnim;
|
||||||
import common.packet.SPacketBlockChange;
|
import common.packet.SPacketBlockChange;
|
||||||
|
@ -177,7 +176,6 @@ public enum PacketRegistry
|
||||||
this.server(SPacketWorld.class);
|
this.server(SPacketWorld.class);
|
||||||
// this.server(SPacketCapes.class);
|
// this.server(SPacketCapes.class);
|
||||||
this.server(SPacketCamera.class);
|
this.server(SPacketCamera.class);
|
||||||
this.server(SPacketBiomes.class);
|
|
||||||
// this.server(S42PacketTitle.class);
|
// this.server(S42PacketTitle.class);
|
||||||
this.server(S43PacketUpdateEntityNBT.class);
|
this.server(S43PacketUpdateEntityNBT.class);
|
||||||
// this.server(SPacketBook.class);
|
// this.server(SPacketBook.class);
|
||||||
|
|
|
@ -65,6 +65,6 @@ public class S2BPacketChangeGameState implements Packet<IClientPlayer>
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Action {
|
public static enum Action {
|
||||||
SET_WEATHER, RAIN_STRENGTH, DARKNESS, FOG_STRENGTH, TEMPERATURE;
|
SET_WEATHER, RAIN_STRENGTH, DARKNESS, FOG_STRENGTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
package common.packet;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import common.network.IClientPlayer;
|
|
||||||
import common.network.Packet;
|
|
||||||
import common.network.PacketBuffer;
|
|
||||||
|
|
||||||
public class SPacketBiomes implements Packet<IClientPlayer> {
|
|
||||||
private int chunkX;
|
|
||||||
private int chunkZ;
|
|
||||||
private byte[] biomes;
|
|
||||||
|
|
||||||
public SPacketBiomes() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SPacketBiomes(int chunkX, int chunkZ, byte[] biomes) {
|
|
||||||
this.chunkX = chunkX;
|
|
||||||
this.chunkZ = chunkZ;
|
|
||||||
this.biomes = biomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
|
||||||
this.chunkX = buf.readInt();
|
|
||||||
this.chunkZ = buf.readInt();
|
|
||||||
buf.readBytes(this.biomes = new byte[256]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
|
||||||
buf.writeInt(this.chunkX);
|
|
||||||
buf.writeInt(this.chunkZ);
|
|
||||||
buf.writeBytes(this.biomes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processPacket(IClientPlayer handler) {
|
|
||||||
handler.handleBiomes(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChunkX() {
|
|
||||||
return this.chunkX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChunkZ() {
|
|
||||||
return this.chunkZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getBiomes() {
|
|
||||||
return this.biomes;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,18 +15,18 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
private int chunkX;
|
private int chunkX;
|
||||||
private int chunkZ;
|
private int chunkZ;
|
||||||
private SPacketChunkData.Extracted extractedData;
|
private SPacketChunkData.Extracted extractedData;
|
||||||
private boolean biomes;
|
private boolean resend;
|
||||||
|
|
||||||
public SPacketChunkData()
|
public SPacketChunkData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPacketChunkData(Chunk chunkIn, boolean biomes, int segUpdate)
|
public SPacketChunkData(Chunk chunkIn, boolean resend, int segUpdate)
|
||||||
{
|
{
|
||||||
this.chunkX = chunkIn.xPos;
|
this.chunkX = chunkIn.xPos;
|
||||||
this.chunkZ = chunkIn.zPos;
|
this.chunkZ = chunkIn.zPos;
|
||||||
this.biomes = biomes;
|
this.resend = resend;
|
||||||
this.extractedData = getExtractedData(chunkIn, biomes, !chunkIn.getWorld().dimension.hasNoLight(), segUpdate);
|
this.extractedData = getExtractedData(chunkIn, resend, segUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +36,7 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
{
|
{
|
||||||
this.chunkX = buf.readInt();
|
this.chunkX = buf.readInt();
|
||||||
this.chunkZ = buf.readInt();
|
this.chunkZ = buf.readInt();
|
||||||
this.biomes = buf.readBoolean();
|
this.resend = buf.readBoolean();
|
||||||
this.extractedData = new SPacketChunkData.Extracted();
|
this.extractedData = new SPacketChunkData.Extracted();
|
||||||
this.extractedData.dataSize = buf.readInt();
|
this.extractedData.dataSize = buf.readInt();
|
||||||
this.extractedData.data = buf.readByteArray();
|
this.extractedData.data = buf.readByteArray();
|
||||||
|
@ -49,7 +49,7 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
{
|
{
|
||||||
buf.writeInt(this.chunkX);
|
buf.writeInt(this.chunkX);
|
||||||
buf.writeInt(this.chunkZ);
|
buf.writeInt(this.chunkZ);
|
||||||
buf.writeBoolean(this.biomes);
|
buf.writeBoolean(this.resend);
|
||||||
buf.writeInt(this.extractedData.dataSize);
|
buf.writeInt(this.extractedData.dataSize);
|
||||||
buf.writeByteArray(this.extractedData.data);
|
buf.writeByteArray(this.extractedData.data);
|
||||||
}
|
}
|
||||||
|
@ -67,16 +67,14 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
return this.extractedData.data;
|
return this.extractedData.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int getSize(int segments, boolean overworld, boolean biomes)
|
protected static int getSize(int segments)
|
||||||
{
|
{
|
||||||
int i = segments * 2 * 16 * 16 * 16;
|
int i = segments * 2 * 16 * 16 * 16;
|
||||||
int j = segments * 16 * 16 * 16 / 2;
|
int j = segments * 16 * 16 * 16 / 2;
|
||||||
int k = overworld ? segments * 16 * 16 * 16 / 2 : 0;
|
return i + j;
|
||||||
int l = biomes ? 256 : 0;
|
|
||||||
return i + j + k + l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SPacketChunkData.Extracted getExtractedData(Chunk chunk, boolean biomes, boolean overworld, int segUpdate)
|
public static SPacketChunkData.Extracted getExtractedData(Chunk chunk, boolean biomes, int segUpdate)
|
||||||
{
|
{
|
||||||
BlockArray[] aextendedblockstorage = chunk.getStorage();
|
BlockArray[] aextendedblockstorage = chunk.getStorage();
|
||||||
SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted();
|
SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted();
|
||||||
|
@ -93,7 +91,7 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s21packetchunkdata$extracted.data = new byte[getSize(Integer.bitCount(s21packetchunkdata$extracted.dataSize), overworld, biomes)];
|
s21packetchunkdata$extracted.data = new byte[getSize(Integer.bitCount(s21packetchunkdata$extracted.dataSize))];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
for (BlockArray extendedblockstorage1 : list)
|
for (BlockArray extendedblockstorage1 : list)
|
||||||
|
@ -112,19 +110,6 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
j = copyTo(extendedblockstorage2.getBlocklight().getData(), s21packetchunkdata$extracted.data, j);
|
j = copyTo(extendedblockstorage2.getBlocklight().getData(), s21packetchunkdata$extracted.data, j);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overworld)
|
|
||||||
{
|
|
||||||
for (BlockArray extendedblockstorage3 : list)
|
|
||||||
{
|
|
||||||
j = copyTo(extendedblockstorage3.getSkylight().getData(), s21packetchunkdata$extracted.data, j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (biomes)
|
|
||||||
{
|
|
||||||
copyTo(chunk.getBiomes(), s21packetchunkdata$extracted.data, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s21packetchunkdata$extracted;
|
return s21packetchunkdata$extracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,9 +134,9 @@ public class SPacketChunkData implements Packet<IClientPlayer>
|
||||||
return this.extractedData.dataSize;
|
return this.extractedData.dataSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBiomes()
|
public boolean isResend()
|
||||||
{
|
{
|
||||||
return this.biomes;
|
return this.resend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Extracted
|
public static class Extracted
|
||||||
|
|
|
@ -13,7 +13,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||||
private int[] xPositions;
|
private int[] xPositions;
|
||||||
private int[] zPositions;
|
private int[] zPositions;
|
||||||
private SPacketChunkData.Extracted[] chunksData;
|
private SPacketChunkData.Extracted[] chunksData;
|
||||||
private boolean isOverworld;
|
|
||||||
|
|
||||||
public SPacketMapChunkBulk()
|
public SPacketMapChunkBulk()
|
||||||
{
|
{
|
||||||
|
@ -25,12 +24,11 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||||
this.xPositions = new int[i];
|
this.xPositions = new int[i];
|
||||||
this.zPositions = new int[i];
|
this.zPositions = new int[i];
|
||||||
this.chunksData = new SPacketChunkData.Extracted[i];
|
this.chunksData = new SPacketChunkData.Extracted[i];
|
||||||
this.isOverworld = !((Chunk)chunks.get(0)).getWorld().dimension.hasNoLight();
|
|
||||||
|
|
||||||
for (int j = 0; j < i; ++j)
|
for (int j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
Chunk chunk = (Chunk)chunks.get(j);
|
Chunk chunk = (Chunk)chunks.get(j);
|
||||||
SPacketChunkData.Extracted s21packetchunkdata$extracted = SPacketChunkData.getExtractedData(chunk, true, this.isOverworld, 0xffffffff);
|
SPacketChunkData.Extracted s21packetchunkdata$extracted = SPacketChunkData.getExtractedData(chunk, true, 0xffffffff);
|
||||||
this.xPositions[j] = chunk.xPos;
|
this.xPositions[j] = chunk.xPos;
|
||||||
this.zPositions[j] = chunk.zPos;
|
this.zPositions[j] = chunk.zPos;
|
||||||
this.chunksData[j] = s21packetchunkdata$extracted;
|
this.chunksData[j] = s21packetchunkdata$extracted;
|
||||||
|
@ -42,7 +40,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||||
*/
|
*/
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException
|
public void readPacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
this.isOverworld = buf.readBoolean();
|
|
||||||
int i = buf.readVarIntFromBuffer();
|
int i = buf.readVarIntFromBuffer();
|
||||||
this.xPositions = new int[i];
|
this.xPositions = new int[i];
|
||||||
this.zPositions = new int[i];
|
this.zPositions = new int[i];
|
||||||
|
@ -54,7 +51,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||||
this.zPositions[j] = buf.readInt();
|
this.zPositions[j] = buf.readInt();
|
||||||
this.chunksData[j] = new SPacketChunkData.Extracted();
|
this.chunksData[j] = new SPacketChunkData.Extracted();
|
||||||
this.chunksData[j].dataSize = buf.readInt();
|
this.chunksData[j].dataSize = buf.readInt();
|
||||||
this.chunksData[j].data = new byte[SPacketChunkData.getSize(Integer.bitCount(this.chunksData[j].dataSize), this.isOverworld, true)];
|
this.chunksData[j].data = new byte[SPacketChunkData.getSize(Integer.bitCount(this.chunksData[j].dataSize))];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int k = 0; k < i; ++k)
|
for (int k = 0; k < i; ++k)
|
||||||
|
@ -68,7 +65,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
|
||||||
*/
|
*/
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException
|
public void writePacketData(PacketBuffer buf) throws IOException
|
||||||
{
|
{
|
||||||
buf.writeBoolean(this.isOverworld);
|
|
||||||
buf.writeVarIntToBuffer(this.chunksData.length);
|
buf.writeVarIntToBuffer(this.chunksData.length);
|
||||||
|
|
||||||
for (int i = 0; i < this.xPositions.length; ++i)
|
for (int i = 0; i < this.xPositions.length; ++i)
|
||||||
|
|
|
@ -8,20 +8,24 @@ import common.network.PacketBuffer;
|
||||||
|
|
||||||
public class SPacketServerTick implements Packet<IClientPlayer> {
|
public class SPacketServerTick implements Packet<IClientPlayer> {
|
||||||
private int time;
|
private int time;
|
||||||
|
private String serverInfo;
|
||||||
|
|
||||||
public SPacketServerTick() {
|
public SPacketServerTick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SPacketServerTick(int time) {
|
public SPacketServerTick(int time, String info) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
|
this.serverInfo = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void readPacketData(PacketBuffer buf) throws IOException {
|
public void readPacketData(PacketBuffer buf) throws IOException {
|
||||||
this.time = buf.readInt();
|
this.time = buf.readInt();
|
||||||
|
this.serverInfo = buf.readStringFromBuffer(64);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writePacketData(PacketBuffer buf) throws IOException {
|
public void writePacketData(PacketBuffer buf) throws IOException {
|
||||||
buf.writeInt(this.time);
|
buf.writeInt(this.time);
|
||||||
|
buf.writeString(this.serverInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processPacket(IClientPlayer handler) {
|
public void processPacket(IClientPlayer handler) {
|
||||||
|
@ -31,4 +35,8 @@ public class SPacketServerTick implements Packet<IClientPlayer> {
|
||||||
public int getTime() {
|
public int getTime() {
|
||||||
return this.time;
|
return this.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServerinfo() {
|
||||||
|
return this.serverInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,6 @@ public abstract class PathNavigate
|
||||||
this.currentPath = pathentityIn;
|
this.currentPath = pathentityIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeSunnyPath();
|
|
||||||
|
|
||||||
if (this.currentPath.getCurrentPathLength() == 0)
|
if (this.currentPath.getCurrentPathLength() == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -322,13 +320,6 @@ public abstract class PathNavigate
|
||||||
return this.theEntity.isInLiquid() || this.theEntity.isInMolten();
|
return this.theEntity.isInLiquid() || this.theEntity.isInMolten();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Trims path data from the end to the first sun covered block
|
|
||||||
*/
|
|
||||||
protected void removeSunnyPath()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||||
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||||
|
|
|
@ -13,7 +13,6 @@ import common.world.World;
|
||||||
public class PathNavigateGround extends PathNavigate
|
public class PathNavigateGround extends PathNavigate
|
||||||
{
|
{
|
||||||
protected WalkNodeProcessor nodeProcessor;
|
protected WalkNodeProcessor nodeProcessor;
|
||||||
private boolean shouldAvoidSun;
|
|
||||||
|
|
||||||
public PathNavigateGround(EntityLiving entitylivingIn, World worldIn)
|
public PathNavigateGround(EntityLiving entitylivingIn, World worldIn)
|
||||||
{
|
{
|
||||||
|
@ -71,33 +70,6 @@ public class PathNavigateGround extends PathNavigate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Trims path data from the end to the first sun covered block
|
|
||||||
*/
|
|
||||||
protected void removeSunnyPath()
|
|
||||||
{
|
|
||||||
super.removeSunnyPath();
|
|
||||||
|
|
||||||
if (this.shouldAvoidSun)
|
|
||||||
{
|
|
||||||
if (this.worldObj.canSeeSky(new BlockPos(ExtMath.floord(this.theEntity.posX), (int)(this.theEntity.getEntityBoundingBox().minY + 0.5D), ExtMath.floord(this.theEntity.posZ))))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
|
|
||||||
{
|
|
||||||
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
|
|
||||||
|
|
||||||
if (this.worldObj.canSeeSky(new BlockPos(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord)))
|
|
||||||
{
|
|
||||||
this.currentPath.setCurrentPathLength(i - 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
|
||||||
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
* pos1, pos2, entityXSize, entityYSize, entityZSize
|
||||||
|
@ -286,9 +258,4 @@ public class PathNavigateGround extends PathNavigate
|
||||||
{
|
{
|
||||||
return this.nodeProcessor.getCanSwim();
|
return this.nodeProcessor.getCanSwim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAvoidSun(boolean par1)
|
|
||||||
{
|
|
||||||
this.shouldAvoidSun = par1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import common.network.Packet;
|
||||||
import common.packet.S35PacketUpdateTileEntity;
|
import common.packet.S35PacketUpdateTileEntity;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
|
import common.world.AWorldServer;
|
||||||
|
|
||||||
public abstract class TileEntityMachine extends TileEntityLockable implements IHopper, ITickable {
|
public abstract class TileEntityMachine extends TileEntityLockable implements IHopper, ITickable {
|
||||||
public static enum Status {
|
public static enum Status {
|
||||||
|
@ -216,7 +217,7 @@ public abstract class TileEntityMachine extends TileEntityLockable implements IH
|
||||||
|
|
||||||
public void update() {
|
public void update() {
|
||||||
if(this.worldObj != null && !this.worldObj.client && this.status != Status.BROKEN) {
|
if(this.worldObj != null && !this.worldObj.client && this.status != Status.BROKEN) {
|
||||||
int envTemp = (int)this.worldObj.getTemperatureC(this.getPos());
|
int envTemp = (int)((AWorldServer)this.worldObj).getTemperatureC(this.getPos());
|
||||||
if(this.executeFunction()) {
|
if(this.executeFunction()) {
|
||||||
this.temperature += this.getTempIncrement();
|
this.temperature += this.getTempIncrement();
|
||||||
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING;
|
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING;
|
||||||
|
|
|
@ -8,14 +8,6 @@ import common.entity.Entity;
|
||||||
public class BlockPos extends Vec3i
|
public class BlockPos extends Vec3i
|
||||||
{
|
{
|
||||||
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
||||||
private static final int NUM_X_BITS = 1 + 26; // ExtMath.calculateLogBaseTwo(ExtMath.roundUpToPowerOfTwo(World.MAX_SIZE));
|
|
||||||
private static final int NUM_Z_BITS = NUM_X_BITS;
|
|
||||||
private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
|
|
||||||
private static final int Y_SHIFT = 0 + NUM_Z_BITS;
|
|
||||||
private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
|
|
||||||
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
|
|
||||||
private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
|
|
||||||
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
|
|
||||||
|
|
||||||
public BlockPos(int x, int y, int z)
|
public BlockPos(int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
@ -194,19 +186,6 @@ public class BlockPos extends Vec3i
|
||||||
return new BlockPos(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX());
|
return new BlockPos(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long toLong()
|
|
||||||
{
|
|
||||||
return ((long)this.getX() & X_MASK) << X_SHIFT | ((long)this.getY() & Y_MASK) << Y_SHIFT | ((long)this.getZ() & Z_MASK) << 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockPos fromLong(long serialized)
|
|
||||||
{
|
|
||||||
int i = (int)(serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
|
|
||||||
int j = (int)(serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
|
|
||||||
int k = (int)(serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
|
|
||||||
return new BlockPos(i, j, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Iterable<BlockPos> getAllInBox(BlockPos from, BlockPos to)
|
public static Iterable<BlockPos> getAllInBox(BlockPos from, BlockPos to)
|
||||||
{
|
{
|
||||||
final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
|
final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
|
||||||
|
|
|
@ -1,285 +0,0 @@
|
||||||
package common.util;
|
|
||||||
|
|
||||||
public class LongHashMap<V>
|
|
||||||
{
|
|
||||||
private transient LongHashMap.Entry<V>[] hashArray = new LongHashMap.Entry[4096];
|
|
||||||
private transient int numHashElements;
|
|
||||||
private int mask;
|
|
||||||
private int capacity = 3072;
|
|
||||||
private final float percentUseable = 0.75F;
|
|
||||||
private transient volatile int modCount;
|
|
||||||
|
|
||||||
public static long packInt(int x, int z) {
|
|
||||||
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LongHashMap()
|
|
||||||
{
|
|
||||||
this.mask = this.hashArray.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the hashed key given the original key
|
|
||||||
*/
|
|
||||||
private static int getHashedKey(long originalKey)
|
|
||||||
{
|
|
||||||
return hash((int)(originalKey ^ originalKey >>> 32));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the hash function
|
|
||||||
*/
|
|
||||||
private static int hash(int integer)
|
|
||||||
{
|
|
||||||
integer = integer ^ integer >>> 20 ^ integer >>> 12;
|
|
||||||
return integer ^ integer >>> 7 ^ integer >>> 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gets the index in the hash given the array length and the hashed key
|
|
||||||
*/
|
|
||||||
private static int getHashIndex(int p_76158_0_, int p_76158_1_)
|
|
||||||
{
|
|
||||||
return p_76158_0_ & p_76158_1_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumHashElements()
|
|
||||||
{
|
|
||||||
return this.numHashElements;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get the value from the map given the key
|
|
||||||
*/
|
|
||||||
public V getValueByKey(long p_76164_1_)
|
|
||||||
{
|
|
||||||
int i = getHashedKey(p_76164_1_);
|
|
||||||
|
|
||||||
for (LongHashMap.Entry<V> entry = this.hashArray[getHashIndex(i, this.mask)]; entry != null; entry = entry.nextEntry)
|
|
||||||
{
|
|
||||||
if (entry.key == p_76164_1_)
|
|
||||||
{
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (V)null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean containsItem(long p_76161_1_)
|
|
||||||
{
|
|
||||||
return this.getEntry(p_76161_1_) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final LongHashMap.Entry<V> getEntry(long p_76160_1_)
|
|
||||||
{
|
|
||||||
int i = getHashedKey(p_76160_1_);
|
|
||||||
|
|
||||||
for (LongHashMap.Entry<V> entry = this.hashArray[getHashIndex(i, this.mask)]; entry != null; entry = entry.nextEntry)
|
|
||||||
{
|
|
||||||
if (entry.key == p_76160_1_)
|
|
||||||
{
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a key-value pair.
|
|
||||||
*/
|
|
||||||
public void add(long p_76163_1_, V p_76163_3_)
|
|
||||||
{
|
|
||||||
int i = getHashedKey(p_76163_1_);
|
|
||||||
int j = getHashIndex(i, this.mask);
|
|
||||||
|
|
||||||
for (LongHashMap.Entry<V> entry = this.hashArray[j]; entry != null; entry = entry.nextEntry)
|
|
||||||
{
|
|
||||||
if (entry.key == p_76163_1_)
|
|
||||||
{
|
|
||||||
entry.value = p_76163_3_;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
++this.modCount;
|
|
||||||
this.createKey(i, p_76163_1_, p_76163_3_, j);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* resizes the table
|
|
||||||
*/
|
|
||||||
private void resizeTable(int p_76153_1_)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V>[] entry = this.hashArray;
|
|
||||||
int i = entry.length;
|
|
||||||
|
|
||||||
if (i == 1073741824)
|
|
||||||
{
|
|
||||||
this.capacity = Integer.MAX_VALUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V>[] entry1 = new LongHashMap.Entry[p_76153_1_];
|
|
||||||
this.copyHashTableTo(entry1);
|
|
||||||
this.hashArray = entry1;
|
|
||||||
this.mask = this.hashArray.length - 1;
|
|
||||||
this.capacity = (int)((float)p_76153_1_ * this.percentUseable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* copies the hash table to the specified array
|
|
||||||
*/
|
|
||||||
private void copyHashTableTo(LongHashMap.Entry<V>[] p_76154_1_)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V>[] entry = this.hashArray;
|
|
||||||
int i = p_76154_1_.length;
|
|
||||||
|
|
||||||
for (int j = 0; j < entry.length; ++j)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V> entry1 = entry[j];
|
|
||||||
|
|
||||||
if (entry1 != null)
|
|
||||||
{
|
|
||||||
entry[j] = null;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V> entry2 = entry1.nextEntry;
|
|
||||||
int k = getHashIndex(entry1.hash, i - 1);
|
|
||||||
entry1.nextEntry = p_76154_1_[k];
|
|
||||||
p_76154_1_[k] = entry1;
|
|
||||||
entry1 = entry2;
|
|
||||||
|
|
||||||
if (entry2 == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* calls the removeKey method and returns removed object
|
|
||||||
*/
|
|
||||||
public V remove(long p_76159_1_)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V> entry = this.removeKey(p_76159_1_);
|
|
||||||
return (V)(entry == null ? null : entry.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
final LongHashMap.Entry<V> removeKey(long p_76152_1_)
|
|
||||||
{
|
|
||||||
int i = getHashedKey(p_76152_1_);
|
|
||||||
int j = getHashIndex(i, this.mask);
|
|
||||||
LongHashMap.Entry<V> entry = this.hashArray[j];
|
|
||||||
LongHashMap.Entry<V> entry1;
|
|
||||||
LongHashMap.Entry<V> entry2;
|
|
||||||
|
|
||||||
for (entry1 = entry; entry1 != null; entry1 = entry2)
|
|
||||||
{
|
|
||||||
entry2 = entry1.nextEntry;
|
|
||||||
|
|
||||||
if (entry1.key == p_76152_1_)
|
|
||||||
{
|
|
||||||
++this.modCount;
|
|
||||||
--this.numHashElements;
|
|
||||||
|
|
||||||
if (entry == entry1)
|
|
||||||
{
|
|
||||||
this.hashArray[j] = entry2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
entry.nextEntry = entry2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry1;
|
|
||||||
}
|
|
||||||
|
|
||||||
entry = entry1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entry1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates the key in the hash table
|
|
||||||
*/
|
|
||||||
private void createKey(int p_76156_1_, long p_76156_2_, V p_76156_4_, int p_76156_5_)
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V> entry = this.hashArray[p_76156_5_];
|
|
||||||
this.hashArray[p_76156_5_] = new LongHashMap.Entry(p_76156_1_, p_76156_2_, p_76156_4_, entry);
|
|
||||||
|
|
||||||
if (this.numHashElements++ >= this.capacity)
|
|
||||||
{
|
|
||||||
this.resizeTable(2 * this.hashArray.length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class Entry<V>
|
|
||||||
{
|
|
||||||
final long key;
|
|
||||||
V value;
|
|
||||||
LongHashMap.Entry<V> nextEntry;
|
|
||||||
final int hash;
|
|
||||||
|
|
||||||
Entry(int p_i1553_1_, long p_i1553_2_, V p_i1553_4_, LongHashMap.Entry<V> p_i1553_5_)
|
|
||||||
{
|
|
||||||
this.value = p_i1553_4_;
|
|
||||||
this.nextEntry = p_i1553_5_;
|
|
||||||
this.key = p_i1553_2_;
|
|
||||||
this.hash = p_i1553_1_;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long getKey()
|
|
||||||
{
|
|
||||||
return this.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final V getValue()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final boolean equals(Object p_equals_1_)
|
|
||||||
{
|
|
||||||
if (!(p_equals_1_ instanceof LongHashMap.Entry))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LongHashMap.Entry<V> entry = (LongHashMap.Entry)p_equals_1_;
|
|
||||||
Object object = Long.valueOf(this.getKey());
|
|
||||||
Object object1 = Long.valueOf(entry.getKey());
|
|
||||||
|
|
||||||
if (object == object1 || object != null && object.equals(object1))
|
|
||||||
{
|
|
||||||
Object object2 = this.getValue();
|
|
||||||
Object object3 = entry.getValue();
|
|
||||||
|
|
||||||
if (object2 == object3 || object2 != null && object2.equals(object3))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int hashCode()
|
|
||||||
{
|
|
||||||
return LongHashMap.getHashedKey(this.key);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String toString()
|
|
||||||
{
|
|
||||||
return this.getKey() + "=" + this.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,7 +2,9 @@ package common.world;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import common.biome.Biome;
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
|
import common.block.LeavesType;
|
||||||
import common.dimension.Dimension;
|
import common.dimension.Dimension;
|
||||||
import common.entity.Entity;
|
import common.entity.Entity;
|
||||||
import common.entity.npc.EntityNPC;
|
import common.entity.npc.EntityNPC;
|
||||||
|
@ -44,4 +46,12 @@ public abstract class AWorldServer extends World {
|
||||||
public abstract boolean isBlockinHighHumidity(BlockPos pos);
|
public abstract boolean isBlockinHighHumidity(BlockPos pos);
|
||||||
public abstract <T extends Entity> T findNearestEntityWithinAABB(Class<? extends T> entityType, BoundingBox aabb, T closestTo);
|
public abstract <T extends Entity> T findNearestEntityWithinAABB(Class<? extends T> entityType, BoundingBox aabb, T closestTo);
|
||||||
public abstract long getTime();
|
public abstract long getTime();
|
||||||
|
public abstract Biome getBiomeGenForCoords(BlockPos pos);
|
||||||
|
public abstract boolean canBurnAt(BlockPos pos);
|
||||||
|
public abstract boolean canFreezeAt(BlockPos pos);
|
||||||
|
public abstract boolean doesWaterVaporize(BlockPos pos);
|
||||||
|
public abstract boolean isLavaFaster(BlockPos pos);
|
||||||
|
public abstract LeavesType getLeavesGen(BlockPos pos);
|
||||||
|
public abstract float getTemperatureC(BlockPos pos);
|
||||||
|
public abstract boolean isRainingAt(BlockPos strikePosition, boolean wet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,11 @@ public class BlockArray {
|
||||||
private int ticked;
|
private int ticked;
|
||||||
private char[] data;
|
private char[] data;
|
||||||
private NibbleArray blocklight;
|
private NibbleArray blocklight;
|
||||||
private NibbleArray skylight;
|
|
||||||
|
|
||||||
public BlockArray(int y, boolean sky) {
|
public BlockArray(int y) {
|
||||||
this.yBase = y;
|
this.yBase = y;
|
||||||
this.data = new char[4096];
|
this.data = new char[4096];
|
||||||
this.blocklight = new NibbleArray();
|
this.blocklight = new NibbleArray();
|
||||||
if(sky)
|
|
||||||
this.skylight = new NibbleArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public State get(int x, int y, int z) {
|
public State get(int x, int y, int z) {
|
||||||
|
@ -64,14 +61,6 @@ public class BlockArray {
|
||||||
return this.yBase;
|
return this.yBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSky(int x, int y, int z, int value) {
|
|
||||||
this.skylight.set(x, y, z, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSky(int x, int y, int z) {
|
|
||||||
return this.skylight.get(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLight(int x, int y, int z, int value) {
|
public void setLight(int x, int y, int z, int value) {
|
||||||
this.blocklight.set(x, y, z, value);
|
this.blocklight.set(x, y, z, value);
|
||||||
}
|
}
|
||||||
|
@ -105,10 +94,6 @@ public class BlockArray {
|
||||||
return this.blocklight;
|
return this.blocklight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NibbleArray getSkylight() {
|
|
||||||
return this.skylight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(char[] data) {
|
public void setData(char[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
|
@ -116,8 +101,4 @@ public class BlockArray {
|
||||||
public void setBlocklight(NibbleArray data) {
|
public void setBlocklight(NibbleArray data) {
|
||||||
this.blocklight = data;
|
this.blocklight = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSkylight(NibbleArray data) {
|
|
||||||
this.skylight = data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package common.world;
|
package common.world;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
@ -24,7 +23,6 @@ import common.util.ClassInheritanceMultiMap;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.util.NibbleArray;
|
import common.util.NibbleArray;
|
||||||
import common.worldgen.BiomeGenerator;
|
|
||||||
import common.worldgen.DebugStates;
|
import common.worldgen.DebugStates;
|
||||||
|
|
||||||
public class Chunk {
|
public class Chunk {
|
||||||
|
@ -33,21 +31,15 @@ public class Chunk {
|
||||||
private final World world;
|
private final World world;
|
||||||
private final BlockArray[] blocks = new BlockArray[32];
|
private final BlockArray[] blocks = new BlockArray[32];
|
||||||
private final byte[] biomes = new byte[256];
|
private final byte[] biomes = new byte[256];
|
||||||
private final int[] precHeight = new int[256];
|
|
||||||
private final boolean[] updateSky = new boolean[256];
|
|
||||||
private final int[] height = new int[256];
|
|
||||||
private final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
|
private final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
|
||||||
private final ClassInheritanceMultiMap<Entity>[] entities = new ClassInheritanceMultiMap[32];
|
private final ClassInheritanceMultiMap<Entity>[] entities = new ClassInheritanceMultiMap[32];
|
||||||
private final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
private final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
|
||||||
|
|
||||||
private boolean loaded;
|
private boolean loaded;
|
||||||
private boolean gapUpdate;
|
|
||||||
private boolean populated;
|
private boolean populated;
|
||||||
private boolean lightInit;
|
|
||||||
private boolean updated;
|
private boolean updated;
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
private boolean hasEntity;
|
private boolean hasEntity;
|
||||||
private int minHeight;
|
|
||||||
private int lightChecks = 8192;
|
private int lightChecks = 8192;
|
||||||
private long lastSave;
|
private long lastSave;
|
||||||
private long inhabited;
|
private long inhabited;
|
||||||
|
@ -59,13 +51,10 @@ public class Chunk {
|
||||||
for(int y = 0; y < this.entities.length; ++y) {
|
for(int y = 0; y < this.entities.length; ++y) {
|
||||||
this.entities[y] = new ClassInheritanceMultiMap(Entity.class);
|
this.entities[y] = new ClassInheritanceMultiMap(Entity.class);
|
||||||
}
|
}
|
||||||
Arrays.fill(this.precHeight, -999);
|
|
||||||
Arrays.fill(this.biomes, (byte)-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk(World world, short[] data, int height, State base, State ceil, Random rand, Biome[] biomes, int x, int z) {
|
public Chunk(World world, short[] data, int height, State base, State ceil, Random rand, int x, int z) {
|
||||||
this(world, x, z);
|
this(world, x, z);
|
||||||
boolean sky = !world.dimension.hasNoLight();
|
|
||||||
for(int bx = 0; bx < 16; ++bx) {
|
for(int bx = 0; bx < 16; ++bx) {
|
||||||
for(int bz = 0; bz < 16; ++bz) {
|
for(int bz = 0; bz < 16; ++bz) {
|
||||||
for(int by = 0; by < height; ++by) {
|
for(int by = 0; by < height; ++by) {
|
||||||
|
@ -73,7 +62,7 @@ public class Chunk {
|
||||||
if(state != null && state.getBlock().getMaterial() != Material.air) {
|
if(state != null && state.getBlock().getMaterial() != Material.air) {
|
||||||
int y = by >> 4;
|
int y = by >> 4;
|
||||||
if(this.blocks[y] == null)
|
if(this.blocks[y] == null)
|
||||||
this.blocks[y] = new BlockArray(y << 4, sky);
|
this.blocks[y] = new BlockArray(y << 4);
|
||||||
this.blocks[y].set(bx, by & 15, bz, state);
|
this.blocks[y].set(bx, by & 15, bz, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +70,7 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
if(base != null) {
|
if(base != null) {
|
||||||
if(this.blocks[0] == null)
|
if(this.blocks[0] == null)
|
||||||
this.blocks[0] = new BlockArray(0, sky);
|
this.blocks[0] = new BlockArray(0);
|
||||||
for(int bx = 0; bx < 16; ++bx) {
|
for(int bx = 0; bx < 16; ++bx) {
|
||||||
for(int bz = 0; bz < 16; ++bz) {
|
for(int bz = 0; bz < 16; ++bz) {
|
||||||
for(int by = 0; by < 5; ++by) {
|
for(int by = 0; by < 5; ++by) {
|
||||||
|
@ -94,10 +83,10 @@ public class Chunk {
|
||||||
if(ceil != null) {
|
if(ceil != null) {
|
||||||
int y = (height - 1) >> 4;
|
int y = (height - 1) >> 4;
|
||||||
if(this.blocks[y] == null)
|
if(this.blocks[y] == null)
|
||||||
this.blocks[y] = new BlockArray(y << 4, sky);
|
this.blocks[y] = new BlockArray(y << 4);
|
||||||
y = (height - 5) >> 4;
|
y = (height - 5) >> 4;
|
||||||
if(this.blocks[y] == null)
|
if(this.blocks[y] == null)
|
||||||
this.blocks[y] = new BlockArray(y << 4, sky);
|
this.blocks[y] = new BlockArray(y << 4);
|
||||||
for(int bx = 0; bx < 16; ++bx) {
|
for(int bx = 0; bx < 16; ++bx) {
|
||||||
for(int bz = 0; bz < 16; ++bz) {
|
for(int bz = 0; bz < 16; ++bz) {
|
||||||
for(int by = height - 1; by >= height - 5; --by) {
|
for(int by = height - 1; by >= height - 5; --by) {
|
||||||
|
@ -107,272 +96,14 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int n = 0; n < this.biomes.length; ++n) {
|
if(ceil != null)
|
||||||
this.biomes[n] = (byte)biomes[n].id;
|
|
||||||
}
|
|
||||||
if(ceil == null)
|
|
||||||
this.genSkyLight();
|
|
||||||
else
|
|
||||||
this.resetRelight();
|
this.resetRelight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHeight(BlockPos pos) {
|
|
||||||
return this.getHeight(pos.getX() & 15, pos.getZ() & 15);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight(int x, int z) {
|
|
||||||
return this.height[z << 4 | x];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTopSegment() {
|
|
||||||
for(int y = this.blocks.length - 1; y >= 0; --y) {
|
|
||||||
if(this.blocks[y] != null) {
|
|
||||||
return this.blocks[y].getY();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockArray[] getStorage() {
|
public BlockArray[] getStorage() {
|
||||||
return this.blocks;
|
return this.blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void genHeights() {
|
|
||||||
int h = this.getTopSegment();
|
|
||||||
this.minHeight = Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
this.precHeight[x + (z << 4)] = -999;
|
|
||||||
|
|
||||||
for(int y = h + 16; y > 0; --y) {
|
|
||||||
Block block = this.getBlock0(x, y - 1, z);
|
|
||||||
|
|
||||||
if(block.getLightOpacity() != 0) {
|
|
||||||
this.height[z << 4 | x] = y;
|
|
||||||
|
|
||||||
if(y < this.minHeight) {
|
|
||||||
this.minHeight = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void genSkyLight() {
|
|
||||||
int h = this.getTopSegment();
|
|
||||||
this.minHeight = Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
this.precHeight[x + (z << 4)] = -999;
|
|
||||||
|
|
||||||
for(int y = h + 16; y > 0; --y) {
|
|
||||||
if(this.getOpacity(x, y - 1, z) != 0) {
|
|
||||||
this.height[z << 4 | x] = y;
|
|
||||||
|
|
||||||
if(y < this.minHeight) {
|
|
||||||
this.minHeight = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.world.dimension.hasNoLight()) {
|
|
||||||
int l = 15;
|
|
||||||
int y = h + 16 - 1;
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
int b = this.getOpacity(x, y, z);
|
|
||||||
|
|
||||||
if(b == 0 && l != 15) {
|
|
||||||
b = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
l -= b;
|
|
||||||
|
|
||||||
if(l > 0) {
|
|
||||||
BlockArray stor = this.blocks[y >> 4];
|
|
||||||
|
|
||||||
if(stor != null) {
|
|
||||||
stor.setSky(x, y & 15, z, l);
|
|
||||||
this.world.notifyLightSet(new BlockPos((this.xPos << 4) + x, y, (this.zPos << 4) + z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--y;
|
|
||||||
|
|
||||||
if(y <= 0 || l <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void propagateOcclusion(int x, int z) {
|
|
||||||
this.updateSky[x + z * 16] = true;
|
|
||||||
this.gapUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void recheckGaps(boolean single) {
|
|
||||||
// this.world.profiler.start("recheckGaps");
|
|
||||||
|
|
||||||
if(this.world.isAreaLoaded(new BlockPos(this.xPos * 16 + 8, 0, this.zPos * 16 + 8), 16)) {
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
if(this.updateSky[x + z * 16]) {
|
|
||||||
this.updateSky[x + z * 16] = false;
|
|
||||||
int h = this.getHeight(x, z);
|
|
||||||
int cx = this.xPos * 16 + x;
|
|
||||||
int cz = this.zPos * 16 + z;
|
|
||||||
int max = Integer.MAX_VALUE;
|
|
||||||
|
|
||||||
for(Facing face : Facing.Plane.HORIZONTAL) {
|
|
||||||
max = Math.min(max, this.world.getChunksLowestHorizon(cx + face.getFrontOffsetX(),
|
|
||||||
cz + face.getFrontOffsetZ()));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.checkNeighbor(cx, cz, max);
|
|
||||||
|
|
||||||
for(Facing face : Facing.Plane.HORIZONTAL) {
|
|
||||||
this.checkNeighbor(cx + face.getFrontOffsetX(), cz + face.getFrontOffsetZ(), h);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(single) {
|
|
||||||
// this.world.profiler.end();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.gapUpdate = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this.world.profiler.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkNeighbor(int x, int z, int max) {
|
|
||||||
int h = this.world.getHeight(new BlockPos(x, 0, z)).getY();
|
|
||||||
|
|
||||||
if(h > max) {
|
|
||||||
this.updateNeighbor(x, z, max, h + 1);
|
|
||||||
}
|
|
||||||
else if(h < max) {
|
|
||||||
this.updateNeighbor(x, z, h, max + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateNeighbor(int x, int z, int bottom, int top) {
|
|
||||||
if(top > bottom && this.world.isAreaLoaded(new BlockPos(x, 0, z), 16)) {
|
|
||||||
for(int y = bottom; y < top; ++y) {
|
|
||||||
this.world.checkLightFor(LightType.SKY, new BlockPos(x, y, z));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modified = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void relightBlock(int x, int y, int z) {
|
|
||||||
int h = this.height[z << 4 | x] & 511;
|
|
||||||
int cy = h;
|
|
||||||
|
|
||||||
if(y > h) {
|
|
||||||
cy = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(cy > 0 && this.getOpacity(x, cy - 1, z) == 0) {
|
|
||||||
--cy;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(cy != h) {
|
|
||||||
this.world.markBlocksDirtyVertical(x + this.xPos * 16, z + this.zPos * 16, cy, h);
|
|
||||||
this.height[z << 4 | x] = cy;
|
|
||||||
int cx = this.xPos * 16 + x;
|
|
||||||
int cz = this.zPos * 16 + z;
|
|
||||||
|
|
||||||
if(!this.world.dimension.hasNoLight()) {
|
|
||||||
if(cy < h) {
|
|
||||||
for(int n = cy; n < h; ++n) {
|
|
||||||
BlockArray stor = this.blocks[n >> 4];
|
|
||||||
|
|
||||||
if(stor != null) {
|
|
||||||
stor.setSky(x, n & 15, z, 15);
|
|
||||||
this.world.notifyLightSet(new BlockPos((this.xPos << 4) + x, n, (this.zPos << 4) + z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(int n = h; n < cy; ++n) {
|
|
||||||
BlockArray stor = this.blocks[n >> 4];
|
|
||||||
|
|
||||||
if(stor != null) {
|
|
||||||
stor.setSky(x, n & 15, z, 0);
|
|
||||||
this.world.notifyLightSet(new BlockPos((this.xPos << 4) + x, n, (this.zPos << 4) + z));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int l = 15;
|
|
||||||
|
|
||||||
while(cy > 0 && l > 0) {
|
|
||||||
--cy;
|
|
||||||
int b = this.getOpacity(x, cy, z);
|
|
||||||
|
|
||||||
if(b == 0) {
|
|
||||||
b = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
l -= b;
|
|
||||||
|
|
||||||
if(l < 0) {
|
|
||||||
l = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
BlockArray stor = this.blocks[cy >> 4];
|
|
||||||
|
|
||||||
if(stor != null) {
|
|
||||||
stor.setSky(x, cy & 15, z, l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int sh = this.height[z << 4 | x];
|
|
||||||
int sy = h;
|
|
||||||
int ey = sh;
|
|
||||||
|
|
||||||
if(sh < h) {
|
|
||||||
sy = sh;
|
|
||||||
ey = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(sh < this.minHeight) {
|
|
||||||
this.minHeight = sh;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.world.dimension.hasNoLight()) {
|
|
||||||
for(Facing face : Facing.Plane.HORIZONTAL) {
|
|
||||||
this.updateNeighbor(cx + face.getFrontOffsetX(), cz + face.getFrontOffsetZ(), sy, ey);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateNeighbor(cx, cz, sy, ey);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.modified = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOpacity(BlockPos pos) {
|
public int getOpacity(BlockPos pos) {
|
||||||
return this.getBlock(pos).getLightOpacity();
|
return this.getBlock(pos).getLightOpacity();
|
||||||
}
|
}
|
||||||
|
@ -453,11 +184,6 @@ public class Chunk {
|
||||||
int z = pos.getZ() & 15;
|
int z = pos.getZ() & 15;
|
||||||
int o = z << 4 | x;
|
int o = z << 4 | x;
|
||||||
|
|
||||||
if(y >= this.precHeight[o] - 1) {
|
|
||||||
this.precHeight[o] = -999;
|
|
||||||
}
|
|
||||||
|
|
||||||
int h = this.height[o];
|
|
||||||
State old = this.getState(pos);
|
State old = this.getState(pos);
|
||||||
|
|
||||||
if(old == state) {
|
if(old == state) {
|
||||||
|
@ -467,15 +193,13 @@ public class Chunk {
|
||||||
Block block = state.getBlock();
|
Block block = state.getBlock();
|
||||||
Block oldb = old.getBlock();
|
Block oldb = old.getBlock();
|
||||||
BlockArray stor = this.blocks[y >> 4];
|
BlockArray stor = this.blocks[y >> 4];
|
||||||
boolean up = false;
|
|
||||||
|
|
||||||
if(stor == null) {
|
if(stor == null) {
|
||||||
if(block == Blocks.air) {
|
if(block == Blocks.air) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight());
|
stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4);
|
||||||
up = y >= h;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stor.set(x, y & 15, z, state);
|
stor.set(x, y & 15, z, state);
|
||||||
|
@ -493,27 +217,6 @@ public class Chunk {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(up) {
|
|
||||||
this.genSkyLight();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int b = block.getLightOpacity();
|
|
||||||
int ob = oldb.getLightOpacity();
|
|
||||||
|
|
||||||
if(b > 0) {
|
|
||||||
if(y >= h) {
|
|
||||||
this.relightBlock(x, y + 1, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(y == h - 1) {
|
|
||||||
this.relightBlock(x, y, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(b != ob && (b < ob || this.getLight(LightType.SKY, pos) > 0 || this.getLight(LightType.BLOCK, pos) > 0)) {
|
|
||||||
this.propagateOcclusion(x, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(oldb instanceof ITileEntityProvider) {
|
if(oldb instanceof ITileEntityProvider) {
|
||||||
TileEntity tile = this.getTileEntity(pos, TileEntity.EnumCreateEntityType.CHECK);
|
TileEntity tile = this.getTileEntity(pos, TileEntity.EnumCreateEntityType.CHECK);
|
||||||
|
|
||||||
|
@ -545,37 +248,27 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLight(LightType type, BlockPos pos) {
|
public int getLight(BlockPos pos) {
|
||||||
int x = pos.getX() & 15;
|
int x = pos.getX() & 15;
|
||||||
int y = pos.getY();
|
int y = pos.getY();
|
||||||
int z = pos.getZ() & 15;
|
int z = pos.getZ() & 15;
|
||||||
BlockArray stor = this.blocks[y >> 4];
|
BlockArray stor = this.blocks[y >> 4];
|
||||||
return stor == null ? (this.canSeeSky(pos) ? type.defValue : 0)
|
return stor == null ? 0 : stor.getLight(x, y & 15, z);
|
||||||
: (type == LightType.SKY ? (this.world.dimension.hasNoLight() ? 0 : stor.getSky(x, y & 15, z))
|
|
||||||
: (type == LightType.BLOCK ? stor.getLight(x, y & 15, z) : type.defValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLight(LightType type, BlockPos pos, int value) {
|
public void setLight(BlockPos pos, int value) {
|
||||||
int x = pos.getX() & 15;
|
int x = pos.getX() & 15;
|
||||||
int y = pos.getY();
|
int y = pos.getY();
|
||||||
int z = pos.getZ() & 15;
|
int z = pos.getZ() & 15;
|
||||||
BlockArray stor = this.blocks[y >> 4];
|
BlockArray stor = this.blocks[y >> 4];
|
||||||
|
|
||||||
if(stor == null) {
|
if(stor == null) {
|
||||||
stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight());
|
stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4);
|
||||||
this.genSkyLight();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
|
|
||||||
if(type == LightType.SKY) {
|
stor.setLight(x, y & 15, z, value);
|
||||||
if(!this.world.dimension.hasNoLight()) {
|
|
||||||
stor.setSky(x, y & 15, z, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(type == LightType.BLOCK) {
|
|
||||||
stor.setLight(x, y & 15, z, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLightSub(BlockPos pos, int amount) {
|
public int getLightSub(BlockPos pos, int amount) {
|
||||||
|
@ -585,11 +278,11 @@ public class Chunk {
|
||||||
BlockArray stor = this.blocks[y >> 4];
|
BlockArray stor = this.blocks[y >> 4];
|
||||||
|
|
||||||
if(stor == null) {
|
if(stor == null) {
|
||||||
return !this.world.dimension.hasNoLight() && amount < LightType.SKY.defValue
|
return !this.world.dimension.hasNoLight() && amount < 15
|
||||||
? LightType.SKY.defValue - amount : 0;
|
? 15 - amount : 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int l = this.world.dimension.hasNoLight() ? 0 : stor.getSky(x, y & 15, z);
|
int l = this.world.dimension.hasNoLight() ? 0 : 15;
|
||||||
l = l - amount;
|
l = l - amount;
|
||||||
int b = stor.getLight(x, y & 15, z);
|
int b = stor.getLight(x, y & 15, z);
|
||||||
|
|
||||||
|
@ -642,13 +335,6 @@ public class Chunk {
|
||||||
this.entities[y].remove(entity);
|
this.entities[y].remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSeeSky(BlockPos pos) {
|
|
||||||
int x = pos.getX() & 15;
|
|
||||||
int y = pos.getY();
|
|
||||||
int z = pos.getZ() & 15;
|
|
||||||
return y >= this.height[z << 4 | x];
|
|
||||||
}
|
|
||||||
|
|
||||||
private TileEntity createNewTileEntity(BlockPos pos) {
|
private TileEntity createNewTileEntity(BlockPos pos) {
|
||||||
Block block = this.getBlock(pos);
|
Block block = this.getBlock(pos);
|
||||||
return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.world, this.getMeta(pos));
|
return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.world, this.getMeta(pos));
|
||||||
|
@ -803,48 +489,9 @@ public class Chunk {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getPrecipitation(BlockPos pos) {
|
public void update() {
|
||||||
int x = pos.getX() & 15;
|
|
||||||
int z = pos.getZ() & 15;
|
|
||||||
int o = x | z << 4;
|
|
||||||
BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
|
|
||||||
|
|
||||||
if(loc.getY() == -999) {
|
|
||||||
int y = this.getTopSegment() + 15;
|
|
||||||
loc = new BlockPos(pos.getX(), y, pos.getZ());
|
|
||||||
int h = -1;
|
|
||||||
|
|
||||||
while(loc.getY() > 0 && h == -1) {
|
|
||||||
Block block = this.getBlock(loc);
|
|
||||||
Material mat = block.getMaterial();
|
|
||||||
|
|
||||||
if((!mat.blocksMovement() && !mat.isLiquid())
|
|
||||||
|| (mat == Material.leaves && ((mat = this.getBlock(loc.up()).getMaterial()) == Material.snow)
|
|
||||||
|| mat == Material.leaves)) {
|
|
||||||
loc = loc.down();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
h = loc.getY() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.precHeight[o] = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(boolean noGaps) {
|
|
||||||
if(this.gapUpdate && !this.world.dimension.hasNoLight() && !noGaps) {
|
|
||||||
this.recheckGaps(this.world.client);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updated = true;
|
this.updated = true;
|
||||||
|
|
||||||
if(!this.lightInit && this.populated) {
|
|
||||||
this.checkLight();
|
|
||||||
}
|
|
||||||
|
|
||||||
while(!this.tileQueue.isEmpty()) {
|
while(!this.tileQueue.isEmpty()) {
|
||||||
BlockPos pos = (BlockPos)this.tileQueue.poll();
|
BlockPos pos = (BlockPos)this.tileQueue.poll();
|
||||||
|
|
||||||
|
@ -857,7 +504,7 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPopulated() {
|
public boolean isPopulated() {
|
||||||
return this.updated && this.populated && this.lightInit;
|
return this.updated && this.populated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPos getPos() {
|
public ChunkPos getPos() {
|
||||||
|
@ -896,14 +543,13 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(byte[] data, int update, boolean biomes) {
|
public void setData(byte[] data, int update, boolean resend) {
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
boolean sky = !this.world.dimension.hasNoLight();
|
|
||||||
|
|
||||||
for(int n = 0; n < this.blocks.length; ++n) {
|
for(int n = 0; n < this.blocks.length; ++n) {
|
||||||
if((update & 1 << n) != 0) {
|
if((update & 1 << n) != 0) {
|
||||||
if(this.blocks[n] == null) {
|
if(this.blocks[n] == null) {
|
||||||
this.blocks[n] = new BlockArray(n << 4, sky);
|
this.blocks[n] = new BlockArray(n << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
char[] blocks = this.blocks[n].getData();
|
char[] blocks = this.blocks[n].getData();
|
||||||
|
@ -913,7 +559,7 @@ public class Chunk {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(biomes && this.blocks[n] != null) {
|
else if(resend && this.blocks[n] != null) {
|
||||||
this.blocks[n] = null;
|
this.blocks[n] = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -926,65 +572,32 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sky) {
|
|
||||||
for(int n = 0; n < this.blocks.length; ++n) {
|
|
||||||
if((update & 1 << n) != 0 && this.blocks[n] != null) {
|
|
||||||
NibbleArray slight = this.blocks[n].getSkylight();
|
|
||||||
System.arraycopy(data, pos, slight.getData(), 0, slight.getData().length);
|
|
||||||
pos += slight.getData().length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(biomes) {
|
|
||||||
System.arraycopy(data, pos, this.biomes, 0, this.biomes.length);
|
|
||||||
// int unk = pos + this.biomes.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int n = 0; n < this.blocks.length; ++n) {
|
for(int n = 0; n < this.blocks.length; ++n) {
|
||||||
if(this.blocks[n] != null && (update & 1 << n) != 0) {
|
if(this.blocks[n] != null && (update & 1 << n) != 0) {
|
||||||
this.blocks[n].update();
|
this.blocks[n].update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lightInit = true;
|
|
||||||
this.populated = true;
|
this.populated = true;
|
||||||
this.genHeights();
|
|
||||||
|
|
||||||
for(TileEntity tile : this.tiles.values()) {
|
for(TileEntity tile : this.tiles.values()) {
|
||||||
tile.updateContainingBlockInfo();
|
tile.updateContainingBlockInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiome(BlockPos pos, BiomeGenerator gen) {
|
public Biome getBiome(BlockPos pos) {
|
||||||
int x = pos.getX() & 15;
|
int x = pos.getX() & 15;
|
||||||
int z = pos.getZ() & 15;
|
int z = pos.getZ() & 15;
|
||||||
int o = this.biomes[z << 4 | x] & 255;
|
int o = this.biomes[z << 4 | x] & 255;
|
||||||
|
|
||||||
if(o == 255) {
|
if(o == 255) {
|
||||||
Biome biome = gen == null ? Biome.DEF_BIOME : gen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
o = Biome.DEF_BIOME.id;
|
||||||
o = biome.id;
|
|
||||||
this.biomes[z << 4 | x] = (byte)(o & 255);
|
this.biomes[z << 4 | x] = (byte)(o & 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Biome.getBiomeDef(o);
|
return Biome.getBiomeDef(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBiomes() {
|
|
||||||
return this.biomes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBiomes(byte[] biomes) {
|
|
||||||
if(this.biomes.length != biomes.length) {
|
|
||||||
Log.JNI.warn("Konnte Biome des Chunks nicht setzen, Länge des Arrays ist " + biomes.length + " statt " + this.biomes.length);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(int n = 0; n < this.biomes.length; ++n) {
|
|
||||||
this.biomes[n] = biomes[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetRelight() {
|
public void resetRelight() {
|
||||||
this.lightChecks = 0;
|
this.lightChecks = 0;
|
||||||
}
|
}
|
||||||
|
@ -1027,106 +640,7 @@ public class Chunk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkLight() {
|
|
||||||
this.populated = true;
|
|
||||||
this.lightInit = true;
|
|
||||||
BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4);
|
|
||||||
|
|
||||||
if(!this.world.dimension.hasNoLight()) {
|
|
||||||
if(this.world.isAreaLoaded(pos.add(-1, 0, -1), pos.add(16, this.world.getSeaLevel(), 16))) {
|
|
||||||
label92:
|
|
||||||
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
if(!this.updateColumn(x, z)) {
|
|
||||||
this.lightInit = false;
|
|
||||||
break label92;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.lightInit) {
|
|
||||||
for(Facing face : Facing.Plane.HORIZONTAL) {
|
|
||||||
int d = face.getAxisDirection() == Facing.AxisDirection.POSITIVE ? 16 : 1;
|
|
||||||
this.world.getChunk(pos.offset(face, d)).updateColumns(face.getOpposite());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setSkyDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.lightInit = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setSkyDirty() {
|
|
||||||
for(int n = 0; n < this.updateSky.length; ++n) {
|
|
||||||
this.updateSky[n] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.recheckGaps(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateColumns(Facing facing) {
|
|
||||||
if(this.populated) {
|
|
||||||
if(facing == Facing.EAST) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
this.updateColumn(15, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(facing == Facing.WEST) {
|
|
||||||
for(int z = 0; z < 16; ++z) {
|
|
||||||
this.updateColumn(0, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(facing == Facing.SOUTH) {
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
this.updateColumn(x, 15);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(facing == Facing.NORTH) {
|
|
||||||
for(int x = 0; x < 16; ++x) {
|
|
||||||
this.updateColumn(x, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean updateColumn(int x, int z) {
|
|
||||||
int top = this.getTopSegment();
|
|
||||||
boolean opaque = false;
|
|
||||||
boolean below = false;
|
|
||||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z);
|
|
||||||
|
|
||||||
for(int y = top + 16 - 1; y > this.world.getSeaLevel() || y > 0 && !below; --y) {
|
|
||||||
pos.set(pos.getX(), y, pos.getZ());
|
|
||||||
int o = this.getOpacity(pos);
|
|
||||||
|
|
||||||
if(o == 255 && pos.getY() < this.world.getSeaLevel()) {
|
|
||||||
below = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!opaque && o > 0) {
|
|
||||||
opaque = true;
|
|
||||||
}
|
|
||||||
else if(opaque && o == 0 && !this.world.checkLight(pos)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(int y = pos.getY(); y > 0; --y) {
|
|
||||||
pos.set(pos.getX(), y, pos.getZ());
|
|
||||||
|
|
||||||
if(this.getBlock(pos).getLightValue() > 0) {
|
|
||||||
this.world.checkLight(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLoaded() {
|
public boolean isLoaded() {
|
||||||
return this.loaded;
|
return this.loaded;
|
||||||
}
|
}
|
||||||
|
@ -1139,21 +653,6 @@ public class Chunk {
|
||||||
return this.world;
|
return this.world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getHeights() {
|
|
||||||
return this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeights(int[] map) {
|
|
||||||
if(this.height.length != map.length) {
|
|
||||||
Log.JNI.warn("Konnte Höhen des Chunks nicht setzen, Länge des Arrays ist " + map.length + " statt " + this.height.length);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(int n = 0; n < this.height.length; ++n) {
|
|
||||||
this.height[n] = map[n];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<BlockPos, TileEntity> getTiles() {
|
public Map<BlockPos, TileEntity> getTiles() {
|
||||||
return this.tiles;
|
return this.tiles;
|
||||||
}
|
}
|
||||||
|
@ -1170,14 +669,6 @@ public class Chunk {
|
||||||
this.populated = populated;
|
this.populated = populated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLightPopulated() {
|
|
||||||
return this.lightInit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLightPopulated(boolean populated) {
|
|
||||||
this.lightInit = populated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModified(boolean modified) {
|
public void setModified(boolean modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
@ -1190,10 +681,6 @@ public class Chunk {
|
||||||
this.lastSave = time;
|
this.lastSave = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLowest() {
|
|
||||||
return this.minHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getInhabited() {
|
public long getInhabited() {
|
||||||
return this.inhabited;
|
return this.inhabited;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package common.world;
|
package common.world;
|
||||||
|
|
||||||
import common.biome.Biome;
|
|
||||||
import common.tileentity.TileEntity;
|
import common.tileentity.TileEntity;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
|
|
||||||
|
@ -8,5 +7,4 @@ public interface IWorldAccess extends IBlockAccess
|
||||||
{
|
{
|
||||||
TileEntity getTileEntity(BlockPos pos);
|
TileEntity getTileEntity(BlockPos pos);
|
||||||
int getCombinedLight(BlockPos pos, int lightValue);
|
int getCombinedLight(BlockPos pos, int lightValue);
|
||||||
Biome getBiomeGenForCoords(BlockPos pos);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package common.world;
|
|
||||||
|
|
||||||
public enum LightType {
|
|
||||||
SKY(15), BLOCK(0);
|
|
||||||
|
|
||||||
public final int defValue;
|
|
||||||
|
|
||||||
private LightType(int def) {
|
|
||||||
this.defValue = def;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -6,14 +6,12 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import common.biome.Biome;
|
|
||||||
import common.block.Block;
|
import common.block.Block;
|
||||||
import common.block.BlockHopper;
|
import common.block.BlockHopper;
|
||||||
import common.block.BlockLiquid;
|
import common.block.BlockLiquid;
|
||||||
import common.block.BlockSlab;
|
import common.block.BlockSlab;
|
||||||
import common.block.BlockSnow;
|
import common.block.BlockSnow;
|
||||||
import common.block.BlockStairs;
|
import common.block.BlockStairs;
|
||||||
import common.block.LeavesType;
|
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Sets;
|
import common.collect.Sets;
|
||||||
import common.dimension.Dimension;
|
import common.dimension.Dimension;
|
||||||
|
@ -80,7 +78,6 @@ public abstract class World implements IWorldAccess {
|
||||||
protected float rain;
|
protected float rain;
|
||||||
protected float darkness;
|
protected float darkness;
|
||||||
protected float fog;
|
protected float fog;
|
||||||
protected float temp;
|
|
||||||
protected Weather weather;
|
protected Weather weather;
|
||||||
protected long daytime;
|
protected long daytime;
|
||||||
|
|
||||||
|
@ -132,14 +129,7 @@ public abstract class World implements IWorldAccess {
|
||||||
if(Math.abs(this.gravity) < 0.075)
|
if(Math.abs(this.gravity) < 0.075)
|
||||||
this.gravity = Math.signum(this.gravity) * 0.075;
|
this.gravity = Math.signum(this.gravity) * 0.075;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiomeGenForCoords(final BlockPos pos) {
|
|
||||||
if(this.isBlockLoaded(pos))
|
|
||||||
return this.getChunk(pos).getBiome(pos, null);
|
|
||||||
else
|
|
||||||
return Biome.DEF_BIOME;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAirBlock(BlockPos pos) {
|
public boolean isAirBlock(BlockPos pos) {
|
||||||
return this.getState(pos).getBlock().getMaterial() == Material.air;
|
return this.getState(pos).getBlock().getMaterial() == Material.air;
|
||||||
}
|
}
|
||||||
|
@ -282,13 +272,7 @@ public abstract class World implements IWorldAccess {
|
||||||
z2 = x2;
|
z2 = x2;
|
||||||
x2 = i;
|
x2 = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.dimension.hasNoLight()) {
|
|
||||||
for(int j = x2; j <= z2; ++j) {
|
|
||||||
this.checkLightFor(LightType.SKY, new BlockPos(x1, j, z1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.markBlockRangeForRenderUpdate(x1, x2, z1, x1, z2, z1);
|
this.markBlockRangeForRenderUpdate(x1, x2, z1, x1, z2, z1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,10 +323,6 @@ public abstract class World implements IWorldAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSeeSky(BlockPos pos) {
|
|
||||||
return this.getChunk(pos).canSeeSky(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLight(BlockPos pos) {
|
public int getLight(BlockPos pos) {
|
||||||
if(pos.getY() < 0) {
|
if(pos.getY() < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -404,122 +384,83 @@ public abstract class World implements IWorldAccess {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getHeight(BlockPos pos) {
|
public int getLightFromNeighborsFor(BlockPos pos) {
|
||||||
int i;
|
|
||||||
|
|
||||||
if(pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE) {
|
|
||||||
if(this.isLoaded(pos.getX() >> 4, pos.getZ() >> 4, true)) {
|
|
||||||
i = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4).getHeight(pos.getX() & 15, pos.getZ() & 15);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
i = this.getSeaLevel() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new BlockPos(pos.getX(), i, pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChunksLowestHorizon(int x, int z) {
|
|
||||||
if(x >= -MAX_SIZE && z >= -MAX_SIZE && x < MAX_SIZE && z < MAX_SIZE) {
|
|
||||||
if(!this.isLoaded(x >> 4, z >> 4, true)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Chunk chunk = this.getChunk(x >> 4, z >> 4);
|
|
||||||
return chunk.getLowest();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return this.getSeaLevel() + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLightFromNeighborsFor(LightType type, BlockPos pos) {
|
|
||||||
if(this.dimension.hasNoLight() && type == LightType.SKY) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(pos.getY() < 0) {
|
|
||||||
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isValid(pos)) {
|
|
||||||
return type.defValue;
|
|
||||||
}
|
|
||||||
else if(!this.isBlockLoaded(pos)) {
|
|
||||||
return type.defValue;
|
|
||||||
}
|
|
||||||
else if(this.getState(pos).getBlock().getSumBrightness()) {
|
|
||||||
int i1 = this.getLightFor(type, pos.up());
|
|
||||||
int i = this.getLightFor(type, pos.east());
|
|
||||||
int j = this.getLightFor(type, pos.west());
|
|
||||||
int k = this.getLightFor(type, pos.south());
|
|
||||||
int l = this.getLightFor(type, pos.north());
|
|
||||||
|
|
||||||
if(i > i1) {
|
|
||||||
i1 = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(j > i1) {
|
|
||||||
i1 = j;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(k > i1) {
|
|
||||||
i1 = k;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(l > i1) {
|
|
||||||
i1 = l;
|
|
||||||
}
|
|
||||||
|
|
||||||
return i1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Chunk chunk = this.getChunk(pos);
|
|
||||||
return chunk.getLight(type, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLightFor(LightType type, BlockPos pos) {
|
|
||||||
if(pos.getY() < 0) {
|
if(pos.getY() < 0) {
|
||||||
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isValid(pos)) {
|
if(!isValid(pos)) {
|
||||||
return type.defValue;
|
return 0;
|
||||||
}
|
}
|
||||||
else if(!this.isBlockLoaded(pos)) {
|
else if(!this.isBlockLoaded(pos)) {
|
||||||
return type.defValue;
|
return 0;
|
||||||
|
}
|
||||||
|
else if(this.getState(pos).getBlock().getSumBrightness()) {
|
||||||
|
int i1 = this.getLightFor(pos.up());
|
||||||
|
int i = this.getLightFor(pos.east());
|
||||||
|
int j = this.getLightFor(pos.west());
|
||||||
|
int k = this.getLightFor(pos.south());
|
||||||
|
int l = this.getLightFor(pos.north());
|
||||||
|
|
||||||
|
if(i > i1) {
|
||||||
|
i1 = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j > i1) {
|
||||||
|
i1 = j;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(k > i1) {
|
||||||
|
i1 = k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(l > i1) {
|
||||||
|
i1 = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Chunk chunk = this.getChunk(pos);
|
Chunk chunk = this.getChunk(pos);
|
||||||
return chunk.getLight(type, pos);
|
return chunk.getLight(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLightFor(LightType type, BlockPos pos, int lightValue) {
|
public int getLightFor(BlockPos pos) {
|
||||||
|
if(pos.getY() < 0) {
|
||||||
|
pos = new BlockPos(pos.getX(), 0, pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isValid(pos)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(!this.isBlockLoaded(pos)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Chunk chunk = this.getChunk(pos);
|
||||||
|
return chunk.getLight(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLightFor(BlockPos pos, int lightValue) {
|
||||||
if(isValid(pos)) {
|
if(isValid(pos)) {
|
||||||
if(this.isBlockLoaded(pos)) {
|
if(this.isBlockLoaded(pos)) {
|
||||||
Chunk chunk = this.getChunk(pos);
|
Chunk chunk = this.getChunk(pos);
|
||||||
chunk.setLight(type, pos, lightValue);
|
chunk.setLight(pos, lightValue);
|
||||||
this.notifyLightSet(pos);
|
this.notifyLightSet(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCombinedLight(BlockPos pos, int lightValue) {
|
public int getCombinedLight(BlockPos pos, int lightValue) {
|
||||||
int i = this.getLightFromNeighborsFor(LightType.SKY, pos);
|
int j = this.getLightFromNeighborsFor(pos);
|
||||||
int j = this.getLightFromNeighborsFor(LightType.BLOCK, pos);
|
|
||||||
|
|
||||||
if(j < lightValue) {
|
if(j < lightValue) {
|
||||||
j = lightValue;
|
j = lightValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i << 20 | j << 4;
|
return 15 << 20 | j << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getLightBrightness(BlockPos pos) {
|
public float getLightBrightness(BlockPos pos) {
|
||||||
|
@ -935,8 +876,30 @@ public abstract class World implements IWorldAccess {
|
||||||
return f * (float)Math.PI * 2.0F;
|
return f * (float)Math.PI * 2.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockPos getPrecipitationHeight(BlockPos pos, int y, int scan) {
|
||||||
|
scan = y - scan;
|
||||||
|
BlockPos loc = new BlockPos(pos.getX(), y, pos.getZ());
|
||||||
|
y = -1;
|
||||||
|
|
||||||
|
while(loc.getY() > 0 && loc.getY() >= scan && y == -1) {
|
||||||
|
Block block = this.getState(loc).getBlock();
|
||||||
|
Material mat = block.getMaterial();
|
||||||
|
|
||||||
|
if((!mat.blocksMovement() && !mat.isLiquid())
|
||||||
|
|| (mat == Material.leaves && ((mat = this.getState(loc.up()).getBlock().getMaterial()) == Material.snow)
|
||||||
|
|| mat == Material.leaves)) {
|
||||||
|
loc = loc.down();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
y = loc.getY() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BlockPos(pos.getX(), y, pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
public BlockPos getPrecipitationHeight(BlockPos pos) {
|
public BlockPos getPrecipitationHeight(BlockPos pos) {
|
||||||
return this.getChunk(pos).getPrecipitation(pos);
|
return this.getPrecipitationHeight(pos, 256, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateEntities() {
|
public void updateEntities() {
|
||||||
|
@ -1509,7 +1472,6 @@ public abstract class World implements IWorldAccess {
|
||||||
this.rain = this.weather.hasDownfall() ? 1.0f : 0.0f;
|
this.rain = this.weather.hasDownfall() ? 1.0f : 0.0f;
|
||||||
this.darkness = this.weather.isDark() ? 1.0f : 0.0f;
|
this.darkness = this.weather.isDark() ? 1.0f : 0.0f;
|
||||||
this.fog = this.weather.getFogIntensity();
|
this.fog = this.weather.getFogIntensity();
|
||||||
this.temp = this.getBaseTemperature() + this.weather.getTemperature();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setActivePlayerChunksAndCheckLight(int l) {
|
protected void setActivePlayerChunksAndCheckLight(int l) {
|
||||||
|
@ -1545,121 +1507,48 @@ public abstract class World implements IWorldAccess {
|
||||||
// this.profiler.end();
|
// this.profiler.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getTempOffset() {
|
|
||||||
return this.temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected float getBaseTemperature() {
|
|
||||||
return this.dimension.getTemperature() + this.dimension.getOrbitOffset() *
|
|
||||||
ExtMath.sin((((float)(this.daytime % this.dimension.getOrbitalPeriod()) / (float)this.dimension.getOrbitalPeriod())
|
|
||||||
-0.125f) * (float)Math.PI * 2.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LeavesType getLeavesGen(BlockPos pos) {
|
|
||||||
return this.canFreezeAt(pos) ? LeavesType.SNOWY : ((!this.dimension.getType().days || this.dimension.getOrbitOffset() == 0.0f) ?
|
|
||||||
this.dimension.getLeavesType() : LeavesType.values()[(int)((this.daytime %
|
|
||||||
this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTemperatureK(BlockPos pos) {
|
|
||||||
return this.temp + this.getBiomeGenForCoords(pos).getTemperature(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getTemperatureC(BlockPos pos) {
|
|
||||||
return World.ABSOLUTE_ZERO + this.getTemperatureK(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canFreezeAt(BlockPos pos) {
|
|
||||||
return this.getTemperatureC(pos) <= 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canBurnAt(BlockPos pos) {
|
|
||||||
return this.getTemperatureC(pos) >= 194.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean doesWaterVaporize(BlockPos pos) {
|
|
||||||
return this.getTemperatureC(pos) >= 100.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLavaFaster(BlockPos pos) {
|
|
||||||
return this.getTemperatureC(pos) >= 314.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canSnowAt(BlockPos pos, boolean checkLight, boolean allowLayers) {
|
|
||||||
if(!this.canFreezeAt(pos)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(!checkLight) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
|
|
||||||
Block block = this.getState(pos).getBlock();
|
|
||||||
|
|
||||||
if((block.getMaterial() == Material.air || (allowLayers && block == Blocks.snow_layer))
|
|
||||||
&& Blocks.snow_layer.canPlaceBlockAt(this, pos)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkLight(BlockPos pos) {
|
public boolean checkLight(BlockPos pos) {
|
||||||
boolean flag = false;
|
return this.checkLightFor(pos);
|
||||||
|
|
||||||
if(!this.dimension.hasNoLight()) {
|
|
||||||
flag |= this.checkLightFor(LightType.SKY, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
flag = flag | this.checkLightFor(LightType.BLOCK, pos);
|
|
||||||
return flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getRawLight(BlockPos pos, LightType lightType) {
|
private int getRawLight(BlockPos pos) {
|
||||||
if(lightType == LightType.SKY && this.canSeeSky(pos)) {
|
Block block = this.getState(pos).getBlock();
|
||||||
return 15;
|
int i = block.getLightValue();
|
||||||
|
int j = block.getLightOpacity();
|
||||||
|
|
||||||
|
if(j >= 15 && block.getLightValue() > 0) {
|
||||||
|
j = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j < 1) {
|
||||||
|
j = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(j >= 15) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if(i >= 14) {
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Block block = this.getState(pos).getBlock();
|
for(Facing enumfacing : Facing.values()) {
|
||||||
int i = lightType == LightType.SKY ? 0 : block.getLightValue();
|
BlockPos blockpos = pos.offset(enumfacing);
|
||||||
int j = block.getLightOpacity();
|
int k = this.getLightFor(blockpos) - j;
|
||||||
|
|
||||||
if(j >= 15 && block.getLightValue() > 0) {
|
if(k > i) {
|
||||||
j = 1;
|
i = k;
|
||||||
}
|
|
||||||
|
|
||||||
if(j < 1) {
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(j >= 15) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(i >= 14) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for(Facing enumfacing : Facing.values()) {
|
|
||||||
BlockPos blockpos = pos.offset(enumfacing);
|
|
||||||
int k = this.getLightFor(lightType, blockpos) - j;
|
|
||||||
|
|
||||||
if(k > i) {
|
|
||||||
i = k;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i >= 14) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
if(i >= 14) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkLightFor(LightType lightType, BlockPos pos) {
|
public boolean checkLightFor(BlockPos pos) {
|
||||||
if(!this.isAreaLoaded(pos, 17, false)) {
|
if(!this.isAreaLoaded(pos, 17, false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1667,8 +1556,8 @@ public abstract class World implements IWorldAccess {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
// this.profiler.start("getBrightness");
|
// this.profiler.start("getBrightness");
|
||||||
int k = this.getLightFor(lightType, pos);
|
int k = this.getLightFor(pos);
|
||||||
int l = this.getRawLight(pos, lightType);
|
int l = this.getRawLight(pos);
|
||||||
int i1 = pos.getX();
|
int i1 = pos.getX();
|
||||||
int j1 = pos.getY();
|
int j1 = pos.getY();
|
||||||
int k1 = pos.getZ();
|
int k1 = pos.getZ();
|
||||||
|
@ -1686,10 +1575,10 @@ public abstract class World implements IWorldAccess {
|
||||||
int k2 = (l1 >> 12 & 63) - 32 + k1;
|
int k2 = (l1 >> 12 & 63) - 32 + k1;
|
||||||
int l2 = l1 >> 18 & 15;
|
int l2 = l1 >> 18 & 15;
|
||||||
BlockPos blockpos = new BlockPos(i2, j2, k2);
|
BlockPos blockpos = new BlockPos(i2, j2, k2);
|
||||||
int i3 = this.getLightFor(lightType, blockpos);
|
int i3 = this.getLightFor(blockpos);
|
||||||
|
|
||||||
if(i3 == l2) {
|
if(i3 == l2) {
|
||||||
this.setLightFor(lightType, blockpos, 0);
|
this.setLightFor(blockpos, 0);
|
||||||
|
|
||||||
if(l2 > 0) {
|
if(l2 > 0) {
|
||||||
int j3 = ExtMath.absi(i2 - i1);
|
int j3 = ExtMath.absi(i2 - i1);
|
||||||
|
@ -1705,7 +1594,7 @@ public abstract class World implements IWorldAccess {
|
||||||
int k4 = k2 + enumfacing.getFrontOffsetZ();
|
int k4 = k2 + enumfacing.getFrontOffsetZ();
|
||||||
blockpos$mutableblockpos.set(i4, j4, k4);
|
blockpos$mutableblockpos.set(i4, j4, k4);
|
||||||
int l4 = Math.max(1, this.getState(blockpos$mutableblockpos).getBlock().getLightOpacity());
|
int l4 = Math.max(1, this.getState(blockpos$mutableblockpos).getBlock().getLightOpacity());
|
||||||
i3 = this.getLightFor(lightType, blockpos$mutableblockpos);
|
i3 = this.getLightFor(blockpos$mutableblockpos);
|
||||||
|
|
||||||
if(i3 == l2 - l4 && j < this.lightUpdate.length) {
|
if(i3 == l2 - l4 && j < this.lightUpdate.length) {
|
||||||
this.lightUpdate[j++] = i4 - i1 + 32 | j4 - j1 + 32 << 6 | k4 - k1 + 32 << 12 | l2 - l4 << 18;
|
this.lightUpdate[j++] = i4 - i1 + 32 | j4 - j1 + 32 << 6 | k4 - k1 + 32 << 12 | l2 - l4 << 18;
|
||||||
|
@ -1728,11 +1617,11 @@ public abstract class World implements IWorldAccess {
|
||||||
int k5 = (i5 >> 6 & 63) - 32 + j1;
|
int k5 = (i5 >> 6 & 63) - 32 + j1;
|
||||||
int l5 = (i5 >> 12 & 63) - 32 + k1;
|
int l5 = (i5 >> 12 & 63) - 32 + k1;
|
||||||
BlockPos blockpos1 = new BlockPos(j5, k5, l5);
|
BlockPos blockpos1 = new BlockPos(j5, k5, l5);
|
||||||
int i6 = this.getLightFor(lightType, blockpos1);
|
int i6 = this.getLightFor(blockpos1);
|
||||||
int j6 = this.getRawLight(blockpos1, lightType);
|
int j6 = this.getRawLight(blockpos1);
|
||||||
|
|
||||||
if(j6 != i6) {
|
if(j6 != i6) {
|
||||||
this.setLightFor(lightType, blockpos1, j6);
|
this.setLightFor(blockpos1, j6);
|
||||||
|
|
||||||
if(j6 > i6) {
|
if(j6 > i6) {
|
||||||
int k6 = Math.abs(j5 - i1);
|
int k6 = Math.abs(j5 - i1);
|
||||||
|
@ -1741,27 +1630,27 @@ public abstract class World implements IWorldAccess {
|
||||||
boolean flag = j < this.lightUpdate.length - 6;
|
boolean flag = j < this.lightUpdate.length - 6;
|
||||||
|
|
||||||
if(k6 + l6 + i7 < 17 && flag) {
|
if(k6 + l6 + i7 < 17 && flag) {
|
||||||
if(this.getLightFor(lightType, blockpos1.west()) < j6) {
|
if(this.getLightFor(blockpos1.west()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 - 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 - 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getLightFor(lightType, blockpos1.east()) < j6) {
|
if(this.getLightFor(blockpos1.east()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 + 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 + 1 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getLightFor(lightType, blockpos1.down()) < j6) {
|
if(this.getLightFor(blockpos1.down()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getLightFor(lightType, blockpos1.up()) < j6) {
|
if(this.getLightFor(blockpos1.up()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 + 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 + 1 - j1 + 32 << 6) + (l5 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getLightFor(lightType, blockpos1.north()) < j6) {
|
if(this.getLightFor(blockpos1.north()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - 1 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 - 1 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.getLightFor(lightType, blockpos1.south()) < j6) {
|
if(this.getLightFor(blockpos1.south()) < j6) {
|
||||||
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 + 1 - k1 + 32 << 12);
|
this.lightUpdate[j++] = j5 - i1 + 32 + (k5 - j1 + 32 << 6) + (l5 + 1 - k1 + 32 << 12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2039,11 +1928,7 @@ public abstract class World implements IWorldAccess {
|
||||||
public void setFogStrength(float strength) {
|
public void setFogStrength(float strength) {
|
||||||
this.fog = strength;
|
this.fog = strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTemperature(float temp) {
|
|
||||||
this.temp = temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDark() {
|
public boolean isDark() {
|
||||||
return this.darkness > 0.9f;
|
return this.darkness > 0.9f;
|
||||||
}
|
}
|
||||||
|
@ -2060,23 +1945,6 @@ public abstract class World implements IWorldAccess {
|
||||||
return this.hasDownfall() && this.weather.canRain();
|
return this.hasDownfall() && this.weather.canRain();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRainingAt(BlockPos strikePosition, boolean wet) {
|
|
||||||
if(wet ? !this.isRaining() : !this.hasDownfall()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(!this.canSeeSky(strikePosition)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !this.canSnowAt(strikePosition, false, false);
|
|
||||||
// else {
|
|
||||||
// Biome biomegenbase = this.getBiomeGenForCoords(strikePosition);
|
|
||||||
// return biomegenbase.isSnowyBiome() ? false : ( ? false : biomegenbase.canRain());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
// public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
|
@ -1174,7 +1174,6 @@ public final class Server implements IThreadListener {
|
||||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.RAIN_STRENGTH, world.getRainStrength()));
|
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.RAIN_STRENGTH, world.getRainStrength()));
|
||||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.DARKNESS, world.getDarkness()));
|
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.DARKNESS, world.getDarkness()));
|
||||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.FOG_STRENGTH, world.getFogStrength()));
|
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.FOG_STRENGTH, world.getFogStrength()));
|
||||||
conn.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.TEMPERATURE, world.getTempOffset()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void syncPlayerInventory(EntityNPC player) {
|
public void syncPlayerInventory(EntityNPC player) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class BiomeChaos extends GenBiome
|
||||||
{
|
{
|
||||||
int i8 = rand.chOffset();
|
int i8 = rand.chOffset();
|
||||||
int l11 = rand.chOffset();
|
int l11 = rand.chOffset();
|
||||||
BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11));
|
BlockPos blockpos2 = worldIn.getPrecipitationHeight(pos.add(i8, 0, l11));
|
||||||
this.mushroomBlueGen.generate(worldIn, rand, blockpos2);
|
this.mushroomBlueGen.generate(worldIn, rand, blockpos2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class BiomeDesert extends GenBiome
|
||||||
{
|
{
|
||||||
int i = rand.chOffset();
|
int i = rand.chOffset();
|
||||||
int j = rand.chOffset();
|
int j = rand.chOffset();
|
||||||
BlockPos blockpos = worldIn.getHeight(pos.add(i, 0, j)).up();
|
BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(i, 0, j)).up();
|
||||||
(new WorldGenDesertWells()).generate(worldIn, rand, blockpos);
|
(new WorldGenDesertWells()).generate(worldIn, rand, blockpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class BiomeForest extends GenBiome
|
||||||
{
|
{
|
||||||
int k = i * 4 + rand.range(9, 11);
|
int k = i * 4 + rand.range(9, 11);
|
||||||
int l = j * 4 + rand.range(9, 11);
|
int l = j * 4 + rand.range(9, 11);
|
||||||
BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));
|
BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(k, 0, l));
|
||||||
|
|
||||||
if (rand.chance(20))
|
if (rand.chance(20))
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ public class BiomeForest extends GenBiome
|
||||||
{
|
{
|
||||||
int j2 = rand.chOffset();
|
int j2 = rand.chOffset();
|
||||||
int k2 = rand.chOffset();
|
int k2 = rand.chOffset();
|
||||||
int i1 = rand.zrange(worldIn.getHeight(pos.add(j2, 0, k2)).getY() + 32);
|
int i1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j2, 0, k2)).getY() + 32);
|
||||||
|
|
||||||
if (DOUBLE_PLANT_GEN.generate(worldIn, rand, new BlockPos(pos.getX() + j2, i1, pos.getZ() + k2)))
|
if (DOUBLE_PLANT_GEN.generate(worldIn, rand, new BlockPos(pos.getX() + j2, i1, pos.getZ() + k2)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class BiomeJungle extends GenBiome
|
||||||
super.decorate(worldIn, rand, pos);
|
super.decorate(worldIn, rand, pos);
|
||||||
int i = rand.chOffset();
|
int i = rand.chOffset();
|
||||||
int j = rand.chOffset();
|
int j = rand.chOffset();
|
||||||
int k = rand.zrange(worldIn.getHeight(pos.add(i, 0, j)).getY() * 2);
|
int k = rand.zrange(worldIn.getPrecipitationHeight(pos.add(i, 0, j)).getY() * 2);
|
||||||
(new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j));
|
(new WorldGenMelon()).generate(worldIn, rand, pos.add(i, k, j));
|
||||||
WorldGenVines worldgenvines = new WorldGenVines();
|
WorldGenVines worldgenvines = new WorldGenVines();
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class BiomePlains extends GenBiome
|
||||||
{
|
{
|
||||||
int j = rand.chOffset();
|
int j = rand.chOffset();
|
||||||
int k = rand.chOffset();
|
int k = rand.chOffset();
|
||||||
int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32);
|
int l = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j, 0, k)).getY() + 32);
|
||||||
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k));
|
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public class BiomePlains extends GenBiome
|
||||||
// {
|
// {
|
||||||
int j1 = rand.chOffset();
|
int j1 = rand.chOffset();
|
||||||
int k1 = rand.chOffset();
|
int k1 = rand.chOffset();
|
||||||
int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32);
|
int l1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j1, 0, k1)).getY() + 32);
|
||||||
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
|
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class BiomeSavanna extends GenBiome
|
||||||
{
|
{
|
||||||
int j = rand.chOffset();
|
int j = rand.chOffset();
|
||||||
int k = rand.chOffset();
|
int k = rand.chOffset();
|
||||||
int l = rand.zrange(worldIn.getHeight(pos.add(j, 0, k)).getY() + 32);
|
int l = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j, 0, k)).getY() + 32);
|
||||||
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k));
|
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j, l, k));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,14 @@ public class BiomeSnow extends GenBiome
|
||||||
{
|
{
|
||||||
int j = rand.chOffset();
|
int j = rand.chOffset();
|
||||||
int k = rand.chOffset();
|
int k = rand.chOffset();
|
||||||
this.spikeGen.generate(worldIn, rand, worldIn.getHeight(pos.add(j, 0, k)));
|
this.spikeGen.generate(worldIn, rand, worldIn.getPrecipitationHeight(pos.add(j, 0, k)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int l = 0; l < 2; ++l)
|
for (int l = 0; l < 2; ++l)
|
||||||
{
|
{
|
||||||
int i1 = rand.chOffset();
|
int i1 = rand.chOffset();
|
||||||
int j1 = rand.chOffset();
|
int j1 = rand.chOffset();
|
||||||
this.pathGen.generate(worldIn, rand, worldIn.getHeight(pos.add(i1, 0, j1)));
|
this.pathGen.generate(worldIn, rand, worldIn.getPrecipitationHeight(pos.add(i1, 0, j1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class BiomeTaiga extends GenBiome
|
||||||
{
|
{
|
||||||
int k = rand.chOffset();
|
int k = rand.chOffset();
|
||||||
int l = rand.chOffset();
|
int l = rand.chOffset();
|
||||||
BlockPos blockpos = worldIn.getHeight(pos.add(k, 0, l));
|
BlockPos blockpos = worldIn.getPrecipitationHeight(pos.add(k, 0, l));
|
||||||
field_150643_aG.generate(worldIn, rand, blockpos);
|
field_150643_aG.generate(worldIn, rand, blockpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ public class BiomeTaiga extends GenBiome
|
||||||
{
|
{
|
||||||
int j1 = rand.chOffset();
|
int j1 = rand.chOffset();
|
||||||
int k1 = rand.chOffset();
|
int k1 = rand.chOffset();
|
||||||
int l1 = rand.zrange(worldIn.getHeight(pos.add(j1, 0, k1)).getY() + 32);
|
int l1 = rand.zrange(worldIn.getPrecipitationHeight(pos.add(j1, 0, k1)).getY() + 32);
|
||||||
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
|
DOUBLE_PLANT_GEN.generate(worldIn, rand, pos.add(j1, l1, k1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class BiomeTian extends GenBiome
|
||||||
{
|
{
|
||||||
int i8 = rand.chOffset();
|
int i8 = rand.chOffset();
|
||||||
int l11 = rand.chOffset();
|
int l11 = rand.chOffset();
|
||||||
BlockPos blockpos2 = worldIn.getHeight(pos.add(i8, 0, l11));
|
BlockPos blockpos2 = worldIn.getPrecipitationHeight(pos.add(i8, 0, l11));
|
||||||
this.mushroomBlueGen.generate(worldIn, rand, blockpos2);
|
this.mushroomBlueGen.generate(worldIn, rand, blockpos2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,7 +340,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
int l = rand.chOffset();
|
int l = rand.chOffset();
|
||||||
WorldGenTree treeGen = this.genBigTreeChance(rand);
|
WorldGenTree treeGen = this.genBigTreeChance(rand);
|
||||||
treeGen.prepare();
|
treeGen.prepare();
|
||||||
BlockPos blockpos = world.getHeight(pos.add(k6, 0, l));
|
BlockPos blockpos = world.getPrecipitationHeight(pos.add(k6, 0, l));
|
||||||
|
|
||||||
if (treeGen.generate(world, rand, blockpos))
|
if (treeGen.generate(world, rand, blockpos))
|
||||||
{
|
{
|
||||||
|
@ -352,14 +352,14 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int l6 = rand.chOffset();
|
int l6 = rand.chOffset();
|
||||||
int k10 = rand.chOffset();
|
int k10 = rand.chOffset();
|
||||||
this.bigMushroomGen.generate(world, rand, world.getHeight(pos.add(l6, 0, k10)));
|
this.bigMushroomGen.generate(world, rand, world.getPrecipitationHeight(pos.add(l6, 0, k10)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int l2 = 0; l2 < this.flowersPerChunk; ++l2)
|
for (int l2 = 0; l2 < this.flowersPerChunk; ++l2)
|
||||||
{
|
{
|
||||||
int i7 = rand.chOffset();
|
int i7 = rand.chOffset();
|
||||||
int l10 = rand.chOffset();
|
int l10 = rand.chOffset();
|
||||||
int j14 = world.getHeight(pos.add(i7, 0, l10)).getY() + 32;
|
int j14 = world.getPrecipitationHeight(pos.add(i7, 0, l10)).getY() + 32;
|
||||||
|
|
||||||
if (j14 > 0)
|
if (j14 > 0)
|
||||||
{
|
{
|
||||||
|
@ -380,7 +380,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int j7 = rand.chOffset();
|
int j7 = rand.chOffset();
|
||||||
int i11 = rand.chOffset();
|
int i11 = rand.chOffset();
|
||||||
int k14 = world.getHeight(pos.add(j7, 0, i11)).getY() * 2;
|
int k14 = world.getPrecipitationHeight(pos.add(j7, 0, i11)).getY() * 2;
|
||||||
|
|
||||||
if (k14 > 0)
|
if (k14 > 0)
|
||||||
{
|
{
|
||||||
|
@ -393,7 +393,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int k7 = rand.chOffset();
|
int k7 = rand.chOffset();
|
||||||
int j11 = rand.chOffset();
|
int j11 = rand.chOffset();
|
||||||
int l14 = world.getHeight(pos.add(k7, 0, j11)).getY() * 2;
|
int l14 = world.getPrecipitationHeight(pos.add(k7, 0, j11)).getY() * 2;
|
||||||
|
|
||||||
if (l14 > 0)
|
if (l14 > 0)
|
||||||
{
|
{
|
||||||
|
@ -406,7 +406,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int l7 = rand.chOffset();
|
int l7 = rand.chOffset();
|
||||||
int k11 = rand.chOffset();
|
int k11 = rand.chOffset();
|
||||||
int i15 = world.getHeight(pos.add(l7, 0, k11)).getY() * 2;
|
int i15 = world.getPrecipitationHeight(pos.add(l7, 0, k11)).getY() * 2;
|
||||||
|
|
||||||
if (i15 > 0)
|
if (i15 > 0)
|
||||||
{
|
{
|
||||||
|
@ -434,7 +434,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int i8 = rand.chOffset();
|
int i8 = rand.chOffset();
|
||||||
int l11 = rand.chOffset();
|
int l11 = rand.chOffset();
|
||||||
BlockPos blockpos2 = world.getHeight(pos.add(i8, 0, l11));
|
BlockPos blockpos2 = world.getPrecipitationHeight(pos.add(i8, 0, l11));
|
||||||
this.mushroomBrownGen.generate(world, rand, blockpos2);
|
this.mushroomBrownGen.generate(world, rand, blockpos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int j8 = rand.chOffset();
|
int j8 = rand.chOffset();
|
||||||
int i12 = rand.chOffset();
|
int i12 = rand.chOffset();
|
||||||
int j15 = world.getHeight(pos.add(j8, 0, i12)).getY() * 2;
|
int j15 = world.getPrecipitationHeight(pos.add(j8, 0, i12)).getY() * 2;
|
||||||
|
|
||||||
if (j15 > 0)
|
if (j15 > 0)
|
||||||
{
|
{
|
||||||
|
@ -457,7 +457,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int i4 = rand.chOffset();
|
int i4 = rand.chOffset();
|
||||||
int k8 = rand.chOffset();
|
int k8 = rand.chOffset();
|
||||||
int j12 = world.getHeight(pos.add(i4, 0, k8)).getY() * 2;
|
int j12 = world.getPrecipitationHeight(pos.add(i4, 0, k8)).getY() * 2;
|
||||||
|
|
||||||
if (j12 > 0)
|
if (j12 > 0)
|
||||||
{
|
{
|
||||||
|
@ -470,7 +470,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int j4 = rand.chOffset();
|
int j4 = rand.chOffset();
|
||||||
int l8 = rand.chOffset();
|
int l8 = rand.chOffset();
|
||||||
int k12 = world.getHeight(pos.add(j4, 0, l8)).getY() * 2;
|
int k12 = world.getPrecipitationHeight(pos.add(j4, 0, l8)).getY() * 2;
|
||||||
|
|
||||||
if (k12 > 0)
|
if (k12 > 0)
|
||||||
{
|
{
|
||||||
|
@ -483,7 +483,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int i9 = rand.chOffset();
|
int i9 = rand.chOffset();
|
||||||
int l12 = rand.chOffset();
|
int l12 = rand.chOffset();
|
||||||
int i16 = world.getHeight(pos.add(i9, 0, l12)).getY() * 2;
|
int i16 = world.getPrecipitationHeight(pos.add(i9, 0, l12)).getY() * 2;
|
||||||
|
|
||||||
if (i16 > 0)
|
if (i16 > 0)
|
||||||
{
|
{
|
||||||
|
@ -496,7 +496,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int j9 = rand.chOffset();
|
int j9 = rand.chOffset();
|
||||||
int i13 = rand.chOffset();
|
int i13 = rand.chOffset();
|
||||||
int j16 = world.getHeight(pos.add(j9, 0, i13)).getY() * 2;
|
int j16 = world.getPrecipitationHeight(pos.add(j9, 0, i13)).getY() * 2;
|
||||||
|
|
||||||
if (j16 > 0)
|
if (j16 > 0)
|
||||||
{
|
{
|
||||||
|
@ -509,7 +509,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int i5 = rand.chOffset();
|
int i5 = rand.chOffset();
|
||||||
int k9 = rand.chOffset();
|
int k9 = rand.chOffset();
|
||||||
int j13 = world.getHeight(pos.add(i5, 0, k9)).getY() * 2;
|
int j13 = world.getPrecipitationHeight(pos.add(i5, 0, k9)).getY() * 2;
|
||||||
|
|
||||||
if (j13 > 0)
|
if (j13 > 0)
|
||||||
{
|
{
|
||||||
|
@ -522,7 +522,7 @@ public abstract class GenBiome implements IBiome {
|
||||||
{
|
{
|
||||||
int l9 = rand.chOffset();
|
int l9 = rand.chOffset();
|
||||||
int k13 = rand.chOffset();
|
int k13 = rand.chOffset();
|
||||||
int l16 = world.getHeight(pos.add(l9, 0, k13)).getY() * 2;
|
int l16 = world.getPrecipitationHeight(pos.add(l9, 0, k13)).getY() * 2;
|
||||||
|
|
||||||
if (l16 > 0)
|
if (l16 > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -254,7 +254,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
|
||||||
this.sendPacket(new SPacketKeepAlive(this.pingKey));
|
this.sendPacket(new SPacketKeepAlive(this.pingKey));
|
||||||
}
|
}
|
||||||
if(this.admin && this.profiling)
|
if(this.admin && this.profiling)
|
||||||
this.sendPacket(new SPacketServerTick((int)this.server.getLastTick()));
|
this.sendPacket(new SPacketServerTick((int)this.server.getLastTick(), this.getTickInfo()));
|
||||||
if(this.respawnTimer > 0) {
|
if(this.respawnTimer > 0) {
|
||||||
if(--this.respawnTimer == 0) {
|
if(--this.respawnTimer == 0) {
|
||||||
this.respawnPlayer();
|
this.respawnPlayer();
|
||||||
|
@ -262,6 +262,18 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getTickInfo() {
|
||||||
|
if(this.charEditor || this.entity == null)
|
||||||
|
return "";
|
||||||
|
WorldServer world = this.getEntityWorld();
|
||||||
|
BlockPos pos = this.entity.getPosition();
|
||||||
|
return String.format("Temperatur: %.2f K / %.2f °C, L: %s%s",
|
||||||
|
world.getTemperatureK(pos), world.getTemperatureC(pos),
|
||||||
|
!world.dimension.getType().days ? "*" : "",
|
||||||
|
world.getLeavesGen(pos).getDisplayName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public void displayLoading(String message) {
|
public void displayLoading(String message) {
|
||||||
this.sendPacket(new SPacketLoading(message));
|
this.sendPacket(new SPacketLoading(message));
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,15 +215,16 @@ public class VillageCollection
|
||||||
|
|
||||||
for (int j = 1; j <= 5; ++j)
|
for (int j = 1; j <= 5; ++j)
|
||||||
{
|
{
|
||||||
if (world.canSeeSky(centerPos.offset(direction, j)))
|
BlockPos pos = centerPos.offset(direction, j);
|
||||||
{
|
for(int z = 0; z < 5; z++) {
|
||||||
++i;
|
if(!world.isAirBlock(pos.up(z)))
|
||||||
|
break;
|
||||||
if (i >= limitation)
|
if(z == 4) {
|
||||||
{
|
++i;
|
||||||
return i;
|
if(i >= limitation)
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -370,19 +370,16 @@ public class Region {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Chunk chunk = new Chunk(world, x, z);
|
Chunk chunk = new Chunk(world, x, z);
|
||||||
chunk.setHeights(tag.getIntArray("HeightMap"));
|
|
||||||
chunk.setTerrainPopulated(tag.getBoolean("TerrainPopulated"));
|
chunk.setTerrainPopulated(tag.getBoolean("TerrainPopulated"));
|
||||||
chunk.setLightPopulated(tag.getBoolean("LightPopulated"));
|
|
||||||
chunk.setInhabited(tag.getLong("InhabitedTime"));
|
chunk.setInhabited(tag.getLong("InhabitedTime"));
|
||||||
NBTTagList sects = tag.getTagList("Sections", 10);
|
NBTTagList sects = tag.getTagList("Sections", 10);
|
||||||
int stor = 32;
|
int stor = 32;
|
||||||
BlockArray[] sections = new BlockArray[stor];
|
BlockArray[] sections = new BlockArray[stor];
|
||||||
boolean light = !world.dimension.hasNoLight();
|
|
||||||
|
|
||||||
for(int n = 0; n < sects.tagCount(); ++n) {
|
for(int n = 0; n < sects.tagCount(); ++n) {
|
||||||
NBTTagCompound sect = sects.getCompoundTagAt(n);
|
NBTTagCompound sect = sects.getCompoundTagAt(n);
|
||||||
int y = sect.getByte("Y");
|
int y = sect.getByte("Y");
|
||||||
BlockArray storage = new BlockArray(y << 4, light);
|
BlockArray storage = new BlockArray(y << 4);
|
||||||
byte[] blocks = sect.getByteArray("Blocks");
|
byte[] blocks = sect.getByteArray("Blocks");
|
||||||
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
|
||||||
NibbleArray adddata = sect.hasKey("Add", 7) ? new NibbleArray(sect.getByteArray("Add")) : null;
|
NibbleArray adddata = sect.hasKey("Add", 7) ? new NibbleArray(sect.getByteArray("Add")) : null;
|
||||||
|
@ -398,21 +395,13 @@ public class Region {
|
||||||
|
|
||||||
storage.setData(seg);
|
storage.setData(seg);
|
||||||
storage.setBlocklight(new NibbleArray(sect.getByteArray("BlockLight")));
|
storage.setBlocklight(new NibbleArray(sect.getByteArray("BlockLight")));
|
||||||
|
|
||||||
if(light) {
|
|
||||||
storage.setSkylight(new NibbleArray(sect.getByteArray("SkyLight")));
|
|
||||||
}
|
|
||||||
|
|
||||||
storage.update();
|
storage.update();
|
||||||
sections[y] = storage;
|
sections[y] = storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
chunk.setStorage(sections);
|
chunk.setStorage(sections);
|
||||||
|
|
||||||
if(tag.hasKey("Biomes", 7)) {
|
|
||||||
chunk.setBiomes(tag.getByteArray("Biomes"));
|
|
||||||
}
|
|
||||||
|
|
||||||
NBTTagList entities = tag.getTagList("Entities", 10);
|
NBTTagList entities = tag.getTagList("Entities", 10);
|
||||||
|
|
||||||
if(entities != null) {
|
if(entities != null) {
|
||||||
|
@ -490,9 +479,7 @@ public class Region {
|
||||||
NBTTagCompound tag = new NBTTagCompound();
|
NBTTagCompound tag = new NBTTagCompound();
|
||||||
// tag.setShort("V", (short)Config.PROTOCOL);
|
// tag.setShort("V", (short)Config.PROTOCOL);
|
||||||
tag.setLong("LastUpdate", world.getTime());
|
tag.setLong("LastUpdate", world.getTime());
|
||||||
tag.setIntArray("HeightMap", chunk.getHeights());
|
|
||||||
tag.setBoolean("TerrainPopulated", chunk.isTerrainPopulated());
|
tag.setBoolean("TerrainPopulated", chunk.isTerrainPopulated());
|
||||||
tag.setBoolean("LightPopulated", chunk.isLightPopulated());
|
|
||||||
tag.setLong("InhabitedTime", chunk.getInhabited());
|
tag.setLong("InhabitedTime", chunk.getInhabited());
|
||||||
BlockArray[] sections = chunk.getStorage();
|
BlockArray[] sections = chunk.getStorage();
|
||||||
NBTTagList sects = new NBTTagList();
|
NBTTagList sects = new NBTTagList();
|
||||||
|
@ -532,20 +519,12 @@ public class Region {
|
||||||
}
|
}
|
||||||
|
|
||||||
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
|
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
|
||||||
|
|
||||||
if(light) {
|
|
||||||
sect.setByteArray("SkyLight", storage.getSkylight().getData());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sect.setByteArray("SkyLight", new byte[storage.getBlocklight().getData().length]);
|
|
||||||
}
|
|
||||||
|
|
||||||
sects.appendTag(sect);
|
sects.appendTag(sect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.setTag("Sections", sects);
|
tag.setTag("Sections", sects);
|
||||||
tag.setByteArray("Biomes", chunk.getBiomes());
|
|
||||||
chunk.setHasEntities(false);
|
chunk.setHasEntities(false);
|
||||||
NBTTagList entities = new NBTTagList();
|
NBTTagList entities = new NBTTagList();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import common.rng.WeightedList;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ChunkPos;
|
import common.util.ChunkPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.world.Chunk;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import server.biome.GenBiome;
|
import server.biome.GenBiome;
|
||||||
import server.biome.RngSpawn;
|
import server.biome.RngSpawn;
|
||||||
|
@ -87,15 +86,14 @@ public abstract class Spawner {
|
||||||
if(cur <= max) {
|
if(cur <= max) {
|
||||||
typeLabel:
|
typeLabel:
|
||||||
for(ChunkPos coord : CHUNKS) {
|
for(ChunkPos coord : CHUNKS) {
|
||||||
Chunk chunk = world.getChunk(coord.x, coord.z);
|
|
||||||
int x = coord.x * 16 + world.rand.zrange(16);
|
int x = coord.x * 16 + world.rand.zrange(16);
|
||||||
int z = coord.z * 16 + world.rand.zrange(16);
|
int z = coord.z * 16 + world.rand.zrange(16);
|
||||||
int h = chunk.getHeight(new BlockPos(x, 0, z)) + 1;
|
int h = world.getPrecipitationHeight(new BlockPos(x, 0, z)).getY() + 1;
|
||||||
if(h > 0) {
|
if(h > 0) {
|
||||||
int m = h % 16;
|
int m = h % 16;
|
||||||
h = m == 0 ? h : h + 16 - m;
|
h = m == 0 ? h : h + 16 - m;
|
||||||
}
|
}
|
||||||
h = h == 0 ? 16 : (h > 0 ? h : chunk.getTopSegment() + 16 - 1);
|
h = h <= 0 ? 16 : h;
|
||||||
int y = world.rand.excl(h <= 8 ? 0 : 8, h);
|
int y = world.rand.excl(h <= 8 ? 0 : 8, h);
|
||||||
BlockPos pos = new BlockPos(x, y, z);
|
BlockPos pos = new BlockPos(x, y, z);
|
||||||
Block block = world.getState(pos).getBlock();
|
Block block = world.getState(pos).getBlock();
|
||||||
|
|
|
@ -20,6 +20,7 @@ import common.block.BlockEventData;
|
||||||
import common.block.BlockFalling;
|
import common.block.BlockFalling;
|
||||||
import common.block.BlockLiquid;
|
import common.block.BlockLiquid;
|
||||||
import common.block.BlockSnow;
|
import common.block.BlockSnow;
|
||||||
|
import common.block.LeavesType;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
import common.collect.Maps;
|
import common.collect.Maps;
|
||||||
import common.collect.Sets;
|
import common.collect.Sets;
|
||||||
|
@ -51,7 +52,6 @@ import common.packet.S29PacketSoundEffect;
|
||||||
import common.packet.S2APacketParticles;
|
import common.packet.S2APacketParticles;
|
||||||
import common.packet.S2BPacketChangeGameState;
|
import common.packet.S2BPacketChangeGameState;
|
||||||
import common.packet.S2CPacketSpawnGlobalEntity;
|
import common.packet.S2CPacketSpawnGlobalEntity;
|
||||||
import common.packet.SPacketBiomes;
|
|
||||||
import common.packet.SPacketBlockAction;
|
import common.packet.SPacketBlockAction;
|
||||||
import common.packet.SPacketBlockBreakAnim;
|
import common.packet.SPacketBlockBreakAnim;
|
||||||
import common.packet.SPacketBlockChange;
|
import common.packet.SPacketBlockChange;
|
||||||
|
@ -66,7 +66,6 @@ import common.util.ChunkPos;
|
||||||
import common.util.ExtMath;
|
import common.util.ExtMath;
|
||||||
import common.util.FileUtils;
|
import common.util.FileUtils;
|
||||||
import common.util.IntHashMap;
|
import common.util.IntHashMap;
|
||||||
import common.util.LongHashMap;
|
|
||||||
import common.util.NextTickListEntry;
|
import common.util.NextTickListEntry;
|
||||||
import common.util.PortalType;
|
import common.util.PortalType;
|
||||||
import common.util.Position;
|
import common.util.Position;
|
||||||
|
@ -76,11 +75,9 @@ import common.world.BlockArray;
|
||||||
import common.world.Chunk;
|
import common.world.Chunk;
|
||||||
import common.world.Explosion;
|
import common.world.Explosion;
|
||||||
import common.world.AWorldServer;
|
import common.world.AWorldServer;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.world.Weather;
|
import common.world.Weather;
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import common.worldgen.BiomeGenerator;
|
|
||||||
import common.worldgen.FeatureLake;
|
import common.worldgen.FeatureLake;
|
||||||
import common.worldgen.FeatureLiquid;
|
import common.worldgen.FeatureLiquid;
|
||||||
import common.worldgen.FeatureOre;
|
import common.worldgen.FeatureOre;
|
||||||
|
@ -93,6 +90,7 @@ import server.village.VillageCollection;
|
||||||
import server.worldgen.BiomeGenLayered;
|
import server.worldgen.BiomeGenLayered;
|
||||||
import server.worldgen.BiomeGenPerlin;
|
import server.worldgen.BiomeGenPerlin;
|
||||||
import server.worldgen.BiomeGenSingle;
|
import server.worldgen.BiomeGenSingle;
|
||||||
|
import server.worldgen.BiomeGenerator;
|
||||||
import server.worldgen.BlockReplacer;
|
import server.worldgen.BlockReplacer;
|
||||||
import server.worldgen.ChunkGenerator;
|
import server.worldgen.ChunkGenerator;
|
||||||
import server.worldgen.ChunkPrimer;
|
import server.worldgen.ChunkPrimer;
|
||||||
|
@ -131,15 +129,15 @@ public final class WorldServer extends AWorldServer {
|
||||||
private final TreeSet<NextTickListEntry> ticksNext = new TreeSet();
|
private final TreeSet<NextTickListEntry> ticksNext = new TreeSet();
|
||||||
private final EventList[] queue = new EventList[] {new EventList(), new EventList()};
|
private final EventList[] queue = new EventList[] {new EventList(), new EventList()};
|
||||||
private final List<NextTickListEntry> ticksNow = Lists.<NextTickListEntry>newArrayList();
|
private final List<NextTickListEntry> ticksNow = Lists.<NextTickListEntry>newArrayList();
|
||||||
private final Set<Long> dropped = Collections.<Long>newSetFromMap(new ConcurrentHashMap());
|
private final Set<ChunkPos> dropped = Collections.<ChunkPos>newSetFromMap(new ConcurrentHashMap());
|
||||||
private final LongHashMap<Chunk> chunks = new LongHashMap();
|
private final Map<ChunkPos, Chunk> chunks = Maps.newHashMap();
|
||||||
private final List<Chunk> loaded = Lists.<Chunk>newArrayList();
|
private final List<Chunk> loaded = Lists.<Chunk>newArrayList();
|
||||||
private final Map<ChunkPos, NBTTagCompound> toRemove = new ConcurrentHashMap();
|
private final Map<ChunkPos, NBTTagCompound> toRemove = new ConcurrentHashMap();
|
||||||
private final Set<ChunkPos> pending = Collections.<ChunkPos>newSetFromMap(new ConcurrentHashMap());
|
private final Set<ChunkPos> pending = Collections.<ChunkPos>newSetFromMap(new ConcurrentHashMap());
|
||||||
private final LongHashMap<BlockPos> loaders = new LongHashMap();
|
private final Map<ChunkPos, BlockPos> loaders = Maps.newHashMap();
|
||||||
private final Set<BlockPos> loaderList = Sets.<BlockPos>newHashSet();
|
private final Set<BlockPos> loaderList = Sets.<BlockPos>newHashSet();
|
||||||
private final List<EntityNPC> managed = Lists.<EntityNPC>newArrayList();
|
private final List<EntityNPC> managed = Lists.<EntityNPC>newArrayList();
|
||||||
private final LongHashMap<PlayerInstance> instances = new LongHashMap();
|
private final Map<ChunkPos, PlayerInstance> instances = Maps.newHashMap();
|
||||||
private final List<PlayerInstance> toUpdate = Lists.<PlayerInstance>newArrayList();
|
private final List<PlayerInstance> toUpdate = Lists.<PlayerInstance>newArrayList();
|
||||||
private final List<PlayerInstance> instList = Lists.<PlayerInstance>newArrayList();
|
private final List<PlayerInstance> instList = Lists.<PlayerInstance>newArrayList();
|
||||||
private final Set<EntityTrackerEntry> tracked = Sets.<EntityTrackerEntry>newHashSet();
|
private final Set<EntityTrackerEntry> tracked = Sets.<EntityTrackerEntry>newHashSet();
|
||||||
|
@ -179,6 +177,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
private boolean loadersModified;
|
private boolean loadersModified;
|
||||||
// private boolean warpsModified;
|
// private boolean warpsModified;
|
||||||
private boolean exterminated;
|
private boolean exterminated;
|
||||||
|
private float temp;
|
||||||
private int emptyTicks;
|
private int emptyTicks;
|
||||||
private int blockEvtIdx;
|
private int blockEvtIdx;
|
||||||
private int trackDistance;
|
private int trackDistance;
|
||||||
|
@ -513,12 +512,12 @@ public final class WorldServer extends AWorldServer {
|
||||||
if(!this.debug) {
|
if(!this.debug) {
|
||||||
for(int i = 0; i < 100; ++i) {
|
for(int i = 0; i < 100; ++i) {
|
||||||
if(!this.dropped.isEmpty()) {
|
if(!this.dropped.isEmpty()) {
|
||||||
Long v = (Long)this.dropped.iterator().next();
|
ChunkPos v = this.dropped.iterator().next();
|
||||||
Chunk chunk = (Chunk)this.chunks.getValueByKey(v.longValue());
|
Chunk chunk = this.chunks.get(v);
|
||||||
if(chunk != null) {
|
if(chunk != null) {
|
||||||
chunk.onChunkUnload();
|
chunk.onChunkUnload();
|
||||||
this.saveChunkData(chunk);
|
this.saveChunkData(chunk);
|
||||||
this.chunks.remove(v.longValue());
|
this.chunks.remove(v);
|
||||||
this.loaded.remove(chunk);
|
this.loaded.remove(chunk);
|
||||||
}
|
}
|
||||||
this.dropped.remove(v);
|
this.dropped.remove(v);
|
||||||
|
@ -571,10 +570,10 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addLoader(BlockPos pos) {
|
public boolean addLoader(BlockPos pos) {
|
||||||
long chunk = LongHashMap.packInt(pos.getX() / 16, pos.getZ() / 16);
|
ChunkPos chunk = new ChunkPos(pos.getX() / 16, pos.getZ() / 16);
|
||||||
if(this.loaders.containsItem(chunk))
|
if(this.loaders.containsKey(chunk))
|
||||||
return false;
|
return false;
|
||||||
this.loaders.add(chunk, pos);
|
this.loaders.put(chunk, pos);
|
||||||
this.loaderList.add(pos);
|
this.loaderList.add(pos);
|
||||||
this.loadersModified = true;
|
this.loadersModified = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -585,8 +584,8 @@ public final class WorldServer extends AWorldServer {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public boolean removeLoader(BlockPos pos) {
|
public boolean removeLoader(BlockPos pos) {
|
||||||
long chunk = LongHashMap.packInt(pos.getX() / 16, pos.getZ() / 16);
|
ChunkPos chunk = new ChunkPos(pos.getX() / 16, pos.getZ() / 16);
|
||||||
BlockPos loader = this.loaders.getValueByKey(chunk);
|
BlockPos loader = this.loaders.get(chunk);
|
||||||
if(!pos.equals(loader))
|
if(!pos.equals(loader))
|
||||||
return false;
|
return false;
|
||||||
this.loaders.remove(chunk);
|
this.loaders.remove(chunk);
|
||||||
|
@ -623,11 +622,84 @@ public final class WorldServer extends AWorldServer {
|
||||||
return this.biomeGen;
|
return this.biomeGen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getBiomeGenForCoords(final BlockPos pos) {
|
public Biome getBiomeGenForCoords(BlockPos pos) {
|
||||||
if(this.isBlockLoaded(pos))
|
return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
||||||
return this.getChunk(pos).getBiome(pos, this.biomeGen);
|
}
|
||||||
else
|
|
||||||
return this.biomeGen.getBiomeGenerator(pos, Biome.DEF_BIOME);
|
protected void calculateInitialWeather() {
|
||||||
|
super.calculateInitialWeather();
|
||||||
|
this.temp = this.getBaseTemperature() + this.weather.getTemperature();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTempOffset() {
|
||||||
|
return this.temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected float getBaseTemperature() {
|
||||||
|
return this.dimension.getTemperature() + this.dimension.getOrbitOffset() *
|
||||||
|
ExtMath.sin((((float)(this.daytime % this.dimension.getOrbitalPeriod()) / (float)this.dimension.getOrbitalPeriod())
|
||||||
|
-0.125f) * (float)Math.PI * 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LeavesType getLeavesGen(BlockPos pos) {
|
||||||
|
return this.canFreezeAt(pos) ? LeavesType.SNOWY : ((!this.dimension.getType().days || this.dimension.getOrbitOffset() == 0.0f) ?
|
||||||
|
this.dimension.getLeavesType() : LeavesType.values()[(int)((this.daytime %
|
||||||
|
this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTemperatureK(BlockPos pos) {
|
||||||
|
return this.temp + this.getBiomeGenForCoords(pos).getTemperature(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getTemperatureC(BlockPos pos) {
|
||||||
|
return World.ABSOLUTE_ZERO + this.getTemperatureK(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canFreezeAt(BlockPos pos) {
|
||||||
|
return this.getTemperatureC(pos) <= 0.0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canBurnAt(BlockPos pos) {
|
||||||
|
return this.getTemperatureC(pos) >= 194.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doesWaterVaporize(BlockPos pos) {
|
||||||
|
return this.getTemperatureC(pos) >= 100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLavaFaster(BlockPos pos) {
|
||||||
|
return this.getTemperatureC(pos) >= 314.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canSnowAt(BlockPos pos, boolean checkLight, boolean allowLayers) {
|
||||||
|
if(!this.canFreezeAt(pos)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(!checkLight) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(pos) < 10) {
|
||||||
|
Block block = this.getState(pos).getBlock();
|
||||||
|
|
||||||
|
if((block.getMaterial() == Material.air || (allowLayers && block == Blocks.snow_layer))
|
||||||
|
&& Blocks.snow_layer.canPlaceBlockAt(this, pos)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRainingAt(BlockPos strikePosition, boolean wet) {
|
||||||
|
if(wet ? !this.isRaining() : !this.hasDownfall()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if(this.getPrecipitationHeight(strikePosition, strikePosition.getY() + 46, 48).getY() > strikePosition.getY()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !this.canSnowAt(strikePosition, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
public void setItemData(String dataID, WorldSavedData worldSavedDataIn) {
|
||||||
|
@ -644,7 +716,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
|
|
||||||
if(this.debug) {
|
if(this.debug) {
|
||||||
for(ChunkPos chunkcoordintpair1 : this.active) {
|
for(ChunkPos chunkcoordintpair1 : this.active) {
|
||||||
this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update(false);
|
this.getChunk(chunkcoordintpair1.x, chunkcoordintpair1.z).update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -661,7 +733,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
// this.profiler.next("checkLight");
|
// this.profiler.next("checkLight");
|
||||||
chunk.enqueueRelight();
|
chunk.enqueueRelight();
|
||||||
// this.profiler.next("tickChunk");
|
// this.profiler.next("tickChunk");
|
||||||
chunk.update(false);
|
chunk.update();
|
||||||
// this.profiler.next("thunder");
|
// this.profiler.next("thunder");
|
||||||
int l2 = Config.boltChance;
|
int l2 = Config.boltChance;
|
||||||
|
|
||||||
|
@ -745,7 +817,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
3.0D, 3.0D);
|
3.0D, 3.0D);
|
||||||
List<EntityLiving> list = this.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate<EntityLiving>() {
|
List<EntityLiving> list = this.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb, new Predicate<EntityLiving>() {
|
||||||
public boolean test(EntityLiving p_apply_1_) {
|
public boolean test(EntityLiving p_apply_1_) {
|
||||||
return p_apply_1_ != null && p_apply_1_.isEntityAlive() && WorldServer.this.canSeeSky(p_apply_1_.getPosition());
|
return p_apply_1_ != null && p_apply_1_.isEntityAlive() && p_apply_1_.getPosition().getY() >= blockpos.getY();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return !list.isEmpty() ? ((EntityLiving)list.get(this.rand.zrange(list.size()))).getPosition() : blockpos;
|
return !list.isEmpty() ? ((EntityLiving)list.get(this.rand.zrange(list.size()))).getPosition() : blockpos;
|
||||||
|
@ -1289,10 +1361,6 @@ public final class WorldServer extends AWorldServer {
|
||||||
else if(this.temp > temp) {
|
else if(this.temp > temp) {
|
||||||
this.temp = Math.max((float)((double)this.temp - 0.01D), temp);
|
this.temp = Math.max((float)((double)this.temp - 0.01D), temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(prevTemp != this.temp || force) {
|
|
||||||
this.server.sendPacket(new S2BPacketChangeGameState(S2BPacketChangeGameState.Action.TEMPERATURE, this.temp), this.dimension.getDimensionId());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(this.resetWeather)
|
// if(this.resetWeather)
|
||||||
|
@ -1326,18 +1394,18 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk getChunk(int x, int z) {
|
public Chunk getChunk(int x, int z) {
|
||||||
Chunk chunk = this.chunks.getValueByKey(LongHashMap.packInt(x, z));
|
Chunk chunk = this.chunks.get(new ChunkPos(x, z));
|
||||||
return chunk == null ? this.loadChunk(x, z) : chunk;
|
return chunk == null ? this.loadChunk(x, z) : chunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean chunkExists(int x, int z) {
|
private boolean chunkExists(int x, int z) {
|
||||||
return this.chunks.containsItem(LongHashMap.packInt(x, z));
|
return this.chunks.containsKey(new ChunkPos(x, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dropChunk(int x, int z) {
|
public void dropChunk(int x, int z) {
|
||||||
long chunk = LongHashMap.packInt(x, z);
|
ChunkPos chunk = new ChunkPos(x, z);
|
||||||
if(!this.loaders.containsItem(chunk))
|
if(!this.loaders.containsKey(chunk))
|
||||||
this.dropped.add(Long.valueOf(chunk));
|
this.dropped.add(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadForcedChunks() {
|
public void loadForcedChunks() {
|
||||||
|
@ -1353,9 +1421,9 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk loadChunk(int x, int z) {
|
public Chunk loadChunk(int x, int z) {
|
||||||
long id = LongHashMap.packInt(x, z);
|
ChunkPos id = new ChunkPos(x, z);
|
||||||
this.dropped.remove(Long.valueOf(id));
|
this.dropped.remove(id);
|
||||||
Chunk chunk = (Chunk)this.chunks.getValueByKey(id);
|
Chunk chunk = this.chunks.get(id);
|
||||||
|
|
||||||
if(chunk == null) {
|
if(chunk == null) {
|
||||||
if(!this.debug)
|
if(!this.debug)
|
||||||
|
@ -1365,7 +1433,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
chunk = this.generate(x, z);
|
chunk = this.generate(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chunks.add(id, chunk);
|
this.chunks.put(id, chunk);
|
||||||
this.loaded.add(chunk);
|
this.loaded.add(chunk);
|
||||||
chunk.onChunkLoad();
|
chunk.onChunkLoad();
|
||||||
this.popChunk(x, z);
|
this.popChunk(x, z);
|
||||||
|
@ -1532,7 +1600,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
private void populate(int x, int z) {
|
private void populate(int x, int z) {
|
||||||
Chunk chunk = this.getChunk(x, z);
|
Chunk chunk = this.getChunk(x, z);
|
||||||
if(!chunk.isTerrainPopulated()) {
|
if(!chunk.isTerrainPopulated()) {
|
||||||
chunk.checkLight();
|
chunk.setTerrainPopulated(true);
|
||||||
BlockFalling.fallInstantly = true;
|
BlockFalling.fallInstantly = true;
|
||||||
int bx = x * 16;
|
int bx = x * 16;
|
||||||
int bz = z * 16;
|
int bz = z * 16;
|
||||||
|
@ -1635,7 +1703,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
if(this.scatteredGen != null) {
|
if(this.scatteredGen != null) {
|
||||||
this.scatteredGen.generate(this, x, z, primer);
|
this.scatteredGen.generate(this, x, z, primer);
|
||||||
}
|
}
|
||||||
return new Chunk(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, this.biomes, x, z);
|
return new Chunk(this, primer.getData(), primer.height, this.base, this.ceil, this.grng, x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExterminated() {
|
public boolean isExterminated() {
|
||||||
|
@ -1653,7 +1721,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
if(!this.loaderList.isEmpty())
|
if(!this.loaderList.isEmpty())
|
||||||
this.loadersModified = true;
|
this.loadersModified = true;
|
||||||
for(BlockPos pos : this.loaderList) {
|
for(BlockPos pos : this.loaderList) {
|
||||||
this.loaders.remove(LongHashMap.packInt(pos.getX() / 16, pos.getZ() / 16));
|
this.loaders.remove(new ChunkPos(pos.getX() / 16, pos.getZ() / 16));
|
||||||
}
|
}
|
||||||
this.loaderList.clear();
|
this.loaderList.clear();
|
||||||
for(Iterator<Entry<String, Position>> iter = this.server.getWarps().entrySet().iterator(); iter.hasNext();) {
|
for(Iterator<Entry<String, Position>> iter = this.server.getWarps().entrySet().iterator(); iter.hasNext();) {
|
||||||
|
@ -1669,11 +1737,11 @@ public final class WorldServer extends AWorldServer {
|
||||||
}));
|
}));
|
||||||
this.exterminated = true;
|
this.exterminated = true;
|
||||||
// this.dataModified = true;
|
// this.dataModified = true;
|
||||||
for(Long v : this.dropped) {
|
for(ChunkPos v : this.dropped) {
|
||||||
Chunk chunk = this.chunks.getValueByKey(v.longValue());
|
Chunk chunk = this.chunks.get(v);
|
||||||
if(chunk != null) {
|
if(chunk != null) {
|
||||||
chunk.onChunkUnload();
|
chunk.onChunkUnload();
|
||||||
this.chunks.remove(v.longValue());
|
this.chunks.remove(v);
|
||||||
this.loaded.remove(chunk);
|
this.loaded.remove(chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1682,18 +1750,18 @@ public final class WorldServer extends AWorldServer {
|
||||||
this.loaded.clear();
|
this.loaded.clear();
|
||||||
this.setExterminatedGen();
|
this.setExterminatedGen();
|
||||||
for(Chunk chunk : loaded) {
|
for(Chunk chunk : loaded) {
|
||||||
long pos = LongHashMap.packInt(chunk.xPos, chunk.zPos);
|
ChunkPos pos = new ChunkPos(chunk.xPos, chunk.zPos);
|
||||||
chunk.onChunkUnload();
|
chunk.onChunkUnload();
|
||||||
this.chunks.remove(pos);
|
this.chunks.remove(pos);
|
||||||
chunk = this.generate(chunk.xPos, chunk.zPos);
|
chunk = this.generate(chunk.xPos, chunk.zPos);
|
||||||
this.chunks.add(pos, chunk);
|
this.chunks.put(pos, chunk);
|
||||||
this.loaded.add(chunk);
|
this.loaded.add(chunk);
|
||||||
chunk.onChunkLoad();
|
chunk.onChunkLoad();
|
||||||
chunk.checkLight();
|
chunk.setTerrainPopulated(true);
|
||||||
chunk.setModified();
|
chunk.setModified();
|
||||||
}
|
}
|
||||||
for(Chunk chunk : this.loaded) {
|
for(Chunk chunk : this.loaded) {
|
||||||
chunk.update(false);
|
chunk.update();
|
||||||
}
|
}
|
||||||
this.entities.removeAll(this.unloaded);
|
this.entities.removeAll(this.unloaded);
|
||||||
for(int l = 0; l < this.unloaded.size(); ++l) {
|
for(int l = 0; l < this.unloaded.size(); ++l) {
|
||||||
|
@ -1765,7 +1833,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
Object[] worlds = server.getWorlds().toArray();
|
Object[] worlds = server.getWorlds().toArray();
|
||||||
for(Object obj : worlds) {
|
for(Object obj : worlds) {
|
||||||
WorldServer world = (WorldServer)obj;
|
WorldServer world = (WorldServer)obj;
|
||||||
chunks += world.chunks.getNumHashElements();
|
chunks += world.chunks.size();
|
||||||
entities += world.entities.size();
|
entities += world.entities.size();
|
||||||
tiles += world.tiles.size();
|
tiles += world.tiles.size();
|
||||||
ticked += world.tickable.size();
|
ticked += world.tickable.size();
|
||||||
|
@ -1865,28 +1933,17 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasPlayerInstance(int chunkX, int chunkZ) {
|
private boolean hasPlayerInstance(int chunkX, int chunkZ) {
|
||||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
ChunkPos v = new ChunkPos(chunkX, chunkZ);
|
||||||
return this.instances.getValueByKey(v) != null;
|
return this.instances.get(v) != null;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean updateBiomes(int chunkX, int chunkZ) {
|
|
||||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
|
||||||
PlayerInstance ins = this.instances.getValueByKey(v);
|
|
||||||
if(ins == null)
|
|
||||||
return false;
|
|
||||||
Chunk chunk = this.getChunk(chunkX, chunkZ);
|
|
||||||
chunk.setModified();
|
|
||||||
ins.sendToAllPlayersWatchingChunk(new SPacketBiomes(chunkX, chunkZ, chunk.getBiomes()));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerInstance getPlayerInstance(int chunkX, int chunkZ, boolean create) {
|
private PlayerInstance getPlayerInstance(int chunkX, int chunkZ, boolean create) {
|
||||||
long v = (long)chunkX + 2147483647L | (long)chunkZ + 2147483647L << 32;
|
ChunkPos v = new ChunkPos(chunkX, chunkZ);
|
||||||
PlayerInstance inst = this.instances.getValueByKey(v);
|
PlayerInstance inst = this.instances.get(v);
|
||||||
|
|
||||||
if(inst == null && create) {
|
if(inst == null && create) {
|
||||||
inst = new PlayerInstance(chunkX, chunkZ);
|
inst = new PlayerInstance(chunkX, chunkZ);
|
||||||
this.instances.add(v, inst);
|
this.instances.put(v, inst);
|
||||||
this.instList.add(inst);
|
this.instList.add(inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2245,29 +2302,6 @@ public final class WorldServer extends AWorldServer {
|
||||||
// return new LazyBlock(state, this, position);
|
// return new LazyBlock(state, this, position);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public final boolean setBiome(BlockPos position, Biome biome) {
|
|
||||||
Chunk chunk = this.getChunk(position);
|
|
||||||
if((chunk != null) && (chunk.isLoaded())) {
|
|
||||||
chunk.getBiomes()[((position.getZ() & 0xF) << 4 | position.getX() & 0xF)] = (byte)biome.id;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setBiomes(BlockPos start, BlockPos end, Biome biome) {
|
|
||||||
Set<ChunkPos> chunks = Sets.newHashSet();
|
|
||||||
for(int x = start.getX(); x <= end.getX(); x++) {
|
|
||||||
for(int z = start.getZ(); z <= end.getZ(); z++) {
|
|
||||||
if(this.setBiome(new BlockPos(x, 0, z), biome))
|
|
||||||
chunks.add(new ChunkPos(x >> 4, z >> 4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(ChunkPos pos : chunks) {
|
|
||||||
this.updateBiomes(pos.x, pos.z);
|
|
||||||
}
|
|
||||||
chunks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public final List<? extends Entity> getEntities(EditRegion region) {
|
// public final List<? extends Entity> getEntities(EditRegion region) {
|
||||||
// List<Entity> entities = Lists.newArrayList();
|
// List<Entity> entities = Lists.newArrayList();
|
||||||
// for(Entity entity : this.entities) {
|
// for(Entity entity : this.entities) {
|
||||||
|
@ -2304,10 +2338,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canStrikeAt(BlockPos strikePosition) {
|
public boolean canStrikeAt(BlockPos strikePosition) {
|
||||||
if(!this.canSeeSky(strikePosition)) {
|
if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if(this.getPrecipitationHeight(strikePosition).getY() > strikePosition.getY()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2380,7 +2411,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
|
if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(pos) < 10) {
|
||||||
State iblockstate = this.getState(pos);
|
State iblockstate = this.getState(pos);
|
||||||
Block block = iblockstate.getBlock();
|
Block block = iblockstate.getBlock();
|
||||||
|
|
||||||
|
@ -2428,12 +2459,13 @@ public final class WorldServer extends AWorldServer {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) {
|
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos, int y, int scan) {
|
||||||
|
scan = y - scan;
|
||||||
Chunk chunk = this.getChunk(pos);
|
Chunk chunk = this.getChunk(pos);
|
||||||
BlockPos blockpos;
|
BlockPos blockpos;
|
||||||
BlockPos blockpos1;
|
BlockPos blockpos1;
|
||||||
|
|
||||||
for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1) {
|
for(blockpos = new BlockPos(pos.getX(), y, pos.getZ()); blockpos.getY() >= 0 && blockpos.getY() >= scan; blockpos = blockpos1) {
|
||||||
blockpos1 = blockpos.down();
|
blockpos1 = blockpos.down();
|
||||||
Material material = chunk.getBlock(blockpos1).getMaterial();
|
Material material = chunk.getBlock(blockpos1).getMaterial();
|
||||||
|
|
||||||
|
@ -2445,6 +2477,10 @@ public final class WorldServer extends AWorldServer {
|
||||||
return blockpos;
|
return blockpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) {
|
||||||
|
return this.getTopSolidOrLiquidBlock(pos, 256, 256);
|
||||||
|
}
|
||||||
|
|
||||||
public void removePlayerEntityDangerously(Entity entityIn) {
|
public void removePlayerEntityDangerously(Entity entityIn) {
|
||||||
entityIn.setDead();
|
entityIn.setDead();
|
||||||
|
|
||||||
|
@ -2802,7 +2838,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
private int updates;
|
private int updates;
|
||||||
private int sections;
|
private int sections;
|
||||||
private long prevTime;
|
private long prevTime;
|
||||||
private boolean biomes;
|
private boolean resend;
|
||||||
|
|
||||||
public PlayerInstance(int chunkX, int chunkZ) {
|
public PlayerInstance(int chunkX, int chunkZ) {
|
||||||
this.position = new ChunkPos(chunkX, chunkZ);
|
this.position = new ChunkPos(chunkX, chunkZ);
|
||||||
|
@ -2836,9 +2872,8 @@ public final class WorldServer extends AWorldServer {
|
||||||
player.connection.getLoadedChunkList().remove(this.position);
|
player.connection.getLoadedChunkList().remove(this.position);
|
||||||
|
|
||||||
if(this.watching.isEmpty()) {
|
if(this.watching.isEmpty()) {
|
||||||
long v = (long)this.position.x + 2147483647L | (long)this.position.z + 2147483647L << 32;
|
|
||||||
this.increaseInhabitedTime(chunk);
|
this.increaseInhabitedTime(chunk);
|
||||||
WorldServer.this.instances.remove(v);
|
WorldServer.this.instances.remove(this.position);
|
||||||
WorldServer.this.instList.remove(this);
|
WorldServer.this.instList.remove(this);
|
||||||
|
|
||||||
if(this.updates > 0) {
|
if(this.updates > 0) {
|
||||||
|
@ -2859,7 +2894,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
WorldServer.this.toUpdate.add(this);
|
WorldServer.this.toUpdate.add(this);
|
||||||
this.updates = 64;
|
this.updates = 64;
|
||||||
this.sections = 0xffffffff;
|
this.sections = 0xffffffff;
|
||||||
this.biomes = true;
|
this.resend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void increaseInhabitedTime(Chunk chunk) {
|
private void increaseInhabitedTime(Chunk chunk) {
|
||||||
|
@ -2914,7 +2949,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
int x = this.position.x * 16;
|
int x = this.position.x * 16;
|
||||||
int z = this.position.z * 16;
|
int z = this.position.z * 16;
|
||||||
this.sendToAllPlayersWatchingChunk(new SPacketChunkData(WorldServer.this.getChunk(this.position.x, this.position.z),
|
this.sendToAllPlayersWatchingChunk(new SPacketChunkData(WorldServer.this.getChunk(this.position.x, this.position.z),
|
||||||
this.biomes, this.sections));
|
this.resend, this.sections));
|
||||||
|
|
||||||
for(int cy = 0; cy < 32; ++cy) {
|
for(int cy = 0; cy < 32; ++cy) {
|
||||||
if((this.sections & 1 << cy) != 0) {
|
if((this.sections & 1 << cy) != 0) {
|
||||||
|
@ -2945,7 +2980,7 @@ public final class WorldServer extends AWorldServer {
|
||||||
|
|
||||||
this.updates = 0;
|
this.updates = 0;
|
||||||
this.sections = 0;
|
this.sections = 0;
|
||||||
this.biomes = false;
|
this.resend = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package server.worldgen;
|
package server.worldgen;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import common.biome.Biome;
|
import common.biome.Biome;
|
||||||
import common.collect.Lists;
|
import common.collect.Lists;
|
||||||
|
import common.collect.Maps;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.LongHashMap;
|
import common.util.ChunkPos;
|
||||||
import common.worldgen.BiomeGenerator;
|
|
||||||
import server.worldgen.layer.GenLayer;
|
import server.worldgen.layer.GenLayer;
|
||||||
import server.worldgen.layer.GenLayerAddAreas;
|
import server.worldgen.layer.GenLayerAddAreas;
|
||||||
import server.worldgen.layer.GenLayerAddExtra;
|
import server.worldgen.layer.GenLayerAddExtra;
|
||||||
|
@ -54,7 +55,7 @@ public class BiomeGenLayered implements BiomeGenerator {
|
||||||
|
|
||||||
private final GenLayer genBiomes;
|
private final GenLayer genBiomes;
|
||||||
private final GenLayer biomeIndexLayer;
|
private final GenLayer biomeIndexLayer;
|
||||||
private final LongHashMap<CacheBlock> cacheMap = new LongHashMap();
|
private final Map<ChunkPos, CacheBlock> cacheMap = Maps.newHashMap();
|
||||||
private final List<CacheBlock> cache = Lists.<CacheBlock>newArrayList();
|
private final List<CacheBlock> cache = Lists.<CacheBlock>newArrayList();
|
||||||
private long lastCleanupTime;
|
private long lastCleanupTime;
|
||||||
|
|
||||||
|
@ -125,13 +126,13 @@ public class BiomeGenLayered implements BiomeGenerator {
|
||||||
{
|
{
|
||||||
x = x >> 4;
|
x = x >> 4;
|
||||||
z = z >> 4;
|
z = z >> 4;
|
||||||
long i = LongHashMap.packInt(x, z); // (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
ChunkPos pos = new ChunkPos(x, z);
|
||||||
CacheBlock blk = this.cacheMap.getValueByKey(i);
|
CacheBlock blk = this.cacheMap.get(pos);
|
||||||
|
|
||||||
if (blk == null)
|
if (blk == null)
|
||||||
{
|
{
|
||||||
blk = new CacheBlock(x, z);
|
blk = new CacheBlock(x, z);
|
||||||
this.cacheMap.add(i, blk);
|
this.cacheMap.put(pos, blk);
|
||||||
this.cache.add(blk);
|
this.cache.add(blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +157,7 @@ public class BiomeGenLayered implements BiomeGenerator {
|
||||||
if (l > 30000L || l < 0L)
|
if (l > 30000L || l < 0L)
|
||||||
{
|
{
|
||||||
this.cache.remove(k--);
|
this.cache.remove(k--);
|
||||||
long i1 = LongHashMap.packInt(blk.xPosition, blk.zPosition) ; // (long)biomecache$block.xPosition & 4294967295L | ((long)biomecache$block.zPosition & 4294967295L) << 32;
|
this.cacheMap.remove(new ChunkPos(blk.xPosition, blk.zPosition));
|
||||||
this.cacheMap.remove(i1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import common.biome.Biome;
|
import common.biome.Biome;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.worldgen.BiomeGenerator;
|
|
||||||
|
|
||||||
public class BiomeGenSingle implements BiomeGenerator {
|
public class BiomeGenSingle implements BiomeGenerator {
|
||||||
private final Biome biome;
|
private final Biome biome;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package common.worldgen;
|
package server.worldgen;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import common.init.Blocks;
|
||||||
import common.material.Material;
|
import common.material.Material;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.world.LightType;
|
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import server.biome.GenBiome;
|
import server.biome.GenBiome;
|
||||||
import server.world.WorldServer;
|
import server.world.WorldServer;
|
||||||
|
@ -161,7 +160,7 @@ public class FeatureLakes
|
||||||
{
|
{
|
||||||
BlockPos blockpos = position.add(i2, j4 - 1, j3);
|
BlockPos blockpos = position.add(i2, j4 - 1, j3);
|
||||||
|
|
||||||
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.getLightFor(LightType.SKY, position.add(i2, j4, j3)) > 0)
|
if (worldIn.getState(blockpos).getBlock() == replace && worldIn.isAirBlock(position.add(i2, j4, j3)))
|
||||||
{
|
{
|
||||||
GenBiome biomegenbase = GenBiome.BIOMES[worldIn.getBiomeGenForCoords(blockpos).id];
|
GenBiome biomegenbase = GenBiome.BIOMES[worldIn.getBiomeGenForCoords(blockpos).id];
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ import common.nbt.NBTTagCompound;
|
||||||
import common.rng.Random;
|
import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.ChunkPos;
|
import common.util.ChunkPos;
|
||||||
import common.util.LongHashMap;
|
|
||||||
import common.world.World;
|
import common.world.World;
|
||||||
import server.world.WorldServer;
|
import server.world.WorldServer;
|
||||||
import server.world.WorldServer.WorldSavedData;
|
import server.world.WorldServer.WorldSavedData;
|
||||||
|
@ -19,7 +18,7 @@ import server.worldgen.caves.MapGenBase;
|
||||||
public abstract class MapGenStructure extends MapGenBase
|
public abstract class MapGenStructure extends MapGenBase
|
||||||
{
|
{
|
||||||
private WorldSavedData structureData;
|
private WorldSavedData structureData;
|
||||||
protected Map<Long, StructureStart> structureMap = Maps.<Long, StructureStart>newHashMap();
|
protected Map<ChunkPos, StructureStart> structureMap = Maps.<ChunkPos, StructureStart>newHashMap();
|
||||||
|
|
||||||
public abstract String getStructureName();
|
public abstract String getStructureName();
|
||||||
|
|
||||||
|
@ -34,14 +33,15 @@ public abstract class MapGenStructure extends MapGenBase
|
||||||
return;
|
return;
|
||||||
this.initializeStructureData(worldIn);
|
this.initializeStructureData(worldIn);
|
||||||
|
|
||||||
if (!this.structureMap.containsKey(Long.valueOf(LongHashMap.packInt(chunkX, chunkZ))))
|
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||||
|
if (!this.structureMap.containsKey(pos))
|
||||||
{
|
{
|
||||||
this.rand.intv();
|
this.rand.intv();
|
||||||
|
|
||||||
if (this.canSpawnStructureAtCoords(chunkX, chunkZ))
|
if (this.canSpawnStructureAtCoords(chunkX, chunkZ))
|
||||||
{
|
{
|
||||||
StructureStart structurestart = this.getStructureStart(chunkX, chunkZ);
|
StructureStart structurestart = this.getStructureStart(chunkX, chunkZ);
|
||||||
this.structureMap.put(Long.valueOf(LongHashMap.packInt(chunkX, chunkZ)), structurestart);
|
this.structureMap.put(pos, structurestart);
|
||||||
this.setStructureStart(chunkX, chunkZ, structurestart);
|
this.setStructureStart(chunkX, chunkZ, structurestart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ public abstract class MapGenStructure extends MapGenBase
|
||||||
|
|
||||||
if (structurestart != null)
|
if (structurestart != null)
|
||||||
{
|
{
|
||||||
this.structureMap.put(Long.valueOf(LongHashMap.packInt(i, j)), structurestart);
|
this.structureMap.put(new ChunkPos(i, j), structurestart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@ import common.rng.Random;
|
||||||
import common.util.BlockPos;
|
import common.util.BlockPos;
|
||||||
import common.util.Facing;
|
import common.util.Facing;
|
||||||
import common.world.State;
|
import common.world.State;
|
||||||
import common.worldgen.BiomeGenerator;
|
|
||||||
import server.world.WorldServer;
|
import server.world.WorldServer;
|
||||||
|
import server.worldgen.BiomeGenerator;
|
||||||
import server.worldgen.LootConstants;
|
import server.worldgen.LootConstants;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue