Revert "make world taller"

This reverts commit caef42dc16.
This commit is contained in:
Sen 2025-05-20 19:09:19 +02:00
parent caef42dc16
commit 4d1d323c72
49 changed files with 292 additions and 490 deletions

View file

@ -767,8 +767,8 @@ 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.getExtractedExtend(), packetIn.hasBiomes()); chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedSize(), packetIn.hasBiomes());
this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (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.hasBiomes() || this.clientWorldController.dimension.hasNoLight()) // TODO: check
{ {
@ -781,7 +781,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController); NetHandler.checkThread(packetIn, this, this.gameController, this.clientWorldController);
Chunk chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); Chunk chunk = this.clientWorldController.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
chunk.setBiomes(packetIn.getBiomes()); chunk.setBiomes(packetIn.getBiomes());
this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 512, (packetIn.getChunkZ() << 4) + 15);
} }
/** /**
@ -1413,8 +1413,8 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
this.clientWorldController.doPreChunk(j, k, true); this.clientWorldController.doPreChunk(j, k, true);
// this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15); // this.clientWorldController.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15);
Chunk chunk = this.clientWorldController.getChunk(j, k); Chunk chunk = this.clientWorldController.getChunk(j, k);
chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkSize(i), packetIn.getChunkExtend(i), true); chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkSize(i), true);
this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15); this.clientWorldController.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 512, (k << 4) + 15);
if (this.clientWorldController.dimension.hasNoLight()) // TODO: check if (this.clientWorldController.dimension.hasNoLight()) // TODO: check
{ {

View file

@ -87,7 +87,7 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
private State getBlockStateRaw(BlockPos pos) private State getBlockStateRaw(BlockPos pos)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) 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;
@ -136,7 +136,7 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
{ {
return 0; return 0;
} }
else if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) else if (pos.getY() >= 0 && pos.getY() < 512)
{ {
if (this.getState(pos).getBlock().getSumBrightness()) if (this.getState(pos).getBlock().getSumBrightness())
{ {
@ -183,7 +183,7 @@ public class RegionRenderCache extends ChunkCache implements IWorldAccess
public int getLightFor(LightType p_175628_1_, BlockPos pos) public int getLightFor(LightType p_175628_1_, BlockPos pos)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) 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;

View file

@ -53,7 +53,6 @@ import common.util.Vec3;
import common.util.Vector3f; import common.util.Vector3f;
import common.world.Chunk; import common.world.Chunk;
import common.world.State; import common.world.State;
import common.world.World;
public class RenderGlobal public class RenderGlobal
{ {
@ -633,7 +632,7 @@ public class RenderGlobal
// boolean flag3 = this.gm.getRenderViewEntity() instanceof EntityLivingBase ? ((EntityLivingBase)this.gm.getRenderViewEntity()).isPlayerSleeping() : false; // boolean flag3 = this.gm.getRenderViewEntity() instanceof EntityLivingBase ? ((EntityLivingBase)this.gm.getRenderViewEntity()).isPlayerSleeping() : false;
if (entity2.posY < (double)(-World.MAX_SIZE_Y) || entity2.posY >= (double)World.MAX_SIZE_Y || this.theWorld.isBlockLoaded(new BlockPos(entity2))) if (entity2.posY < 0.0D || entity2.posY >= 512.0D || this.theWorld.isBlockLoaded(new BlockPos(entity2)))
{ {
if((entity2 != this.gm.getRenderViewEntity() || this.gm.thirdPersonView != 0 /* || flag3 */)) { if((entity2 != this.gm.getRenderViewEntity() || this.gm.thirdPersonView != 0 /* || flag3 */)) {
++this.countEntitiesRendered; ++this.countEntitiesRendered;
@ -932,7 +931,7 @@ public class RenderGlobal
private RenderChunk getRenderChunkOffset(BlockPos playerPos, RenderChunk renderChunkBase, Facing facing) private RenderChunk getRenderChunkOffset(BlockPos playerPos, RenderChunk renderChunkBase, Facing facing)
{ {
BlockPos blockpos = renderChunkBase.getBlockPosOffset16(facing); BlockPos blockpos = renderChunkBase.getBlockPosOffset16(facing);
return ExtMath.absi(playerPos.getX() - blockpos.getX()) > this.renderDistanceChunks * 16 ? null : (blockpos.getY() >= -World.MAX_SIZE_Y && blockpos.getY() < World.MAX_SIZE_Y ? (ExtMath.absi(playerPos.getZ() - blockpos.getZ()) > this.renderDistanceChunks * 16 ? null : this.viewFrustum.getRenderChunk(blockpos)) : null); return ExtMath.absi(playerPos.getX() - blockpos.getX()) > this.renderDistanceChunks * 16 ? null : (blockpos.getY() >= 0 && blockpos.getY() < 512 ? (ExtMath.absi(playerPos.getZ() - blockpos.getZ()) > this.renderDistanceChunks * 16 ? null : this.viewFrustum.getRenderChunk(blockpos)) : null);
} }
protected Vector3f getViewVector(Entity entityIn, double partialTicks) protected Vector3f getViewVector(Entity entityIn, double partialTicks)

View file

@ -19,12 +19,14 @@ public class EmptyChunk extends Chunk {
private final int liquidY; private final int liquidY;
private final State liquid; private final State liquid;
private final Block liquidBlock; private final Block liquidBlock;
private final int liquidMeta;
public EmptyChunk(WorldClient world) { public EmptyChunk(WorldClient world) {
super(world, 0, 0); super(world, 0, 0);
this.liquidY = world.dimension.getSeaLevel() - 1; this.liquidY = world.dimension.getSeaLevel() - 1;
this.liquid = world.dimension.getLiquid(); this.liquid = world.dimension.getLiquid();
this.liquidBlock = this.liquid.getBlock(); this.liquidBlock = this.liquid.getBlock();
this.liquidMeta = this.liquidBlock.getMetaFromState(this.liquid);
} }
public int getHeight(int x, int z) { public int getHeight(int x, int z) {
@ -105,7 +107,7 @@ public class EmptyChunk extends Chunk {
return true; return true;
} }
public void setData(byte[] data, int update, int[] extend, boolean biomes) { public void setData(byte[] data, int update, boolean biomes) {
} }
public Biome getBiome(BlockPos pos, BiomeGenerator gen) { public Biome getBiome(BlockPos pos, BiomeGenerator gen) {

View file

@ -36,7 +36,6 @@ import common.util.BlockPos.MutableBlockPos;
import common.world.Chunk; import common.world.Chunk;
import common.world.AWorldClient; import common.world.AWorldClient;
import common.world.State; import common.world.State;
import common.world.World;
public class WorldClient extends AWorldClient public class WorldClient extends AWorldClient
{ {
@ -81,14 +80,14 @@ public class WorldClient extends AWorldClient
this.chunkMapping.add(id, this.emptyChunk); this.chunkMapping.add(id, this.emptyChunk);
this.emptyChunkListing.remove(id); this.emptyChunkListing.remove(id);
this.nextEmptyChunkListing.add(id); this.nextEmptyChunkListing.add(id);
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15); this.markBlockRangeForRenderUpdate(x << 4, 0, z << 4, (x << 4) + 15, 512, (z << 4) + 15);
} }
} }
for(Long id : this.emptyChunkListing) { for(Long id : this.emptyChunkListing) {
this.chunkMapping.remove(id); this.chunkMapping.remove(id);
int x = LongHashMap.getX(id); int x = LongHashMap.getX(id);
int z = LongHashMap.getZ(id); int z = LongHashMap.getZ(id);
this.markBlockRangeForRenderUpdate(x << 4, -World.MAX_SIZE_Y, z << 4, (x << 4) + 15, World.MAX_SIZE_Y, (z << 4) + 15); this.markBlockRangeForRenderUpdate(x << 4, 0, z << 4, (x << 4) + 15, 512, (z << 4) + 15);
} }
this.emptyChunkListing.clear(); this.emptyChunkListing.clear();
this.emptyChunkListing.addAll(this.nextEmptyChunkListing); this.emptyChunkListing.addAll(this.nextEmptyChunkListing);
@ -185,7 +184,7 @@ public class WorldClient extends AWorldClient
if (!load) if (!load)
{ {
this.markBlockRangeForRenderUpdate(x * 16, -World.MAX_SIZE_Y, z * 16, x * 16 + 15, World.MAX_SIZE_Y, z * 16 + 15); this.markBlockRangeForRenderUpdate(x * 16, 0, z * 16, x * 16 + 15, 512, z * 16 + 15);
} }
} }

View file

@ -87,7 +87,7 @@ public class BlockBanner extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityBanner(); return new TileEntityBanner();
} }

View file

@ -49,7 +49,7 @@ public class BlockBeacon extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityBeacon(); return new TileEntityBeacon();
} }

View file

@ -70,7 +70,7 @@ public class BlockBlueShroom extends BlockBush
public boolean canBlockStay(World worldIn, BlockPos pos, State state) public boolean canBlockStay(World worldIn, BlockPos pos, State state)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) if (pos.getY() >= 0 && pos.getY() < 512)
{ {
State iblockstate = worldIn.getState(pos.down()); State iblockstate = worldIn.getState(pos.down());
return (iblockstate.getBlock() == Blocks.tian_soil || iblockstate.getBlock() == Blocks.obsidian) ? true : (worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock())); return (iblockstate.getBlock() == Blocks.tian_soil || iblockstate.getBlock() == Blocks.obsidian) ? true : (worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));

View file

@ -382,7 +382,7 @@ public class BlockBrewingStand extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityBrewingStand(); return new TileEntityBrewingStand();
} }

View file

@ -530,7 +530,7 @@ public class BlockChest extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityChest(); return new TileEntityChest();
} }

View file

@ -152,7 +152,7 @@ public class BlockDaylightDetector extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityDaylightDetector(); return new TileEntityDaylightDetector();
} }

View file

@ -183,7 +183,7 @@ public class BlockDispenser extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityDispenser(); return new TileEntityDispenser();
} }

View file

@ -291,7 +291,7 @@ public class BlockDoor extends Block
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{ {
return pos.getY() >= World.MAX_SIZE_Y - 1 ? false : worldIn.isBlockSolid(pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up()); return pos.getY() >= 511 ? false : worldIn.isBlockSolid(pos.down()) && super.canPlaceBlockAt(worldIn, pos) && super.canPlaceBlockAt(worldIn, pos.up());
} }
public int getMobilityFlag() public int getMobilityFlag()

View file

@ -24,7 +24,7 @@ public class BlockDropper extends BlockDispenser
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityDropper(); return new TileEntityDropper();
} }

View file

@ -96,7 +96,7 @@ public class BlockEnchantmentTable extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityEnchantmentTable(); return new TileEntityEnchantmentTable();
} }

View file

@ -167,7 +167,7 @@ public class BlockFurnace extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityFurnace(); return new TileEntityFurnace();
} }

View file

@ -142,7 +142,7 @@ public class BlockHopper extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityHopper(); return new TileEntityHopper();
} }

View file

@ -64,7 +64,7 @@ public class BlockLilyPad extends BlockBush
public boolean canBlockStay(World worldIn, BlockPos pos, State state) public boolean canBlockStay(World worldIn, BlockPos pos, State state)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) if (pos.getY() >= 0 && pos.getY() < 512)
{ {
State iblockstate = worldIn.getState(pos.down()); State iblockstate = worldIn.getState(pos.down());
return (iblockstate.getBlock().getMaterial().isColdLiquid() && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0) return (iblockstate.getBlock().getMaterial().isColdLiquid() && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0)

View file

@ -23,7 +23,7 @@ public abstract class BlockMachine extends BlockDirectional implements ITileEnti
this.setTab(CheatTab.tabTech); this.setTab(CheatTab.tabTech);
} }
public abstract TileEntity createNewTileEntity(World worldIn); public abstract TileEntity createNewTileEntity(World worldIn, int meta);
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state) { public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state) {
this.updateState(worldIn, pos, state); this.updateState(worldIn, pos, state);

View file

@ -22,7 +22,7 @@ public class BlockMobSpawner extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityMobSpawner(); return new TileEntityMobSpawner();
} }

View file

@ -74,7 +74,7 @@ public class BlockMushroom extends BlockBush implements IGrowable
public boolean canBlockStay(World worldIn, BlockPos pos, State state) public boolean canBlockStay(World worldIn, BlockPos pos, State state)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) if (pos.getY() >= 0 && pos.getY() < 512)
{ {
State iblockstate = worldIn.getState(pos.down()); State iblockstate = worldIn.getState(pos.down());
return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock())); return iblockstate.getBlock() == Blocks.mycelium ? true : (iblockstate.getBlock() == Blocks.dirt && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL ? true : worldIn.getLight(pos) < 13 && this.canPlaceBlockOn(iblockstate.getBlock()));

View file

@ -85,7 +85,7 @@ public class BlockNote extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityNote(); return new TileEntityNote();
} }

View file

@ -548,9 +548,9 @@ public class BlockPistonBase extends Block
{ {
return false; return false;
} }
else if (pos.getY() >= -World.MAX_SIZE_Y && (direction != Facing.DOWN || pos.getY() != -World.MAX_SIZE_Y)) else if (pos.getY() >= 0 && (direction != Facing.DOWN || pos.getY() != 0))
{ {
if (pos.getY() <= World.MAX_SIZE_Y - 1 && (direction != Facing.UP || pos.getY() != World.MAX_SIZE_Y - 1)) if (pos.getY() <= World.HEIGHT - 1 && (direction != Facing.UP || pos.getY() != World.HEIGHT - 1))
{ {
if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston) if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
{ {

View file

@ -35,7 +35,7 @@ public class BlockPistonMoving extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return null; return null;
} }

View file

@ -242,7 +242,7 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state) public void onBlockAdded(AWorldServer worldIn, BlockPos pos, State state)
{ {
super.onBlockAdded(worldIn, pos, state); super.onBlockAdded(worldIn, pos, state);
worldIn.setTileEntity(pos, this.createNewTileEntity(worldIn)); worldIn.setTileEntity(pos, this.createNewTileEntity(worldIn, 0));
} }
public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state) public void onBlockRemoved(AWorldServer worldIn, BlockPos pos, State state)
@ -265,7 +265,7 @@ public class BlockRedstoneComparator extends BlockRedstoneDiode implements ITile
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntityComparator(); return new TileEntityComparator();
} }

View file

@ -79,7 +79,7 @@ public class BlockSign extends BlockContainer
/** /**
* Returns a new instance of a block's tile entity class. Called on placing the block. * Returns a new instance of a block's tile entity class. Called on placing the block.
*/ */
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntitySign(); return new TileEntitySign();
} }

View file

@ -77,7 +77,7 @@ public class BlockSkull extends BlockContainer
return this.getState().withProperty(FACING, placer.getHorizontalFacing()); return this.getState().withProperty(FACING, placer.getHorizontalFacing());
} }
public TileEntity createNewTileEntity(World worldIn) public TileEntity createNewTileEntity(World worldIn, int meta)
{ {
return new TileEntitySkull(); return new TileEntitySkull();
} }

View file

@ -11,7 +11,7 @@ import common.world.State;
import common.world.World; import common.world.World;
public class BlockTianReactor extends BlockMachine { public class BlockTianReactor extends BlockMachine {
public TileEntity createNewTileEntity(World worldIn) { public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityTianReactor(); return new TileEntityTianReactor();
} }

View file

@ -280,7 +280,7 @@ public class BlockVine extends Block
Facing enumfacing1 = Facing.random(rand); Facing enumfacing1 = Facing.random(rand);
BlockPos blockpos1 = pos.up(); BlockPos blockpos1 = pos.up();
if (enumfacing1 == Facing.UP && pos.getY() < World.MAX_SIZE_Y - 1 && worldIn.isAirBlock(blockpos1)) if (enumfacing1 == Facing.UP && pos.getY() < 511 && worldIn.isAirBlock(blockpos1))
{ {
if (!flag) if (!flag)
{ {

View file

@ -5,5 +5,8 @@ import common.world.World;
public interface ITileEntityProvider public interface ITileEntityProvider
{ {
TileEntity createNewTileEntity(World worldIn); /**
* Returns a new instance of a block's tile entity class. Called on placing the block.
*/
TileEntity createNewTileEntity(World worldIn, int meta);
} }

View file

@ -975,7 +975,6 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.seed = tag.getLong("Seed"); this.seed = tag.getLong("Seed");
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) { if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
this.seaLevel = tag.getInteger("SeaLevel"); this.seaLevel = tag.getInteger("SeaLevel");
this.filler = BlockRegistry.getFromIdName(tag.getString("FillerBlock"), Blocks.stone.getState());
this.liquid = BlockRegistry.getFromIdName(tag.getString("LiquidBlock"), Blocks.water.getState()); this.liquid = BlockRegistry.getFromIdName(tag.getString("LiquidBlock"), Blocks.water.getState());
} }
} }
@ -1022,6 +1021,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather; this.defaultWeather = this.defaultWeather == null ? Weather.CLEAR : this.defaultWeather;
this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves")); this.defaultLeaves = LeavesType.getByName(tag.getString("DefaultLeaves"));
this.defaultLeaves = this.defaultLeaves == null ? LeavesType.SPRING : this.defaultLeaves; this.defaultLeaves = this.defaultLeaves == null ? LeavesType.SPRING : this.defaultLeaves;
this.filler = BlockRegistry.getFromIdName(tag.getString("FillerBlock"), Blocks.stone.getState());
this.top = BlockRegistry.getFromIdName(tag.getString("TopBlock"), Blocks.dirt.getState()); this.top = BlockRegistry.getFromIdName(tag.getString("TopBlock"), Blocks.dirt.getState());
this.surface = BlockRegistry.getFromIdName(tag.getString("SurfaceBlock"), Blocks.grass.getState()); this.surface = BlockRegistry.getFromIdName(tag.getString("SurfaceBlock"), Blocks.grass.getState());
this.alt1 = BlockRegistry.getFromIdName(tag.getString("AltBlock1"), Blocks.gravel.getState()); this.alt1 = BlockRegistry.getFromIdName(tag.getString("AltBlock1"), Blocks.gravel.getState());
@ -1215,7 +1215,6 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
tag.setLong("Seed", this.seed); tag.setLong("Seed", this.seed);
if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) { if(partialGen || all || this.id >= UniverseRegistry.MORE_DIM_ID) {
tag.setInteger("SeaLevel", this.seaLevel); tag.setInteger("SeaLevel", this.seaLevel);
tag.setString("FillerBlock", BlockRegistry.toIdName(this.filler));
tag.setString("LiquidBlock", BlockRegistry.toIdName(this.liquid)); tag.setString("LiquidBlock", BlockRegistry.toIdName(this.liquid));
} }
} }
@ -1262,6 +1261,7 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
tag.setBoolean("SemiFixed", this.semiFixed); tag.setBoolean("SemiFixed", this.semiFixed);
tag.setString("DefaultWeather", this.defaultWeather.getName()); tag.setString("DefaultWeather", this.defaultWeather.getName());
tag.setString("DefaultLeaves", this.defaultLeaves.getName()); tag.setString("DefaultLeaves", this.defaultLeaves.getName());
tag.setString("FillerBlock", BlockRegistry.toIdName(this.filler));
tag.setString("TopBlock", BlockRegistry.toIdName(this.top)); tag.setString("TopBlock", BlockRegistry.toIdName(this.top));
tag.setString("SurfaceBlock", BlockRegistry.toIdName(this.surface)); tag.setString("SurfaceBlock", BlockRegistry.toIdName(this.surface));
tag.setString("AltBlock1", BlockRegistry.toIdName(this.alt1)); tag.setString("AltBlock1", BlockRegistry.toIdName(this.alt1));

View file

@ -174,7 +174,7 @@ public class EntityFalling extends Entity implements IObjectData
} }
} }
} }
else if (this.fallTime > 100 && !this.worldObj.client && (blockpos1.getY() < -World.MAX_SIZE_Y + 1 || blockpos1.getY() > World.MAX_SIZE_Y) || this.fallTime > 600) else if (this.fallTime > 100 && !this.worldObj.client && (blockpos1.getY() < 1 || blockpos1.getY() > 512) || this.fallTime > 600)
{ {
if (this.shouldDropItem && Config.objectDrop) if (this.shouldDropItem && Config.objectDrop)
{ {

View file

@ -2684,7 +2684,7 @@ public abstract class EntityNPC extends EntityLiving
} }
else else
{ {
this.client.addToSendQueue(new CPacketPlayer.C06PacketPlayerPosLook(this.motionX, -99999999.0D, this.motionZ, this.rotYaw, this.rotPitch, this.onGround)); this.client.addToSendQueue(new CPacketPlayer.C06PacketPlayerPosLook(this.motionX, -999.0D, this.motionZ, this.rotYaw, this.rotPitch, this.onGround));
flag2 = false; flag2 = false;
} }

View file

@ -36,7 +36,7 @@ public class ItemBucket extends Item
private final BlockDynamicLiquid liquid; private final BlockDynamicLiquid liquid;
private static boolean test(AWorldServer world, BlockPos pos, Set<Block> blocks, int max, BlockPos origin, int radius) { private static boolean test(AWorldServer world, BlockPos pos, Set<Block> blocks, int max, BlockPos origin, int radius) {
if(pos.getY() < -World.MAX_SIZE_Y || pos.getY() > max) if(pos.getY() < 0 || pos.getY() > max)
return false; return false;
if(pos.getX() < origin.getX() - radius || pos.getX() > origin.getX() + radius) if(pos.getX() < origin.getX() - radius || pos.getX() > origin.getX() + radius)
return false; return false;
@ -54,7 +54,7 @@ public class ItemBucket extends Item
List<Vec3i> dirs = new ArrayList<Vec3i>(); List<Vec3i> dirs = new ArrayList<Vec3i>();
Set<Block> blocks = liquid == null ? null : Sets.newHashSet(FluidRegistry.getDynamicBlock(liquid), liquid, Blocks.air); Set<Block> blocks = liquid == null ? null : Sets.newHashSet(FluidRegistry.getDynamicBlock(liquid), liquid, Blocks.air);
State state = (liquid == null ? Blocks.air : liquid).getState(); State state = (liquid == null ? Blocks.air : liquid).getState();
int max = World.MAX_SIZE_Y - 1; int max = 511;
if(liquid != null) { if(liquid != null) {
dirs.add(new Vec3i(1, 0, 0)); dirs.add(new Vec3i(1, 0, 0));

View file

@ -58,14 +58,16 @@ 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.writeInt(pos.getX()); this.writeLong(pos.toLong());
this.writeInt(pos.getY()); // this.writeInt(pos.getX());
this.writeInt(pos.getZ()); // this.writeInt(pos.getY());
// this.writeInt(pos.getZ());
} }
// public Text readChatComponent() throws IOException // public Text readChatComponent() throws IOException

View file

@ -21,12 +21,12 @@ public class SPacketChunkData implements Packet<IClientPlayer>
{ {
} }
public SPacketChunkData(Chunk chunkIn, boolean biomes, int segUpdate, int[] extend) public SPacketChunkData(Chunk chunkIn, boolean biomes, int segUpdate)
{ {
this.chunkX = chunkIn.xPos; this.chunkX = chunkIn.xPos;
this.chunkZ = chunkIn.zPos; this.chunkZ = chunkIn.zPos;
this.biomes = biomes; this.biomes = biomes;
this.extractedData = getExtractedData(chunkIn, biomes, !chunkIn.getWorld().dimension.hasNoLight(), segUpdate, extend); this.extractedData = getExtractedData(chunkIn, biomes, !chunkIn.getWorld().dimension.hasNoLight(), segUpdate);
} }
/** /**
@ -40,10 +40,6 @@ public class SPacketChunkData implements Packet<IClientPlayer>
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();
this.extractedData.extend = new int[buf.readVarIntFromBuffer()];
for(int z = 0; z < this.extractedData.extend.length; z++) {
this.extractedData.extend[z] = buf.readVarIntFromBuffer();
}
} }
/** /**
@ -56,10 +52,6 @@ public class SPacketChunkData implements Packet<IClientPlayer>
buf.writeBoolean(this.biomes); buf.writeBoolean(this.biomes);
buf.writeInt(this.extractedData.dataSize); buf.writeInt(this.extractedData.dataSize);
buf.writeByteArray(this.extractedData.data); buf.writeByteArray(this.extractedData.data);
buf.writeVarIntToBuffer(this.extractedData.extend.length);
for(int z = 0; z < this.extractedData.extend.length; z++) {
buf.writeVarIntToBuffer(this.extractedData.extend[z]);
}
} }
/** /**
@ -84,11 +76,9 @@ public class SPacketChunkData implements Packet<IClientPlayer>
return i + j + k + l; return i + j + k + l;
} }
public static SPacketChunkData.Extracted getExtractedData(Chunk chunk, boolean biomes, boolean overworld, int segUpdate, int[] extend) public static SPacketChunkData.Extracted getExtractedData(Chunk chunk, boolean biomes, boolean overworld, int segUpdate)
{ {
BlockArray[] aextendedblockstorage = chunk.getStorage(); BlockArray[] aextendedblockstorage = chunk.getStorage();
BlockArray[] down = chunk.getStorageDown();
BlockArray[] up = chunk.getStorageUp();
SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted(); SPacketChunkData.Extracted s21packetchunkdata$extracted = new SPacketChunkData.Extracted();
List<BlockArray> list = Lists.<BlockArray>newArrayList(); List<BlockArray> list = Lists.<BlockArray>newArrayList();
@ -102,37 +92,8 @@ public class SPacketChunkData implements Packet<IClientPlayer>
list.add(extendedblockstorage); list.add(extendedblockstorage);
} }
} }
int epos = list.size();
if(extend == null) {
if(down != null) {
for(BlockArray arr : down) {
if(arr != null && (!biomes || !arr.isEmpty()))
list.add(arr);
}
}
if(up != null) {
for(BlockArray arr : up) {
if(arr != null && (!biomes || !arr.isEmpty()))
list.add(arr);
}
}
}
else {
for(int cy : extend) {
if(cy < 0 || cy >= aextendedblockstorage.length) {
BlockArray arr = chunk.getArray(cy);
if(arr != null && (!biomes || !arr.isEmpty()))
list.add(arr);
}
}
}
extend = new int[list.size() - epos];
for(int z = 0; z < extend.length; z++) {
extend[z] = list.get(z + epos).getY();
}
s21packetchunkdata$extracted.extend = extend; s21packetchunkdata$extracted.data = new byte[getSize(Integer.bitCount(s21packetchunkdata$extracted.dataSize), overworld, biomes)];
s21packetchunkdata$extracted.data = new byte[getSize(Integer.bitCount(s21packetchunkdata$extracted.dataSize) + extend.length, overworld, biomes)];
int j = 0; int j = 0;
for (BlockArray extendedblockstorage1 : list) for (BlockArray extendedblockstorage1 : list)
@ -188,11 +149,6 @@ public class SPacketChunkData implements Packet<IClientPlayer>
return this.extractedData.dataSize; return this.extractedData.dataSize;
} }
public int[] getExtractedExtend()
{
return this.extractedData.extend;
}
public boolean hasBiomes() public boolean hasBiomes()
{ {
return this.biomes; return this.biomes;
@ -202,6 +158,5 @@ public class SPacketChunkData implements Packet<IClientPlayer>
{ {
public byte[] data; public byte[] data;
public int dataSize; public int dataSize;
public int[] extend;
} }
} }

View file

@ -30,7 +30,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
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, null); SPacketChunkData.Extracted s21packetchunkdata$extracted = SPacketChunkData.getExtractedData(chunk, true, this.isOverworld, 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;
@ -54,11 +54,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].extend = new int[buf.readVarIntFromBuffer()]; this.chunksData[j].data = new byte[SPacketChunkData.getSize(Integer.bitCount(this.chunksData[j].dataSize), this.isOverworld, true)];
for(int z = 0; z < this.chunksData[j].extend.length; z++) {
this.chunksData[j].extend[z] = buf.readVarIntFromBuffer();
}
this.chunksData[j].data = new byte[SPacketChunkData.getSize(Integer.bitCount(this.chunksData[j].dataSize) + this.chunksData[j].extend.length, this.isOverworld, true)];
} }
for (int k = 0; k < i; ++k) for (int k = 0; k < i; ++k)
@ -80,10 +76,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
buf.writeInt(this.xPositions[i]); buf.writeInt(this.xPositions[i]);
buf.writeInt(this.zPositions[i]); buf.writeInt(this.zPositions[i]);
buf.writeInt(this.chunksData[i].dataSize); buf.writeInt(this.chunksData[i].dataSize);
buf.writeVarIntToBuffer(this.chunksData[i].extend.length);
for(int z = 0; z < this.chunksData[i].extend.length; z++) {
buf.writeVarIntToBuffer(this.chunksData[i].extend[z]);
}
} }
for (int j = 0; j < this.xPositions.length; ++j) for (int j = 0; j < this.xPositions.length; ++j)
@ -124,9 +116,4 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
{ {
return this.chunksData[p_179754_1_].dataSize; return this.chunksData[p_179754_1_].dataSize;
} }
public int[] getChunkExtend(int index)
{
return this.chunksData[index].extend;
}
} }

View file

@ -20,7 +20,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
{ {
} }
public SPacketMultiBlockChange(int p_i45181_1_, long[] crammedPositionsIn, Chunk chunkIn) public SPacketMultiBlockChange(int p_i45181_1_, int[] crammedPositionsIn, Chunk chunkIn)
{ {
this.chunkPosCoord = new ChunkPos(chunkIn.xPos, chunkIn.zPos); this.chunkPosCoord = new ChunkPos(chunkIn.xPos, chunkIn.zPos);
this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[p_i45181_1_]; this.changedBlocks = new SPacketMultiBlockChange.BlockUpdateData[p_i45181_1_];
@ -41,7 +41,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
for (int i = 0; i < this.changedBlocks.length; ++i) for (int i = 0; i < this.changedBlocks.length; ++i)
{ {
this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readLong(), (State)BlockRegistry.STATEMAP.getByValue(buf.readVarIntFromBuffer())); this.changedBlocks[i] = new SPacketMultiBlockChange.BlockUpdateData(buf.readInt(), (State)BlockRegistry.STATEMAP.getByValue(buf.readVarIntFromBuffer()));
} }
} }
@ -56,7 +56,7 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks) for (SPacketMultiBlockChange.BlockUpdateData s22packetmultiblockchange$blockupdatedata : this.changedBlocks)
{ {
buf.writeLong(s22packetmultiblockchange$blockupdatedata.getRawPos()); buf.writeInt(s22packetmultiblockchange$blockupdatedata.getRawPos());
buf.writeVarIntToBuffer(BlockRegistry.STATEMAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState())); buf.writeVarIntToBuffer(BlockRegistry.STATEMAP.get(s22packetmultiblockchange$blockupdatedata.getBlockState()));
} }
} }
@ -76,16 +76,16 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
public class BlockUpdateData public class BlockUpdateData
{ {
private final long position; private final int position;
private final State blockState; private final State blockState;
public BlockUpdateData(long raw, State state) public BlockUpdateData(int raw, State state)
{ {
this.position = raw; this.position = raw;
this.blockState = state; this.blockState = state;
} }
public BlockUpdateData(long raw, Chunk chunkIn) public BlockUpdateData(int raw, Chunk chunkIn)
{ {
this.position = raw; this.position = raw;
this.blockState = chunkIn.getState(this.getPos()); this.blockState = chunkIn.getState(this.getPos());
@ -93,11 +93,11 @@ public class SPacketMultiBlockChange implements Packet<IClientPlayer>
public BlockPos getPos() public BlockPos getPos()
{ {
ChunkPos pos = SPacketMultiBlockChange.this.chunkPosCoord; ChunkPos r = SPacketMultiBlockChange.this.chunkPosCoord;
return new BlockPos(new BlockPos((pos.x << 4) + (int)(this.position >> 36 & 15L), (int)(this.position & 4294967295L), (pos.z << 4) + (int)(this.position >> 32 & 15L))); return new BlockPos(new BlockPos((r.x << 4) + (this.position >> 13 & 15), this.position & 511, (r.z << 4) + (this.position >> 9 & 15)));
} }
public long getRawPos() public int getRawPos()
{ {
return this.position; return this.position;
} }

View file

@ -17,7 +17,7 @@ public class PathCache extends ChunkCache implements IBlockAccess
public State getState(BlockPos pos) public State getState(BlockPos pos)
{ {
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) 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;

View file

@ -78,7 +78,7 @@ public class TileEntityBeacon extends TileEntity implements ITickable
int j = this.pos.getX(); int j = this.pos.getX();
int k = this.pos.getY(); int k = this.pos.getY();
int l = this.pos.getZ(); int l = this.pos.getZ();
BoundingBox axisalignedbb = (new BoundingBox((double)j, (double)k, (double)l, (double)(j + 1), (double)(k + 1), (double)(l + 1))).expand(d0, d0, d0).addCoord(0.0D, (double)World.MAX_SIZE_Y, 0.0D); BoundingBox axisalignedbb = (new BoundingBox((double)j, (double)k, (double)l, (double)(j + 1), (double)(k + 1), (double)(l + 1))).expand(d0, d0, d0).addCoord(0.0D, (double)World.HEIGHT, 0.0D);
List<EntityLiving> list = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb); List<EntityLiving> list = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
for (EntityLiving entityplayer : list) for (EntityLiving entityplayer : list)

View file

@ -8,6 +8,14 @@ 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)
{ {
@ -186,6 +194,19 @@ 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()));

View file

@ -31,8 +31,6 @@ public class Chunk {
public final int xPos; public final int xPos;
public final int zPos; public final int zPos;
private final World world; private final World world;
private final State filler;
private final Block fillerBlock;
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 int[] precHeight = new int[256];
@ -50,24 +48,18 @@ public class Chunk {
private boolean modified; private boolean modified;
private boolean hasEntity; private boolean hasEntity;
private int minHeight; private int minHeight;
private int lightChecks = Integer.MAX_VALUE; private int lightChecks = 8192;
private int bottom = Integer.MAX_VALUE;
private int top = Integer.MIN_VALUE;
private long lastSave; private long lastSave;
private long inhabited; private long inhabited;
private BlockArray[] extendDown;
private BlockArray[] extendUp;
public Chunk(World world, int x, int z) { public Chunk(World world, int x, int z) {
this.world = world; this.world = world;
this.xPos = x; this.xPos = x;
this.zPos = z; this.zPos = z;
this.filler = world.dimension.getFiller();
this.fillerBlock = this.filler.getBlock();
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, -99999999); Arrays.fill(this.precHeight, -999);
Arrays.fill(this.biomes, (byte)-1); Arrays.fill(this.biomes, (byte)-1);
} }
@ -118,8 +110,6 @@ public class Chunk {
for(int n = 0; n < this.biomes.length; ++n) { for(int n = 0; n < this.biomes.length; ++n) {
this.biomes[n] = (byte)biomes[n].id; this.biomes[n] = (byte)biomes[n].id;
} }
this.bottom = height == 0 ? Integer.MAX_VALUE : 0;
this.top = height == 0 ? Integer.MIN_VALUE : (height + 15) >> 4;
if(ceil == null) if(ceil == null)
this.genSkyLight(); this.genSkyLight();
else else
@ -134,110 +124,29 @@ public class Chunk {
return this.height[z << 4 | x]; return this.height[z << 4 | x];
} }
private int findTopSegment() {
if(this.extendUp != null) {
for(int y = this.extendUp.length - 1; y >= 0; --y) {
if(this.extendUp[y] != null)
return this.extendUp[y].getY();
}
}
for(int y = this.blocks.length - 1; y >= 0; --y) {
if(this.blocks[y] != null)
return this.blocks[y].getY();
}
if(this.extendDown != null) {
for(int y = this.extendDown.length - 1; y >= 0; --y) {
if(this.extendDown[y] != null)
return this.extendDown[y].getY();
}
}
return Integer.MIN_VALUE;
}
private int findBottomSegment() {
if(this.extendDown != null) {
for(int y = 0; y < this.extendDown.length; ++y) {
if(this.extendDown[y] != null)
return this.extendDown[y].getY();
}
}
for(int y = 0; y < this.blocks.length; ++y) {
if(this.blocks[y] != null)
return this.blocks[y].getY();
}
if(this.extendUp != null) {
for(int y = 0; y < this.extendUp.length; ++y) {
if(this.extendUp[y] != null)
return this.extendUp[y].getY();
}
}
return Integer.MAX_VALUE;
}
public int getTopSegment() { public int getTopSegment() {
return this.top; for(int y = this.blocks.length - 1; y >= 0; --y) {
if(this.blocks[y] != null) {
return this.blocks[y].getY();
}
} }
public int getBottomSegment() { return 0;
return this.bottom;
} }
public BlockArray[] getStorage() { public BlockArray[] getStorage() {
return this.blocks; return this.blocks;
} }
public BlockArray[] getStorageDown() {
return this.extendDown;
}
public BlockArray[] getStorageUp() {
return this.extendUp;
}
public BlockArray getArray(int y) {
return y >= 0 && y < this.blocks.length ? this.blocks[y] : (y < 0 ? (this.extendDown == null || -y > this.extendDown.length ? null : this.extendDown[-this.extendDown.length - y]) : (this.extendUp == null || y - this.blocks.length >= this.extendUp.length ? null : this.extendUp[y - this.blocks.length]));
}
private void setArray(int y, BlockArray array) {
if(y >= 0 && y < this.blocks.length) {
this.blocks[y] = array;
}
else if(y < 0) {
if(this.extendDown == null) {
this.extendDown = new BlockArray[-y];
}
else if(this.extendDown.length < -y) {
BlockArray[] extendDown = this.extendDown;
this.extendDown = new BlockArray[-y];
System.arraycopy(extendDown, 0, this.extendDown, -y - extendDown.length, extendDown.length);
}
this.extendDown[-this.extendDown.length - y] = array;
}
else {
if(this.extendUp == null) {
this.extendUp = new BlockArray[1 + y - this.blocks.length];
}
else if(this.extendUp.length <= y - this.blocks.length) {
BlockArray[] extendUp = this.extendUp;
this.extendUp = new BlockArray[1 + y - this.blocks.length];
System.arraycopy(extendUp, 0, this.extendUp, 0, extendUp.length);
}
this.extendUp[y - this.blocks.length] = array;
}
this.bottom = this.findBottomSegment();
this.top = this.findTopSegment();
}
protected void genHeights() { protected void genHeights() {
int top = this.getTopSegment(); int h = this.getTopSegment();
int bottom = this.getBottomSegment();
this.minHeight = Integer.MAX_VALUE; this.minHeight = Integer.MAX_VALUE;
for(int x = 0; x < 16; ++x) { for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) { for(int z = 0; z < 16; ++z) {
this.precHeight[x + (z << 4)] = -99999999; this.precHeight[x + (z << 4)] = -999;
for(int y = top + 16; y > bottom; --y) { for(int y = h + 16; y > 0; --y) {
Block block = this.getBlock0(x, y - 1, z); Block block = this.getBlock0(x, y - 1, z);
if(block.getLightOpacity() != 0) { if(block.getLightOpacity() != 0) {
@ -257,15 +166,14 @@ public class Chunk {
} }
public void genSkyLight() { public void genSkyLight() {
int top = this.getTopSegment(); int h = this.getTopSegment();
int bottom = this.getBottomSegment();
this.minHeight = Integer.MAX_VALUE; this.minHeight = Integer.MAX_VALUE;
for(int x = 0; x < 16; ++x) { for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) { for(int z = 0; z < 16; ++z) {
this.precHeight[x + (z << 4)] = -99999999; this.precHeight[x + (z << 4)] = -999;
for(int y = top + 16; y > bottom; --y) { for(int y = h + 16; y > 0; --y) {
if(this.getOpacity(x, y - 1, z) != 0) { if(this.getOpacity(x, y - 1, z) != 0) {
this.height[z << 4 | x] = y; this.height[z << 4 | x] = y;
@ -277,9 +185,9 @@ public class Chunk {
} }
} }
if(!this.world.dimension.hasNoLight() && top != Integer.MIN_VALUE) { if(!this.world.dimension.hasNoLight()) {
int l = 15; int l = 15;
int y = top + 16 - 1; int y = h + 16 - 1;
while(true) { while(true) {
int b = this.getOpacity(x, y, z); int b = this.getOpacity(x, y, z);
@ -291,7 +199,7 @@ public class Chunk {
l -= b; l -= b;
if(l > 0) { if(l > 0) {
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.blocks[y >> 4];
if(stor != null) { if(stor != null) {
stor.setSky(x, y & 15, z, l); stor.setSky(x, y & 15, z, l);
@ -301,7 +209,7 @@ public class Chunk {
--y; --y;
if(y <= bottom || l <= 0) { if(y <= 0 || l <= 0) {
break; break;
} }
} }
@ -377,15 +285,14 @@ public class Chunk {
} }
private void relightBlock(int x, int y, int z) { private void relightBlock(int x, int y, int z) {
int h = this.height[z << 4 | x]; int h = this.height[z << 4 | x] & 511;
int min = this.getBottomSegment();
int cy = h; int cy = h;
if(y > h) { if(y > h) {
cy = y; cy = y;
} }
while(cy > min && this.getOpacity(x, cy - 1, z) == 0) { while(cy > 0 && this.getOpacity(x, cy - 1, z) == 0) {
--cy; --cy;
} }
@ -398,7 +305,7 @@ public class Chunk {
if(!this.world.dimension.hasNoLight()) { if(!this.world.dimension.hasNoLight()) {
if(cy < h) { if(cy < h) {
for(int n = cy; n < h; ++n) { for(int n = cy; n < h; ++n) {
BlockArray stor = this.getArray(n >> 4); BlockArray stor = this.blocks[n >> 4];
if(stor != null) { if(stor != null) {
stor.setSky(x, n & 15, z, 15); stor.setSky(x, n & 15, z, 15);
@ -408,7 +315,7 @@ public class Chunk {
} }
else { else {
for(int n = h; n < cy; ++n) { for(int n = h; n < cy; ++n) {
BlockArray stor = this.getArray(n >> 4); BlockArray stor = this.blocks[n >> 4];
if(stor != null) { if(stor != null) {
stor.setSky(x, n & 15, z, 0); stor.setSky(x, n & 15, z, 0);
@ -419,7 +326,7 @@ public class Chunk {
int l = 15; int l = 15;
while(cy > min && l > 0) { while(cy > 0 && l > 0) {
--cy; --cy;
int b = this.getOpacity(x, cy, z); int b = this.getOpacity(x, cy, z);
@ -433,7 +340,7 @@ public class Chunk {
l = 0; l = 0;
} }
BlockArray stor = this.getArray(cy >> 4); BlockArray stor = this.blocks[cy >> 4];
if(stor != null) { if(stor != null) {
stor.setSky(x, cy & 15, z, l); stor.setSky(x, cy & 15, z, l);
@ -475,46 +382,67 @@ public class Chunk {
} }
private Block getBlock0(int x, int y, int z) { private Block getBlock0(int x, int y, int z) {
Block block = Blocks.air;
if(y >= 0 && y >> 4 < this.blocks.length) { if(y >= 0 && y >> 4 < this.blocks.length) {
BlockArray stor = this.blocks[y >> 4]; BlockArray stor = this.blocks[y >> 4];
return stor != null ? stor.getBlock(x, y & 15, z) : Blocks.air;
if(stor != null) {
block = stor.getBlock(x, y & 15, z);
} }
else if(y < 0 && this.extendDown != null && -(y >> 4) <= this.extendDown.length) {
BlockArray stor = this.extendDown[-this.extendDown.length - (y >> 4)];
return stor != null ? stor.getBlock(x, y & 15, z) : this.fillerBlock;
}
else if(y >> 4 >= this.blocks.length && this.extendUp != null && (y >> 4) - this.blocks.length < this.extendUp.length) {
BlockArray stor = this.extendUp[(y >> 4) - this.blocks.length];
return stor != null ? stor.getBlock(x, y & 15, z) : Blocks.air;
}
return y < 0 ? this.fillerBlock : Blocks.air;
} }
public State getState(BlockPos pos) { return block;
if(this.world.debug) {
State state = pos.getY() == 1 ? DebugStates.getState(pos.getX(), pos.getZ()) : null;
return state == null ? Blocks.air.getState() : state;
}
if(pos.getY() >= 0 && pos.getY() >> 4 < this.blocks.length) {
BlockArray stor = this.blocks[pos.getY() >> 4];
return stor != null ? stor.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15) : Blocks.air.getState();
}
else if(pos.getY() < 0 && this.extendDown != null && -(pos.getY() >> 4) <= this.extendDown.length) {
BlockArray stor = this.extendDown[-this.extendDown.length - (pos.getY() >> 4)];
return stor != null ? stor.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15) : this.filler;
}
else if(pos.getY() >> 4 >= this.blocks.length && this.extendUp != null && (pos.getY() >> 4) - this.blocks.length < this.extendUp.length) {
BlockArray stor = this.extendUp[(pos.getY() >> 4) - this.blocks.length];
return stor != null ? stor.get(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15) : Blocks.air.getState();
}
return pos.getY() < 0 ? this.filler : Blocks.air.getState();
} }
public Block getBlock(BlockPos pos) { public Block getBlock(BlockPos pos) {
return this.getBlock0(pos.getX() & 15, pos.getY(), pos.getZ() & 15); return this.getBlock0(pos.getX() & 15, pos.getY(), pos.getZ() & 15);
} }
public State getState(BlockPos pos) {
if(this.world.debug) {
State state = null;
// if(pos.getY() == 60) {
// state = Blocks.glass.getDefaultState();
// }
if(pos.getY() == 1) {
state = DebugStates.getState(pos.getX(), pos.getZ());
}
return state == null ? Blocks.air.getState() : state;
}
else {
if(pos.getY() >= 0 && pos.getY() >> 4 < this.blocks.length) {
BlockArray stor = this.blocks[pos.getY() >> 4];
if(stor != null) {
int x = pos.getX() & 15;
int y = pos.getY() & 15;
int z = pos.getZ() & 15;
return stor.get(x, y, z);
}
}
return Blocks.air.getState();
}
}
private int getMeta(int x, int y, int z) {
if(y >> 4 >= this.blocks.length) {
return 0;
}
else {
BlockArray stor = this.blocks[y >> 4];
return stor != null ? stor.getMeta(x, y & 15, z) : 0;
}
}
public int getMeta(BlockPos pos) {
return this.getMeta(pos.getX() & 15, pos.getY(), pos.getZ() & 15);
}
public State setState(BlockPos pos, State state) { public State setState(BlockPos pos, State state) {
int x = pos.getX() & 15; int x = pos.getX() & 15;
int y = pos.getY(); int y = pos.getY();
@ -522,7 +450,7 @@ public class Chunk {
int o = z << 4 | x; int o = z << 4 | x;
if(y >= this.precHeight[o] - 1) { if(y >= this.precHeight[o] - 1) {
this.precHeight[o] = -99999999; this.precHeight[o] = -999;
} }
int h = this.height[o]; int h = this.height[o];
@ -534,7 +462,7 @@ public class Chunk {
else { else {
Block block = state.getBlock(); Block block = state.getBlock();
Block oldb = old.getBlock(); Block oldb = old.getBlock();
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.blocks[y >> 4];
boolean up = false; boolean up = false;
if(stor == null) { if(stor == null) {
@ -542,8 +470,7 @@ public class Chunk {
return null; return null;
} }
stor = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight()); stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight());
this.setArray(y >> 4, stor);
up = y >= h; up = y >= h;
} }
@ -599,7 +526,7 @@ public class Chunk {
TileEntity tile = this.getTileEntity(pos, TileEntity.EnumCreateEntityType.CHECK); TileEntity tile = this.getTileEntity(pos, TileEntity.EnumCreateEntityType.CHECK);
if(tile == null) { if(tile == null) {
tile = ((ITileEntityProvider)block).createNewTileEntity(this.world); tile = ((ITileEntityProvider)block).createNewTileEntity(this.world, block.getMetaFromState(state));
this.world.setTileEntity(pos, tile); this.world.setTileEntity(pos, tile);
} }
@ -618,7 +545,7 @@ public class Chunk {
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.getArray(y >> 4); BlockArray stor = this.blocks[y >> 4];
return stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) return stor == null ? (this.canSeeSky(pos) ? type.defValue : 0)
: (type == LightType.SKY ? (this.world.dimension.hasNoLight() ? 0 : stor.getSky(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)); : (type == LightType.BLOCK ? stor.getLight(x, y & 15, z) : type.defValue));
@ -628,11 +555,10 @@ public class Chunk {
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.getArray(y >> 4); BlockArray stor = this.blocks[y >> 4];
if(stor == null) { if(stor == null) {
stor = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight()); stor = this.blocks[y >> 4] = new BlockArray(y >> 4 << 4, !this.world.dimension.hasNoLight());
this.setArray(y >> 4, stor);
this.genSkyLight(); this.genSkyLight();
} }
@ -652,7 +578,7 @@ public class Chunk {
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.getArray(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 < LightType.SKY.defValue
@ -721,7 +647,7 @@ public class Chunk {
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); return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.world, this.getMeta(pos));
} }
public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) { public TileEntity getTileEntity(BlockPos pos, TileEntity.EnumCreateEntityType type) {
@ -879,13 +805,12 @@ public class Chunk {
int o = x | z << 4; int o = x | z << 4;
BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ()); BlockPos loc = new BlockPos(pos.getX(), this.precHeight[o], pos.getZ());
if(loc.getY() == -99999999) { if(loc.getY() == -999) {
int y = this.getTopSegment() + 15; int y = this.getTopSegment() + 15;
int min = this.getBottomSegment();
loc = new BlockPos(pos.getX(), y, pos.getZ()); loc = new BlockPos(pos.getX(), y, pos.getZ());
int h = -1; int h = -1;
while(loc.getY() > min && h == -1) { while(loc.getY() > 0 && h == -1) {
Block block = this.getBlock(loc); Block block = this.getBlock(loc);
Material mat = block.getMaterial(); Material mat = block.getMaterial();
@ -936,8 +861,16 @@ public class Chunk {
} }
public boolean isEmpty(int bottom, int top) { public boolean isEmpty(int bottom, int top) {
if(bottom < 0) {
bottom = 0;
}
if(top >= 512) {
top = 511;
}
for(int y = bottom; y <= top; y += 16) { for(int y = bottom; y <= top; y += 16) {
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.blocks[y >> 4];
if(stor != null && !stor.isEmpty()) { if(stor != null && !stor.isEmpty()) {
return false; return false;
@ -947,7 +880,7 @@ public class Chunk {
return true; return true;
} }
public void setStorage(BlockArray[] arrays, BlockArray[] down, BlockArray[] up) { public void setStorage(BlockArray[] arrays) {
if(this.blocks.length != arrays.length) { if(this.blocks.length != arrays.length) {
Log.JNI.warn("Konnte Sektionen des Chunks nicht setzen, Länge des Arrays ist " + arrays.length + " statt " Log.JNI.warn("Konnte Sektionen des Chunks nicht setzen, Länge des Arrays ist " + arrays.length + " statt "
+ this.blocks.length); + this.blocks.length);
@ -956,14 +889,10 @@ public class Chunk {
for(int n = 0; n < this.blocks.length; ++n) { for(int n = 0; n < this.blocks.length; ++n) {
this.blocks[n] = arrays[n]; this.blocks[n] = arrays[n];
} }
this.extendDown = down;
this.extendUp = up;
this.bottom = this.findBottomSegment();
this.top = this.findTopSegment();
} }
} }
public void setData(byte[] data, int update, int[] extend, boolean biomes) { public void setData(byte[] data, int update, boolean biomes) {
int pos = 0; int pos = 0;
boolean sky = !this.world.dimension.hasNoLight(); boolean sky = !this.world.dimension.hasNoLight();
@ -984,23 +913,6 @@ public class Chunk {
this.blocks[n] = null; this.blocks[n] = null;
} }
} }
if(biomes) {
this.extendDown = null;
this.extendUp = null;
}
for(int cy : extend) {
BlockArray arr = this.getArray(cy);
if(arr == null) {
arr = new BlockArray(cy << 4, sky);
}
char[] blocks = arr.getData();
for(int k = 0; k < blocks.length; ++k) {
blocks[k] = (char)((data[pos + 1] & 255) << 8 | data[pos] & 255);
pos += 2;
}
}
for(int n = 0; n < this.blocks.length; ++n) { for(int n = 0; n < this.blocks.length; ++n) {
if((update & 1 << n) != 0 && this.blocks[n] != null) { if((update & 1 << n) != 0 && this.blocks[n] != null) {
@ -1009,14 +921,6 @@ public class Chunk {
pos += light.getData().length; pos += light.getData().length;
} }
} }
for(int cy : extend) {
BlockArray arr = this.getArray(cy);
if(arr != null) {
NibbleArray light = arr.getBlocklight();
System.arraycopy(data, pos, light.getData(), 0, light.getData().length);
pos += light.getData().length;
}
}
if(sky) { if(sky) {
for(int n = 0; n < this.blocks.length; ++n) { for(int n = 0; n < this.blocks.length; ++n) {
@ -1026,14 +930,6 @@ public class Chunk {
pos += slight.getData().length; pos += slight.getData().length;
} }
} }
for(int cy : extend) {
BlockArray arr = this.getArray(cy);
if(arr != null) {
NibbleArray slight = arr.getSkylight();
System.arraycopy(data, pos, slight.getData(), 0, slight.getData().length);
pos += slight.getData().length;
}
}
} }
if(biomes) { if(biomes) {
@ -1041,20 +937,11 @@ public class Chunk {
// int unk = pos + this.biomes.length; // int unk = pos + this.biomes.length;
} }
this.bottom = this.findBottomSegment();
this.top = this.findTopSegment();
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();
} }
} }
for(int cy : extend) {
BlockArray arr = this.getArray(cy);
if(arr != null) {
arr.update();
}
}
this.lightInit = true; this.lightInit = true;
this.populated = true; this.populated = true;
@ -1109,14 +996,11 @@ public class Chunk {
BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4); BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4);
for(int n = 0; n < 8; ++n) { for(int n = 0; n < 8; ++n) {
if(this.top == Integer.MIN_VALUE) if(this.lightChecks >= 8192)
return;
int h = 1 + this.top - this.bottom;
if(this.lightChecks >= 256 * h)
return; return;
int s = (this.lightChecks % h) + this.bottom; int s = this.lightChecks % 31;
int x = this.lightChecks / h % 16; int x = this.lightChecks / 31 % 16;
int z = this.lightChecks / 512; int z = this.lightChecks / 512;
++this.lightChecks; ++this.lightChecks;
@ -1124,9 +1008,8 @@ public class Chunk {
BlockPos block = pos.add(x, (s << 4) + y, z); BlockPos block = pos.add(x, (s << 4) + y, z);
boolean edge = y == 0 || y == 15 || x == 0 || x == 15 || z == 0 || z == 15; boolean edge = y == 0 || y == 15 || x == 0 || x == 15 || z == 0 || z == 15;
BlockArray arr = this.getArray(s); if(this.blocks[s] == null && edge || this.blocks[s] != null
if(arr == null && edge || arr != null && this.blocks[s].getBlock(x, y, z).getMaterial() == Material.air) {
&& arr.getBlock(x, y, z).getMaterial() == Material.air) {
for(Facing face : Facing.values()) { for(Facing face : Facing.values()) {
BlockPos side = block.offset(face); BlockPos side = block.offset(face);
@ -1209,12 +1092,11 @@ public class Chunk {
private boolean updateColumn(int x, int z) { private boolean updateColumn(int x, int z) {
int top = this.getTopSegment(); int top = this.getTopSegment();
int bottom = this.getBottomSegment();
boolean opaque = false; boolean opaque = false;
boolean below = false; boolean below = false;
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos((this.xPos << 4) + x, 0, (this.zPos << 4) + z); 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 > bottom && !below; --y) { for(int y = top + 16 - 1; y > this.world.getSeaLevel() || y > 0 && !below; --y) {
pos.set(pos.getX(), y, pos.getZ()); pos.set(pos.getX(), y, pos.getZ());
int o = this.getOpacity(pos); int o = this.getOpacity(pos);
@ -1230,7 +1112,7 @@ public class Chunk {
} }
} }
for(int y = pos.getY(); y > bottom; --y) { for(int y = pos.getY(); y > 0; --y) {
pos.set(pos.getX(), y, pos.getZ()); pos.set(pos.getX(), y, pos.getZ());
if(this.getBlock(pos).getLightValue() > 0) { if(this.getBlock(pos).getLightValue() > 0) {

View file

@ -51,7 +51,7 @@ public abstract class World implements IWorldAccess {
} }
public static final float[] MOON_PHASES = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F}; public static final float[] MOON_PHASES = new float[] {1.0F, 0.75F, 0.5F, 0.25F, 0.0F, 0.25F, 0.5F, 0.75F};
public static final int MAX_SIZE = 67108864; public static final int MAX_SIZE = 67108864;
public static final int MAX_SIZE_Y = 4096; public static final int HEIGHT = 512;
public static final long START_TIME = 4385238000L; public static final long START_TIME = 4385238000L;
public static final float ABSOLUTE_ZERO = -273.15f; public static final float ABSOLUTE_ZERO = -273.15f;
// private static final Calendar calendar = Calendar.getInstance(); // private static final Calendar calendar = Calendar.getInstance();
@ -109,7 +109,7 @@ public abstract class World implements IWorldAccess {
public static boolean isValid(BlockPos pos) { public static boolean isValid(BlockPos pos) {
return pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE && return pos.getX() >= -MAX_SIZE && pos.getZ() >= -MAX_SIZE && pos.getX() < MAX_SIZE && pos.getZ() < MAX_SIZE &&
pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y; pos.getY() >= 0 && pos.getY() < 512;
} }
public static boolean isValidXZ(BlockPos pos) { public static boolean isValidXZ(BlockPos pos) {
@ -170,7 +170,7 @@ public abstract class World implements IWorldAccess {
} }
private boolean isAreaLoaded(int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, boolean allowEmpty) { private boolean isAreaLoaded(int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, boolean allowEmpty) {
if(yEnd >= -MAX_SIZE_Y && yStart < MAX_SIZE_Y) { if(yEnd >= 0 && yStart < 512) {
xStart = xStart >> 4; xStart = xStart >> 4;
zStart = zStart >> 4; zStart = zStart >> 4;
xEnd = xEnd >> 4; xEnd = xEnd >> 4;
@ -344,12 +344,12 @@ public abstract class World implements IWorldAccess {
} }
public int getLight(BlockPos pos) { public int getLight(BlockPos pos) {
if(pos.getY() < -MAX_SIZE_Y) { if(pos.getY() < 0) {
return 0; return 0;
} }
else { else {
if(pos.getY() >= MAX_SIZE_Y) { if(pos.getY() >= 512) {
pos = new BlockPos(pos.getX(), MAX_SIZE_Y - 1, pos.getZ()); pos = new BlockPos(pos.getX(), 511, pos.getZ());
} }
return this.getChunk(pos).getLightSub(pos, 0); return this.getChunk(pos).getLightSub(pos, 0);
@ -387,12 +387,12 @@ public abstract class World implements IWorldAccess {
return i1; return i1;
} }
else if(pos.getY() < -MAX_SIZE_Y) { else if(pos.getY() < 0) {
return 0; return 0;
} }
else { else {
if(pos.getY() >= MAX_SIZE_Y) { if(pos.getY() >= 512) {
pos = new BlockPos(pos.getX(), MAX_SIZE_Y - 1, pos.getZ()); pos = new BlockPos(pos.getX(), 511, pos.getZ());
} }
Chunk chunk = this.getChunk(pos); Chunk chunk = this.getChunk(pos);
@ -442,8 +442,8 @@ public abstract class World implements IWorldAccess {
return 0; return 0;
} }
else { else {
if(pos.getY() < -MAX_SIZE_Y) { if(pos.getY() < 0) {
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ()); pos = new BlockPos(pos.getX(), 0, pos.getZ());
} }
if(!isValid(pos)) { if(!isValid(pos)) {
@ -485,8 +485,8 @@ public abstract class World implements IWorldAccess {
} }
public int getLightFor(LightType type, BlockPos pos) { public int getLightFor(LightType type, BlockPos pos) {
if(pos.getY() < -MAX_SIZE_Y) { if(pos.getY() < 0) {
pos = new BlockPos(pos.getX(), -MAX_SIZE_Y, pos.getZ()); pos = new BlockPos(pos.getX(), 0, pos.getZ());
} }
if(!isValid(pos)) { if(!isValid(pos)) {
@ -1593,7 +1593,7 @@ public abstract class World implements IWorldAccess {
return true; return true;
} }
else { else {
if(pos.getY() >= -MAX_SIZE_Y && pos.getY() < MAX_SIZE_Y && this.getLightFor(LightType.BLOCK, pos) < 10) { if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
Block block = this.getState(pos).getBlock(); Block block = this.getState(pos).getBlock();
if((block.getMaterial() == Material.air || (allowLayers && block == Blocks.snow_layer)) if((block.getMaterial() == Material.air || (allowLayers && block == Blocks.snow_layer))

View file

@ -41,6 +41,8 @@ public class ClipboardPlacer {
} }
public void setBlock(BlockPos location, ClipboardBlock block) { public void setBlock(BlockPos location, ClipboardBlock block) {
if(location.getY() < 0 || location.getY() > 511)
return;
Block type = block.getState().getBlock(); Block type = block.getState().getBlock();
if (ReorderRegistry.shouldPlaceLast(type)) { if (ReorderRegistry.shouldPlaceLast(type)) {
// Place torches, etc. last // Place torches, etc. last

View file

@ -74,7 +74,7 @@ public abstract class Command implements Executable {
} }
}, },
new DoubleParser("x", defaulted ? DefType.X : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered), new DoubleParser("x", defaulted ? DefType.X : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered),
new DoubleParser("y", defaulted ? DefType.Y : null, (double)(-World.MAX_SIZE_Y), (double)World.MAX_SIZE_Y, false), new DoubleParser("y", defaulted ? DefType.Y : null, 0.0, (double)World.HEIGHT, false),
new DoubleParser("z", defaulted ? DefType.Z : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered)); new DoubleParser("z", defaulted ? DefType.Z : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE, centered));
} }

View file

@ -970,7 +970,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
if (chunk.isPopulated()) if (chunk.isPopulated())
{ {
list.add(chunk); list.add(chunk);
list1.addAll(((WorldServer)this.entity.worldObj).getTileEntitiesIn(chunkcoordintpair.x * 16, -World.MAX_SIZE_Y, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, World.MAX_SIZE_Y, chunkcoordintpair.z * 16 + 16)); list1.addAll(((WorldServer)this.entity.worldObj).getTileEntitiesIn(chunkcoordintpair.x * 16, 0, chunkcoordintpair.z * 16, chunkcoordintpair.x * 16 + 16, 512, chunkcoordintpair.z * 16 + 16));
iterator1.remove(); iterator1.remove();
} }
} }
@ -985,7 +985,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
{ {
if (list.size() == 1) if (list.size() == 1)
{ {
this.sendPacket(new SPacketChunkData((Chunk)list.get(0), true, 0xffffffff, null)); this.sendPacket(new SPacketChunkData((Chunk)list.get(0), true, 0xffffffff));
} }
else else
{ {
@ -2098,7 +2098,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
float f1 = this.entity.rotYaw; float f1 = this.entity.rotYaw;
float f2 = this.entity.rotPitch; float f2 = this.entity.rotPitch;
if (packetIn.isMoving() && packetIn.getPositionY() == -99999999.0D) if (packetIn.isMoving() && packetIn.getPositionY() == -999.0D)
{ {
packetIn.setMoving(false); packetIn.setMoving(false);
} }
@ -2281,7 +2281,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
{ {
return; return;
} }
else if (blockpos.getY() >= World.MAX_SIZE_Y) else if (blockpos.getY() >= World.HEIGHT)
{ {
return; return;
} }
@ -2345,7 +2345,7 @@ public class Player extends NetHandler implements ICrafting, Executor, IPlayer
this.tryUseItem(itemstack); this.tryUseItem(itemstack);
// } // }
} }
else if (blockpos.getY() < World.MAX_SIZE_Y - 1 || enumfacing != Facing.UP && blockpos.getY() < World.MAX_SIZE_Y) else if (blockpos.getY() < World.HEIGHT - 1 || enumfacing != Facing.UP && blockpos.getY() < World.HEIGHT)
{ {
double max = this.entity.getReachDistance() + 3.0D; double max = this.entity.getReachDistance() + 3.0D;
max *= max; max *= max;

View file

@ -376,22 +376,12 @@ public class Region {
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;
int min = 0;
int max = stor - 1;
for(int n = 0; n < sects.tagCount(); ++n) {
NBTTagCompound sect = sects.getCompoundTagAt(n);
int y = sect.getInteger("Y");
min = y < min ? y : min;
max = y > max ? y : max;
}
BlockArray[] sections = new BlockArray[stor]; BlockArray[] sections = new BlockArray[stor];
BlockArray[] down = min < 0 ? new BlockArray[-min] : null;
BlockArray[] up = max >= stor ? new BlockArray[1 + max - stor] : null;
boolean light = !world.dimension.hasNoLight(); 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.getInteger("Y"); int y = sect.getByte("Y");
BlockArray storage = new BlockArray(y << 4, light); BlockArray storage = new BlockArray(y << 4, light);
byte[] blocks = sect.getByteArray("Blocks"); byte[] blocks = sect.getByteArray("Blocks");
NibbleArray data = new NibbleArray(sect.getByteArray("Data")); NibbleArray data = new NibbleArray(sect.getByteArray("Data"));
@ -414,15 +404,10 @@ public class Region {
} }
storage.update(); storage.update();
if(y >= 0 && y < stor)
sections[y] = storage; sections[y] = storage;
else if(y < 0)
down[-down.length - y] = storage;
else
up[y - stor] = storage;
} }
chunk.setStorage(sections, down, up); chunk.setStorage(sections);
if(tag.hasKey("Biomes", 7)) { if(tag.hasKey("Biomes", 7)) {
chunk.setBiomes(tag.getByteArray("Biomes")); chunk.setBiomes(tag.getByteArray("Biomes"));
@ -510,18 +495,13 @@ public class Region {
tag.setBoolean("LightPopulated", chunk.isLightPopulated()); tag.setBoolean("LightPopulated", chunk.isLightPopulated());
tag.setLong("InhabitedTime", chunk.getInhabited()); tag.setLong("InhabitedTime", chunk.getInhabited());
BlockArray[] sections = chunk.getStorage(); BlockArray[] sections = chunk.getStorage();
BlockArray[] down = chunk.getStorage();
BlockArray[] up = chunk.getStorage();
NBTTagList sects = new NBTTagList(); NBTTagList sects = new NBTTagList();
boolean light = !world.dimension.hasNoLight(); boolean light = !world.dimension.hasNoLight();
for(BlockArray[] sec : new BlockArray[][] {sections, down, up}) { for(BlockArray storage : sections) {
if(sec == null)
continue;
for(BlockArray storage : sec) {
if(storage != null) { if(storage != null) {
NBTTagCompound sect = new NBTTagCompound(); NBTTagCompound sect = new NBTTagCompound();
sect.setInteger("Y", storage.getY() >> 4); sect.setByte("Y", (byte)(storage.getY() >> 4 & 511));
byte[] blocks = new byte[storage.getData().length]; byte[] blocks = new byte[storage.getData().length];
NibbleArray data = new NibbleArray(); NibbleArray data = new NibbleArray();
NibbleArray adddata = null; NibbleArray adddata = null;
@ -563,7 +543,6 @@ public class Region {
sects.appendTag(sect); sects.appendTag(sect);
} }
} }
}
tag.setTag("Sections", sects); tag.setTag("Sections", sects);
tag.setByteArray("Biomes", chunk.getBiomes()); tag.setByteArray("Biomes", chunk.getBiomes());

View file

@ -90,10 +90,13 @@ public abstract class Spawner {
Chunk chunk = world.getChunk(coord.x, coord.z); 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.getTopSegment(); int h = chunk.getHeight(new BlockPos(x, 0, z)) + 1;
if(h == Integer.MIN_VALUE) if(h > 0) {
continue; int m = h % 16;
int y = world.rand.range(chunk.getBottomSegment(), h + 16); h = m == 0 ? h : h + 16 - m;
}
h = h == 0 ? 16 : (h > 0 ? h : chunk.getTopSegment() + 16 - 1);
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();
if(!block.isNormalCube()) { if(!block.isNormalCube()) {

View file

@ -741,7 +741,7 @@ public final class WorldServer extends AWorldServer {
private BlockPos adjustPosToNearbyEntity(BlockPos pos) { private BlockPos adjustPosToNearbyEntity(BlockPos pos) {
BlockPos blockpos = this.getPrecipitationHeight(pos); BlockPos blockpos = this.getPrecipitationHeight(pos);
BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.MAX_SIZE_Y, blockpos.getZ()))).expand(3.0D, BoundingBox axisalignedbb = (new BoundingBox(blockpos, new BlockPos(blockpos.getX(), World.HEIGHT, blockpos.getZ()))).expand(3.0D,
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_) {
@ -2369,7 +2369,7 @@ public final class WorldServer extends AWorldServer {
if(!this.canBurnAt(pos)) { if(!this.canBurnAt(pos)) {
return false; return false;
} }
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y) { if(pos.getY() >= 0 && pos.getY() < 512) {
Block block = this.getState(pos).getBlock(); Block block = this.getState(pos).getBlock();
if(block.getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this, pos)) { if(block.getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this, pos)) {
@ -2385,7 +2385,7 @@ public final class WorldServer extends AWorldServer {
return false; return false;
} }
else { else {
if(pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y && this.getLightFor(LightType.BLOCK, pos) < 10) { if(pos.getY() >= 0 && pos.getY() < 512 && this.getLightFor(LightType.BLOCK, pos) < 10) {
State iblockstate = this.getState(pos); State iblockstate = this.getState(pos);
Block block = iblockstate.getBlock(); Block block = iblockstate.getBlock();
@ -2437,9 +2437,8 @@ public final class WorldServer extends AWorldServer {
Chunk chunk = this.getChunk(pos); Chunk chunk = this.getChunk(pos);
BlockPos blockpos; BlockPos blockpos;
BlockPos blockpos1; BlockPos blockpos1;
int bottom;
for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()), bottom = chunk.getBottomSegment(); blockpos.getY() >= bottom; blockpos = blockpos1) { for(blockpos = new BlockPos(pos.getX(), chunk.getTopSegment() + 16, pos.getZ()); blockpos.getY() >= 0; blockpos = blockpos1) {
blockpos1 = blockpos.down(); blockpos1 = blockpos.down();
Material material = chunk.getBlock(blockpos1).getMaterial(); Material material = chunk.getBlock(blockpos1).getMaterial();
@ -2803,10 +2802,8 @@ public final class WorldServer extends AWorldServer {
private class PlayerInstance { private class PlayerInstance {
private final List<EntityNPC> watching = Lists.<EntityNPC>newArrayList(); private final List<EntityNPC> watching = Lists.<EntityNPC>newArrayList();
private final Set<Integer> extend = Sets.newHashSet();
private final long[] changes = new long[64];
private final ChunkPos position; private final ChunkPos position;
private int[] changes = new int[64];
private int updates; private int updates;
private int sections; private int sections;
private long prevTime; private long prevTime;
@ -2837,7 +2834,7 @@ public final class WorldServer extends AWorldServer {
Chunk chunk = WorldServer.this.getChunk(this.position.x, this.position.z); Chunk chunk = WorldServer.this.getChunk(this.position.x, this.position.z);
if(chunk.isPopulated()) { if(chunk.isPopulated()) {
player.connection.sendPacket(new SPacketChunkData(chunk, true, 0, new int[0])); player.connection.sendPacket(new SPacketChunkData(chunk, true, 0));
} }
this.watching.remove(player); this.watching.remove(player);
@ -2880,13 +2877,10 @@ public final class WorldServer extends AWorldServer {
WorldServer.this.toUpdate.add(this); WorldServer.this.toUpdate.add(this);
} }
if(y >= 0 && y >> 4 < 32)
this.sections |= 1 << (y >> 4); this.sections |= 1 << (y >> 4);
else
this.extend.add(y >> 4);
if(this.updates < 64) { if(this.updates < 64) {
long pos = ((long)x & 4294967295L) << 36 | ((long)z & 4294967295L) << 32 | (y & 4294967295L); int pos = x << 13 | z << 9 | y;
for(int i = 0; i < this.updates; ++i) { for(int i = 0; i < this.updates; ++i) {
if(this.changes[i] == pos) { if(this.changes[i] == pos) {
@ -2911,9 +2905,9 @@ public final class WorldServer extends AWorldServer {
public void onUpdate() { public void onUpdate() {
if(this.updates != 0) { if(this.updates != 0) {
if(this.updates == 1) { if(this.updates == 1) {
int x = (int)(this.changes[0] >> 36 & 15L) + this.position.x * 16; int x = (this.changes[0] >> 13 & 15) + this.position.x * 16;
int y = (int)(this.changes[0] & 4294967295L); int y = this.changes[0] & 511;
int z = (int)(this.changes[0] >> 32 & 15L) + this.position.z * 16; int z = (this.changes[0] >> 9 & 15) + this.position.z * 16;
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
this.sendToAllPlayersWatchingChunk(new SPacketBlockChange(WorldServer.this, pos)); this.sendToAllPlayersWatchingChunk(new SPacketBlockChange(WorldServer.this, pos));
@ -2924,39 +2918,14 @@ public final class WorldServer extends AWorldServer {
else if(this.updates == 64) { else if(this.updates == 64) {
int x = this.position.x * 16; int x = this.position.x * 16;
int z = this.position.z * 16; int z = this.position.z * 16;
int[] extend = null;
if(!this.biomes) {
extend = new int[this.extend.size()];
int n = 0;
for(Integer i : this.extend) {
extend[n++] = i;
}
}
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, extend)); this.biomes, this.sections));
if(this.biomes) {
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, Integer.MIN_VALUE, z, x + 16, Integer.MAX_VALUE, z + 16);
for(int n = 0; n < list.size(); ++n) {
this.sendTileToAllPlayersWatchingChunk(list.get(n));
}
}
else {
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) {
int y = cy << 4; int y = cy << 4;
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, y, z, x + 16, y + 16, z + 16); List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, y, z, x + 16, y + 16, z + 16);
for(int n = 0; n < list.size(); ++n) {
this.sendTileToAllPlayersWatchingChunk(list.get(n));
}
}
}
for(Integer cy : this.extend) {
int y = cy << 4;
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, y, z, x + 16, y + 16, z + 16);
for(int n = 0; n < list.size(); ++n) { for(int n = 0; n < list.size(); ++n) {
this.sendTileToAllPlayersWatchingChunk(list.get(n)); this.sendTileToAllPlayersWatchingChunk(list.get(n));
} }
@ -2968,9 +2937,9 @@ public final class WorldServer extends AWorldServer {
WorldServer.this.getChunk(this.position.x, this.position.z))); WorldServer.this.getChunk(this.position.x, this.position.z)));
for(int n = 0; n < this.updates; ++n) { for(int n = 0; n < this.updates; ++n) {
int x = (int)(this.changes[n] >> 36 & 15L) + this.position.x * 16; int x = (this.changes[n] >> 13 & 15) + this.position.x * 16;
int y = (int)(this.changes[n] & 4294967295L); int y = this.changes[n] & 511;
int z = (int)(this.changes[n] >> 32 & 15L) + this.position.z * 16; int z = (this.changes[n] >> 9 & 15) + this.position.z * 16;
BlockPos pos = new BlockPos(x, y, z); BlockPos pos = new BlockPos(x, y, z);
if(WorldServer.this.getState(pos).getBlock().hasTileEntity()) { if(WorldServer.this.getState(pos).getBlock().hasTileEntity()) {
@ -2981,7 +2950,6 @@ public final class WorldServer extends AWorldServer {
this.updates = 0; this.updates = 0;
this.sections = 0; this.sections = 0;
this.extend.clear();
this.biomes = false; this.biomes = false;
} }
} }