2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
2015-05-18 00:02:28 +02:00
|
|
|
* Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
|
2014-11-14 12:02:52 +01:00
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
package appeng.spatial;
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.ChunkPosition;
|
|
|
|
import net.minecraft.world.NextTickListEntry;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraft.world.chunk.Chunk;
|
|
|
|
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2014-12-29 21:59:05 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.AEApi;
|
2015-01-03 02:53:14 +01:00
|
|
|
import appeng.api.definitions.IBlockDefinition;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.movable.IMovableHandler;
|
|
|
|
import appeng.api.movable.IMovableRegistry;
|
|
|
|
import appeng.api.util.WorldCoord;
|
|
|
|
import appeng.core.AELog;
|
2014-03-06 06:45:14 +01:00
|
|
|
import appeng.core.WorldSettings;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.util.Platform;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
public class CachedPlane
|
|
|
|
{
|
2014-09-29 09:54:34 +02:00
|
|
|
final int x_size;
|
|
|
|
final int z_size;
|
|
|
|
final int cx_size;
|
|
|
|
final int cz_size;
|
|
|
|
final int x_offset;
|
|
|
|
final int y_offset;
|
|
|
|
final int z_offset;
|
|
|
|
final int y_size;
|
|
|
|
final Chunk[][] myChunks;
|
|
|
|
final Column[][] myColumns;
|
|
|
|
final LinkedList<TileEntity> tiles = new LinkedList<TileEntity>();
|
|
|
|
final LinkedList<NextTickListEntry> ticks = new LinkedList<NextTickListEntry>();
|
|
|
|
final World world;
|
|
|
|
final IMovableRegistry reg = AEApi.instance().registries().movable();
|
|
|
|
final LinkedList<WorldCoord> updates = new LinkedList<WorldCoord>();
|
2015-01-03 02:53:14 +01:00
|
|
|
private final IBlockDefinition matrixFrame = AEApi.instance().definitions().blocks().matrixFrame();
|
|
|
|
int verticalBits;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
public CachedPlane( World w, int minX, int minY, int minZ, int maxX, int maxY, int maxZ )
|
|
|
|
{
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.world = w;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.x_size = maxX - minX + 1;
|
|
|
|
this.y_size = maxY - minY + 1;
|
|
|
|
this.z_size = maxZ - minZ + 1;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.x_offset = minX;
|
|
|
|
this.y_offset = minY;
|
|
|
|
this.z_offset = minZ;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
int minCX = minX >> 4;
|
|
|
|
int minCY = minY >> 4;
|
|
|
|
int minCZ = minZ >> 4;
|
|
|
|
int maxCX = maxX >> 4;
|
|
|
|
int maxCY = maxY >> 4;
|
|
|
|
int maxCZ = maxZ >> 4;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cx_size = maxCX - minCX + 1;
|
2013-12-27 23:59:59 +01:00
|
|
|
int cy_size = maxCY - minCY + 1;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.cz_size = maxCZ - minCZ + 1;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myChunks = new Chunk[this.cx_size][this.cz_size];
|
|
|
|
this.myColumns = new Column[this.x_size][this.z_size];
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.verticalBits = 0;
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int cy = 0; cy < cy_size; cy++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.verticalBits |= 1 << ( minCY + cy );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < this.x_size; x++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = 0; z < this.z_size; z++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.myColumns[x][z] = new Column( w.getChunkFromChunkCoords( ( minX + x ) >> 4, ( minZ + z ) >> 4 ), ( minX + x ) & 0xF, ( minZ + z ) & 0xF, minCY, cy_size );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-09-20 22:37:58 +02:00
|
|
|
IMovableRegistry mr = AEApi.instance().registries().movable();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int cx = 0; cx < this.cx_size; cx++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int cz = 0; cz < this.cz_size; cz++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-11-04 12:32:33 +01:00
|
|
|
LinkedList<Entry<ChunkPosition, TileEntity>> rawTiles = new LinkedList<Entry<ChunkPosition, TileEntity>>();
|
2013-12-27 23:59:59 +01:00
|
|
|
LinkedList<ChunkPosition> deadTiles = new LinkedList<ChunkPosition>();
|
|
|
|
|
|
|
|
Chunk c = w.getChunkFromChunkCoords( minCX + cx, minCZ + cz );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myChunks[cx][cz] = c;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
rawTiles.addAll( ( (HashMap<ChunkPosition, TileEntity>) c.chunkTileEntityMap ).entrySet() );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( Entry<ChunkPosition, TileEntity> tx : rawTiles )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
ChunkPosition cp = tx.getKey();
|
|
|
|
TileEntity te = tx.getValue();
|
2015-04-03 08:54:31 +02:00
|
|
|
if( te.xCoord >= minX && te.xCoord <= maxX && te.yCoord >= minY && te.yCoord <= maxY && te.zCoord >= minZ && te.zCoord <= maxZ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( mr.askToMove( te ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.tiles.add( te );
|
2013-12-27 23:59:59 +01:00
|
|
|
deadTiles.add( cp );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Object[] details = this.myColumns[te.xCoord - minX][te.zCoord - minZ].getDetails( te.yCoord );
|
2014-02-09 02:34:52 +01:00
|
|
|
Block blk = (Block) details[0];
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-09-28 11:47:17 +02:00
|
|
|
// don't skip air, just let the code replace it...
|
2015-04-03 08:54:31 +02:00
|
|
|
if( blk != null && blk.isAir( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) && blk.isReplaceable( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-05-08 23:37:09 +02:00
|
|
|
c.worldObj.setBlock( te.xCoord, te.yCoord, te.zCoord, Platform.AIR_BLOCK );
|
|
|
|
c.worldObj.notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.AIR_BLOCK );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
else
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.myColumns[te.xCoord - minX][te.zCoord - minZ].setSkip( te.yCoord );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ChunkPosition cp : deadTiles )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
c.chunkTileEntityMap.remove( cp );
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
long k = this.world.getTotalWorldTime();
|
|
|
|
List list = this.world.getPendingBlockUpdates( c, false );
|
2015-04-03 08:54:31 +02:00
|
|
|
if( list != null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( Object o : list )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
NextTickListEntry entry = (NextTickListEntry) o;
|
2015-04-03 08:54:31 +02:00
|
|
|
if( entry.xCoord >= minX && entry.xCoord <= maxX && entry.yCoord >= minY && entry.yCoord <= maxY && entry.zCoord >= minZ && entry.zCoord <= maxZ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-09-28 11:47:17 +02:00
|
|
|
NextTickListEntry newEntry = new NextTickListEntry( entry.xCoord, entry.yCoord, entry.zCoord, entry.func_151351_a() );
|
|
|
|
newEntry.scheduledTime = entry.scheduledTime - k;
|
2014-12-29 15:13:47 +01:00
|
|
|
this.ticks.add( newEntry );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( TileEntity te : this.tiles )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.world.loadedTileEntityList.remove( te );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( Exception e )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( e );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private IMovableHandler getHandler( TileEntity te )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-09-20 22:37:58 +02:00
|
|
|
IMovableRegistry mr = AEApi.instance().registries().movable();
|
2013-12-27 23:59:59 +01:00
|
|
|
return mr.getHandler( te );
|
|
|
|
}
|
|
|
|
|
2015-05-18 00:02:28 +02:00
|
|
|
void swap( CachedPlane dst )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-09-20 22:37:58 +02:00
|
|
|
IMovableRegistry mr = AEApi.instance().registries().movable();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( dst.x_size == this.x_size && dst.y_size == this.y_size && dst.z_size == this.z_size )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
AELog.info( "Block Copy Scale: " + this.x_size + ", " + this.y_size + ", " + this.z_size );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
long startTime = System.nanoTime();
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < this.x_size; x++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = 0; z < this.z_size; z++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Column a = this.myColumns[x][z];
|
2013-12-27 23:59:59 +01:00
|
|
|
Column b = dst.myColumns[x][z];
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int y = 0; y < this.y_size; y++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
int src_y = y + this.y_offset;
|
2013-12-27 23:59:59 +01:00
|
|
|
int dst_y = y + dst.y_offset;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( a.doNotSkip( src_y ) && b.doNotSkip( dst_y ) )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-09 02:34:52 +01:00
|
|
|
Object[] aD = a.getDetails( src_y );
|
|
|
|
Object[] bD = b.getDetails( dst_y );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
a.setBlockIDWithMetadata( src_y, bD );
|
|
|
|
b.setBlockIDWithMetadata( dst_y, aD );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.markForUpdate( x + this.x_offset, src_y, z + this.z_offset );
|
2013-12-27 23:59:59 +01:00
|
|
|
dst.markForUpdate( x + dst.x_offset, dst_y, z + dst.z_offset );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
long endTime = System.nanoTime();
|
|
|
|
long duration = endTime - startTime;
|
|
|
|
AELog.info( "Block Copy Time: " + duration );
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( TileEntity te : this.tiles )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
dst.addTile( te.xCoord - this.x_offset, te.yCoord - this.y_offset, te.zCoord - this.z_offset, te, this, mr );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( TileEntity te : dst.tiles )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addTile( te.xCoord - dst.x_offset, te.yCoord - dst.y_offset, te.zCoord - dst.z_offset, te, dst, mr );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( NextTickListEntry entry : this.ticks )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
dst.addTick( entry.xCoord - this.x_offset, entry.yCoord - this.y_offset, entry.zCoord - this.z_offset, entry );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( NextTickListEntry entry : dst.ticks )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addTick( entry.xCoord - dst.x_offset, entry.yCoord - dst.y_offset, entry.zCoord - dst.z_offset, entry );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
startTime = System.nanoTime();
|
2014-12-29 15:13:47 +01:00
|
|
|
this.updateChunks();
|
2013-12-27 23:59:59 +01:00
|
|
|
dst.updateChunks();
|
|
|
|
endTime = System.nanoTime();
|
|
|
|
|
|
|
|
duration = endTime - startTime;
|
|
|
|
AELog.info( "Update Time: " + duration );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
private void markForUpdate( int x, int y, int z )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2015-05-08 23:25:19 +02:00
|
|
|
this.updates.add( new WorldCoord( x, y, z ) );
|
2015-04-03 08:54:31 +02:00
|
|
|
for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-05-08 23:25:19 +02:00
|
|
|
this.updates.add( new WorldCoord( x + d.offsetX, y + d.offsetY, z + d.offsetZ ) );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private void addTick( int x, int y, int z, NextTickListEntry entry )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.world.scheduleBlockUpdate( x + this.x_offset, y + this.y_offset, z + this.z_offset, entry.func_151351_a(), (int) entry.scheduledTime );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private void addTile( int x, int y, int z, TileEntity te, CachedPlane alternateDestination, IMovableRegistry mr )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Column c = this.myColumns[x][z];
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( c.doNotSkip( y + this.y_offset ) || alternateDestination == null )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
IMovableHandler handler = this.getHandler( te );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
handler.moveTile( te, this.world, x + this.x_offset, y + this.y_offset, z + this.z_offset );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( Throwable e )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( e );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
// attempt recovery...
|
2014-12-29 15:13:47 +01:00
|
|
|
te.setWorldObj( this.world );
|
2013-12-27 23:59:59 +01:00
|
|
|
te.xCoord = x;
|
|
|
|
te.yCoord = y;
|
|
|
|
te.zCoord = z;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
c.c.func_150812_a( c.x, y + y, c.z, te );
|
|
|
|
// c.c.setChunkTileEntity( c.x, y + y, c.z, te );
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
if( c.c.isChunkLoaded )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.world.addTileEntity( te );
|
|
|
|
this.world.markBlockForUpdate( x, y, z );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mr.doneMoving( te );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-11-04 12:32:33 +01:00
|
|
|
alternateDestination.addTile( x, y, z, te, null, mr );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
2015-04-03 08:54:31 +02:00
|
|
|
catch( Throwable e )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-02-07 21:37:22 +01:00
|
|
|
AELog.error( e );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateChunks()
|
|
|
|
{
|
|
|
|
|
|
|
|
// update shit..
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < this.cx_size; x++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = 0; z < this.cz_size; z++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
Chunk c = this.myChunks[x][z];
|
2013-12-27 23:59:59 +01:00
|
|
|
c.resetRelightChecks();
|
|
|
|
c.generateSkylightMap();
|
|
|
|
c.isModified = true;
|
|
|
|
}
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
// send shit...
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int x = 0; x < this.cx_size; x++ )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int z = 0; z < this.cz_size; z++ )
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
Chunk c = this.myChunks[x][z];
|
2014-03-05 08:27:42 +01:00
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int y = 1; y < 255; y += 32 )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
WorldSettings.getInstance().getCompass().updateArea( this.world, c.xPosition << 4, y, c.zPosition << 4 );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2014-03-06 06:45:14 +01:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
Platform.sendChunk( c, this.verticalBits );
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
class Column
|
|
|
|
{
|
|
|
|
|
|
|
|
private final int x;
|
|
|
|
private final int z;
|
|
|
|
private final Chunk c;
|
|
|
|
private final Object[] ch = { 0, 0, 0 };
|
|
|
|
private final ExtendedBlockStorage[] storage;
|
|
|
|
private List<Integer> skipThese = null;
|
|
|
|
|
2015-05-08 23:25:19 +02:00
|
|
|
public Column( Chunk chunk, int x, int z, int chunkY, int chunkHeight )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-05-08 23:25:19 +02:00
|
|
|
this.x = x;
|
|
|
|
this.z = z;
|
|
|
|
this.c = chunk;
|
2015-01-03 02:53:14 +01:00
|
|
|
this.storage = this.c.getBlockStorageArray();
|
|
|
|
|
|
|
|
// make sure storage exists before hand...
|
2015-04-03 08:54:31 +02:00
|
|
|
for( int ay = 0; ay < chunkHeight; ay++ )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-05-08 23:25:19 +02:00
|
|
|
int by = ( ay + chunkY );
|
2015-01-03 02:53:14 +01:00
|
|
|
ExtendedBlockStorage extendedblockstorage = this.storage[by];
|
2015-04-03 08:54:31 +02:00
|
|
|
if( extendedblockstorage == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
extendedblockstorage = this.storage[by] = new ExtendedBlockStorage( by << 4, !this.c.worldObj.provider.hasNoSky );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
public void setBlockIDWithMetadata( int y, Object[] blk )
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
for( Block matrixFrameBlock : CachedPlane.this.matrixFrame.maybeBlock().asSet() )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( blk[0] == matrixFrameBlock )
|
2015-01-03 02:53:14 +01:00
|
|
|
{
|
2015-05-08 23:37:09 +02:00
|
|
|
blk[0] = Platform.AIR_BLOCK;
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
ExtendedBlockStorage extendedBlockStorage = this.storage[y >> 4];
|
|
|
|
extendedBlockStorage.func_150818_a( this.x, y & 15, this.z, (Block) blk[0] );
|
|
|
|
// extendedBlockStorage.setExtBlockID( x, y & 15, z, blk[0] );
|
|
|
|
extendedBlockStorage.setExtBlockMetadata( this.x, y & 15, this.z, (Integer) blk[1] );
|
|
|
|
extendedBlockStorage.setExtBlocklightValue( this.x, y & 15, this.z, (Integer) blk[2] );
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object[] getDetails( int y )
|
|
|
|
{
|
|
|
|
ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4];
|
|
|
|
this.ch[0] = extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z );
|
|
|
|
this.ch[1] = extendedblockstorage.getExtBlockMetadata( this.x, y & 15, this.z );
|
|
|
|
this.ch[2] = extendedblockstorage.getExtBlocklightValue( this.x, y & 15, this.z );
|
|
|
|
return this.ch;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean doNotSkip( int y )
|
|
|
|
{
|
|
|
|
ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4];
|
2015-04-03 08:54:31 +02:00
|
|
|
if( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ) ) )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return false;
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
|
|
|
|
return this.skipThese == null || !this.skipThese.contains( y );
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSkip( int yCoord )
|
|
|
|
{
|
2015-04-03 08:54:31 +02:00
|
|
|
if( this.skipThese == null )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
this.skipThese = new LinkedList<Integer>();
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-01-03 02:53:14 +01:00
|
|
|
this.skipThese.add( yCoord );
|
|
|
|
}
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|