minimize client world class
This commit is contained in:
parent
eec61c9258
commit
76e018b4ed
62 changed files with 1183 additions and 1338 deletions
|
@ -83,6 +83,7 @@ import common.packet.SPacketSignEditorOpen;
|
|||
import common.packet.SPacketPlayerAbilities;
|
||||
import common.packet.SPacketTabComplete;
|
||||
import common.packet.SPacketAnimation;
|
||||
import common.packet.SPacketBlockBreakAnim;
|
||||
import common.packet.SPacketBlockChange;
|
||||
import common.packet.SPacketCharacterList;
|
||||
import common.packet.SPacketChunkData;
|
||||
|
@ -933,6 +934,25 @@ public class Player extends User implements Executor, IPlayer
|
|||
return new SPacketMapChunkBulk(xPositions, zPositions, chunksData, sky);
|
||||
}
|
||||
|
||||
|
||||
private void sendBlockBreakProgress(BlockPos pos, int progress)
|
||||
{
|
||||
for (Player conn : this.server.getPlayers())
|
||||
{
|
||||
EntityNPC player = conn.getPresentEntity();
|
||||
if (player != null && player.worldObj == this.entity.worldObj && player != this.entity)
|
||||
{
|
||||
double d0 = (double)pos.getX() - player.posX;
|
||||
double d1 = (double)pos.getY() - player.posY;
|
||||
double d2 = (double)pos.getZ() - player.posZ;
|
||||
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
|
||||
{
|
||||
conn.sendPacket(new SPacketBlockBreakAnim(this.entity.getId(), pos, progress));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -1045,7 +1065,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (j != this.durabilityRemainingOnBlock)
|
||||
{
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.removingPos, j);
|
||||
this.sendBlockBreakProgress(this.removingPos, j);
|
||||
this.durabilityRemainingOnBlock = j;
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1082,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (block1 == Blocks.air)
|
||||
{
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, -1);
|
||||
this.sendBlockBreakProgress(this.startPos, -1);
|
||||
this.durabilityRemainingOnBlock = -1;
|
||||
this.isDestroyingBlock = false;
|
||||
}
|
||||
|
@ -1074,7 +1094,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
if (l != this.durabilityRemainingOnBlock)
|
||||
{
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, l);
|
||||
this.sendBlockBreakProgress(this.startPos, l);
|
||||
this.durabilityRemainingOnBlock = l;
|
||||
}
|
||||
}
|
||||
|
@ -1121,7 +1141,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
this.isDestroyingBlock = true;
|
||||
this.startPos = pos;
|
||||
int i = (int)(f * 10.0F);
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), pos, i);
|
||||
this.sendBlockBreakProgress(pos, i);
|
||||
this.durabilityRemainingOnBlock = i;
|
||||
}
|
||||
// }
|
||||
|
@ -1141,7 +1161,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
if (f >= 0.7F)
|
||||
{
|
||||
this.isDestroyingBlock = false;
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), pos, -1);
|
||||
this.sendBlockBreakProgress(pos, -1);
|
||||
this.tryHarvestBlock(pos);
|
||||
}
|
||||
else if (!this.receivedFinishDiggingPacket)
|
||||
|
@ -1158,7 +1178,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
public void cancelDestroyingBlock()
|
||||
{
|
||||
this.isDestroyingBlock = false;
|
||||
this.entity.worldObj.sendBlockBreakProgress(this.entity.getId(), this.startPos, -1);
|
||||
this.sendBlockBreakProgress(this.startPos, -1);
|
||||
}
|
||||
|
||||
private boolean removeBlock(BlockPos pos)
|
||||
|
|
|
@ -73,6 +73,7 @@ import common.util.Vec3;
|
|||
import common.vars.Vars;
|
||||
import common.village.Village;
|
||||
import common.world.BlockArray;
|
||||
import common.world.Chunk;
|
||||
import common.world.Explosion;
|
||||
import common.world.AWorldServer;
|
||||
import common.world.LightType;
|
||||
|
@ -405,7 +406,7 @@ public final class WorldServer extends AWorldServer {
|
|||
this.dimension.setTimeExisted(this.time += 1L);
|
||||
// this.dataModified = true;
|
||||
if(Vars.dayCycle) // {
|
||||
this.daytime += Vars.timeFlow;
|
||||
this.daytime += (long)Vars.timeFlow;
|
||||
// if(this.dimension.getType().dayCycle)
|
||||
// this.season = this.getSeasonByTime();
|
||||
// }
|
||||
|
@ -1676,14 +1677,6 @@ public final class WorldServer extends AWorldServer {
|
|||
{
|
||||
this.sendNear(x, y, z, volume > 1.0F ? (double)(16.0F * volume) : 16.0D, new SPacketSoundEffect(sound, x, y, z, volume));
|
||||
}
|
||||
|
||||
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
|
||||
{
|
||||
}
|
||||
|
||||
protected void notifyLightSet(BlockPos pos)
|
||||
{
|
||||
}
|
||||
|
||||
public void playAuxSFX(EntityNPC player, int sfxType, BlockPos blockPosIn, int data)
|
||||
{
|
||||
|
@ -1695,25 +1688,6 @@ public final class WorldServer extends AWorldServer {
|
|||
// this.server.sendPacket(new S28PacketEffect(soundID, pos, data, true));
|
||||
// }
|
||||
|
||||
public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
|
||||
{
|
||||
for (Player conn : this.server.getPlayers())
|
||||
{
|
||||
EntityNPC player = conn.getPresentEntity();
|
||||
if (player != null && player.worldObj == this && player.getId() != breakerId)
|
||||
{
|
||||
double d0 = (double)pos.getX() - player.posX;
|
||||
double d1 = (double)pos.getY() - player.posY;
|
||||
double d2 = (double)pos.getZ() - player.posZ;
|
||||
|
||||
if (d0 * d0 + d1 * d1 + d2 * d2 < 1024.0D)
|
||||
{
|
||||
conn.sendPacket(new SPacketBlockBreakAnim(breakerId, pos, progress));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePlayerInstances() {
|
||||
long time = this.time;
|
||||
|
||||
|
@ -2046,6 +2020,24 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean setState(BlockPos pos, State newState, int flags) {
|
||||
if(!isValid(pos))
|
||||
return false;
|
||||
Chunk chunk = this.getChunk(pos);
|
||||
Block block = newState.getBlock();
|
||||
State iblockstate = chunk.setState(pos, newState);
|
||||
if(iblockstate == null)
|
||||
return false;
|
||||
Block block1 = iblockstate.getBlock();
|
||||
if(block.getLightOpacity() != block1.getLightOpacity() || block.getLight() != block1.getLight())
|
||||
this.checkLight(pos);
|
||||
if((flags & 2) != 0 && chunk.isPopulated())
|
||||
this.markBlockForUpdate(pos);
|
||||
if((flags & 1) != 0)
|
||||
this.notifyNeighborsOfStateChange(pos, iblockstate.getBlock());
|
||||
return true;
|
||||
}
|
||||
|
||||
public final boolean setBlock(BlockPos pos, ClipboardBlock block) {
|
||||
// int x = position.getBlockX();
|
||||
|
@ -2625,6 +2617,20 @@ public final class WorldServer extends AWorldServer {
|
|||
}
|
||||
}
|
||||
|
||||
public void notifyNeighborsOfStateChange(BlockPos pos, Block blockType) {
|
||||
this.notifyBlockOfStateChange(pos.west(), blockType);
|
||||
this.notifyBlockOfStateChange(pos.east(), blockType);
|
||||
this.notifyBlockOfStateChange(pos.down(), blockType);
|
||||
this.notifyBlockOfStateChange(pos.up(), blockType);
|
||||
this.notifyBlockOfStateChange(pos.north(), blockType);
|
||||
this.notifyBlockOfStateChange(pos.south(), blockType);
|
||||
}
|
||||
|
||||
private void notifyBlockOfStateChange(BlockPos pos, final Block blockIn) {
|
||||
State iblockstate = this.getState(pos);
|
||||
iblockstate.getBlock().onUpdate(this, pos, iblockstate, blockIn);
|
||||
}
|
||||
|
||||
private static SPacketMultiBlockChange getPacket(int amount, long[] list, ChunkServer chunk) {
|
||||
ChunkPos pos = new ChunkPos(chunk.xPos, chunk.zPos);
|
||||
SPacketMultiBlockChange.BlockUpdateData[] changes = new SPacketMultiBlockChange.BlockUpdateData[amount];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue