Ported to 1.7
This commit is contained in:
+35
-31
@@ -7,22 +7,19 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.network.packet.Packet51MapChunk;
|
||||
import net.minecraft.server.management.PlayerInstance;
|
||||
import net.minecraft.server.management.PlayerManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.NextTickListEntry;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.movable.IMovableHandler;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.core.AELog;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class CachedPlane
|
||||
{
|
||||
@@ -33,7 +30,7 @@ public class CachedPlane
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final Chunk c;
|
||||
private final int ch[] = { 0, 0, 0 };
|
||||
private final Object ch[] = { 0, 0, 0 };
|
||||
private List<Integer> skipThese = null;
|
||||
|
||||
private ExtendedBlockStorage[] storage;
|
||||
@@ -54,18 +51,19 @@ public class CachedPlane
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlockIDWithMetadata(int y, int[] blk)
|
||||
public void setBlockIDWithMetadata(int y, Object[] blk)
|
||||
{
|
||||
ExtendedBlockStorage extendedblockstorage = storage[y >> 4];
|
||||
extendedblockstorage.setExtBlockID( x, y & 15, z, blk[0] );
|
||||
extendedblockstorage.setExtBlockMetadata( x, y & 15, z, blk[1] );
|
||||
extendedblockstorage.setExtBlocklightValue( x, y & 15, z, blk[2] );
|
||||
extendedblockstorage.func_150818_a( x, y & 15, z, (Block) blk[0] );
|
||||
// extendedblockstorage.setExtBlockID( x, y & 15, z, blk[0] );
|
||||
extendedblockstorage.setExtBlockMetadata( x, y & 15, z, (Integer) blk[1] );
|
||||
extendedblockstorage.setExtBlocklightValue( x, y & 15, z, (Integer) blk[2] );
|
||||
}
|
||||
|
||||
public int[] getDetails(int y)
|
||||
public Object[] getDetails(int y)
|
||||
{
|
||||
ExtendedBlockStorage extendedblockstorage = storage[y >> 4];
|
||||
ch[0] = extendedblockstorage.getExtBlockID( x, y & 15, z );
|
||||
ch[0] = extendedblockstorage.getBlockByExtId( x, y & 15, z );
|
||||
ch[1] = extendedblockstorage.getExtBlockMetadata( x, y & 15, z );
|
||||
ch[2] = extendedblockstorage.getExtBlocklightValue( x, y & 15, z );
|
||||
return ch;
|
||||
@@ -172,15 +170,15 @@ public class CachedPlane
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] details = myColumns[te.xCoord - minx][te.zCoord - minz].getDetails( te.yCoord );
|
||||
Block blk = Block.blocksList[details[0]];
|
||||
Object[] details = myColumns[te.xCoord - minx][te.zCoord - minz].getDetails( te.yCoord );
|
||||
Block blk = (Block) details[0];
|
||||
|
||||
// don't skip air, juset let the code replace it...
|
||||
if ( blk != null && blk.isAirBlock( c.worldObj, te.xCoord, te.yCoord, te.zCoord )
|
||||
&& blk.isBlockReplaceable( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) )
|
||||
if ( blk != null && blk.isAir( c.worldObj, te.xCoord, te.yCoord, te.zCoord )
|
||||
&& blk.isReplaceable( c.worldObj, te.xCoord, te.yCoord, te.zCoord ) )
|
||||
{
|
||||
c.worldObj.setBlock( te.xCoord, te.yCoord, te.zCoord, 0 );
|
||||
c.worldObj.notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, 0 );
|
||||
c.worldObj.setBlock( te.xCoord, te.yCoord, te.zCoord, Platform.air );
|
||||
c.worldObj.notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.air );
|
||||
}
|
||||
else
|
||||
myColumns[te.xCoord - minx][te.zCoord - minz].setSkip( te.yCoord );
|
||||
@@ -200,9 +198,10 @@ public class CachedPlane
|
||||
for (Object o : list)
|
||||
{
|
||||
NextTickListEntry ntle = (NextTickListEntry) o;
|
||||
if ( ntle.xCoord >= minx && ntle.xCoord <= maxx && ntle.yCoord >= miny && ntle.yCoord <= maxy && ntle.zCoord >= minz && ntle.zCoord <= maxz )
|
||||
if ( ntle.xCoord >= minx && ntle.xCoord <= maxx && ntle.yCoord >= miny && ntle.yCoord <= maxy && ntle.zCoord >= minz
|
||||
&& ntle.zCoord <= maxz )
|
||||
{
|
||||
NextTickListEntry newEntry = new NextTickListEntry( ntle.xCoord, ntle.yCoord, ntle.zCoord, ntle.blockID );
|
||||
NextTickListEntry newEntry = new NextTickListEntry( ntle.xCoord, ntle.yCoord, ntle.zCoord, ntle.func_151351_a() );
|
||||
newEntry.scheduledTime = ntle.scheduledTime - k;
|
||||
ticks.add( newEntry );
|
||||
}
|
||||
@@ -254,8 +253,8 @@ public class CachedPlane
|
||||
|
||||
if ( a.dontSkip( src_y ) && b.dontSkip( dst_y ) )
|
||||
{
|
||||
int[] aD = a.getDetails( src_y );
|
||||
int[] bD = b.getDetails( dst_y );
|
||||
Object[] aD = a.getDetails( src_y );
|
||||
Object[] bD = b.getDetails( dst_y );
|
||||
|
||||
a.setBlockIDWithMetadata( src_y, bD );
|
||||
b.setBlockIDWithMetadata( dst_y, aD );
|
||||
@@ -313,7 +312,7 @@ public class CachedPlane
|
||||
|
||||
private void addTick(int x, int y, int z, NextTickListEntry ntle)
|
||||
{
|
||||
wrld.scheduleBlockUpdate( x + x_offset, y + y_offset, z + z_offset, ntle.blockID, (int) ntle.scheduledTime );
|
||||
wrld.scheduleBlockUpdate( x + x_offset, y + y_offset, z + z_offset, ntle.func_151351_a(), (int) ntle.scheduledTime );
|
||||
}
|
||||
|
||||
private void addTile(int x, int y, int z, TileEntity te, CachedPlane alernateDest, IMovableRegistry mr)
|
||||
@@ -335,12 +334,13 @@ public class CachedPlane
|
||||
AELog.error( e );
|
||||
|
||||
// attempt recovery...
|
||||
te.worldObj = wrld;
|
||||
te.setWorldObj( wrld );
|
||||
te.xCoord = x;
|
||||
te.yCoord = y;
|
||||
te.zCoord = z;
|
||||
|
||||
c.c.setChunkBlockTileEntity( c.x, y + y, c.z, te );
|
||||
c.c.func_150812_a( c.x, y + y, c.z, te );
|
||||
// c.c.setChunkTileEntity( c.x, y + y, c.z, te );
|
||||
|
||||
if ( c.c.isChunkLoaded )
|
||||
{
|
||||
@@ -384,14 +384,18 @@ public class CachedPlane
|
||||
for (int x = 0; x < cx_size; x++)
|
||||
for (int z = 0; z < cz_size; z++)
|
||||
{
|
||||
Chunk c = myChunks[x][z];
|
||||
|
||||
WorldServer ws = (WorldServer) c.worldObj;
|
||||
PlayerManager pm = ws.getPlayerManager();
|
||||
PlayerInstance playerinstance = pm.getOrCreateChunkWatcher( c.xPosition, c.zPosition, false );
|
||||
// TODO: Fix?
|
||||
|
||||
if ( playerinstance != null )
|
||||
playerinstance.sendToAllPlayersWatchingChunk( new Packet51MapChunk( c, false, verticalBits ) );
|
||||
/*
|
||||
* Chunk c = myChunks[x][z];
|
||||
*
|
||||
* WorldServer ws = (WorldServer) c.worldObj; PlayerManager pm = ws.getPlayerManager(); PlayerInstance
|
||||
* playerinstance = pm.getOrCreateChunkWatcher( c.xPosition, c.zPosition, false );
|
||||
*
|
||||
* if ( playerinstance != null ) playerinstance.sendToAllPlayersWatchingChunk( new Packet51MapChunk( c,
|
||||
* false, verticalBits ) );
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,14 @@ public class DefaultSpatialHandler implements IMovableHandler
|
||||
public void moveTile(TileEntity te, World w, int x, int y, int z)
|
||||
{
|
||||
|
||||
te.worldObj = w;
|
||||
te.setWorldObj( w );
|
||||
te.xCoord = x;
|
||||
te.yCoord = y;
|
||||
te.zCoord = z;
|
||||
|
||||
Chunk c = w.getChunkFromBlockCoords( x, z );
|
||||
c.setChunkBlockTileEntity( x & 0xF, y, z & 0xF, te );
|
||||
c.func_150812_a( x & 0xF, y, z & 0xF, te );
|
||||
// c.setChunkBlockTileEntity( x & 0xF, y, z & 0xF, te );
|
||||
|
||||
if ( c.isChunkLoaded )
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
@@ -29,10 +28,7 @@ public class StorageChunkProvider extends ChunkProviderGenerate implements IChun
|
||||
@Override
|
||||
public Chunk provideChunk(int x, int z)
|
||||
{
|
||||
|
||||
byte[] data = new byte[32768];
|
||||
|
||||
Chunk chunk = new Chunk( w, data, x, z );
|
||||
Chunk chunk = new Chunk( w, x, z );
|
||||
|
||||
if ( !chunk.isTerrainPopulated )
|
||||
{
|
||||
@@ -55,10 +51,4 @@ public class StorageChunkProvider extends ChunkProviderGenerate implements IChun
|
||||
return new ArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkPosition findClosestStructure(World par1World, String par2Str, int par3, int par4, int par5)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-13
@@ -15,6 +15,7 @@ import net.minecraft.world.WorldServer;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.block.solids.BlockMatrixFrame;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class StorageHelper
|
||||
{
|
||||
@@ -40,9 +41,8 @@ public class StorageHelper
|
||||
@Override
|
||||
public void visit(int x, int y, int z)
|
||||
{
|
||||
int blk = dst.getBlockId( x, y, z );
|
||||
if ( blk > 0 )
|
||||
Block.blocksList[blk].onNeighborBlockChange( dst, x, y, z, 0 );
|
||||
Block blk = dst.getBlock( x, y, z );
|
||||
blk.onNeighborBlockChange( dst, x, y, z, Platform.air );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -50,9 +50,10 @@ public class StorageHelper
|
||||
{
|
||||
|
||||
World dst;
|
||||
int blkID, Meta;
|
||||
Block blkID;
|
||||
int Meta;
|
||||
|
||||
public WrapInMatrixFrame(int blockID, int metaData, World dst2) {
|
||||
public WrapInMatrixFrame(Block blockID, int metaData, World dst2) {
|
||||
dst = dst2;
|
||||
blkID = blockID;
|
||||
Meta = metaData;
|
||||
@@ -178,7 +179,8 @@ public class StorageHelper
|
||||
oldWorld.getChunkFromChunkCoords( entX, entZ ).isModified = true;
|
||||
}
|
||||
|
||||
oldWorld.onEntityRemoved( entity );
|
||||
// TODO: Fix?
|
||||
// oldWorld.onEntityRemoved( entity );
|
||||
|
||||
if ( player == null ) // Are we NOT working with a player?
|
||||
{
|
||||
@@ -215,7 +217,8 @@ public class StorageHelper
|
||||
|
||||
if ( player != null )
|
||||
{
|
||||
WorldServer.class.cast( newWorld ).getChunkProvider().loadChunk( MathHelper.floor_double( entity.posX ) >> 4, MathHelper.floor_double( entity.posZ ) >> 4 );
|
||||
WorldServer.class.cast( newWorld ).getChunkProvider()
|
||||
.loadChunk( MathHelper.floor_double( entity.posX ) >> 4, MathHelper.floor_double( entity.posZ ) >> 4 );
|
||||
}
|
||||
|
||||
return entity;
|
||||
@@ -252,7 +255,7 @@ public class StorageHelper
|
||||
{
|
||||
BlockMatrixFrame blkMF = (BlockMatrixFrame) AEApi.instance().blocks().blockMatrixFrame.block();
|
||||
|
||||
transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( blkMF.blockID, 0, dst ) );
|
||||
transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new WrapInMatrixFrame( blkMF, 0, dst ) );
|
||||
|
||||
AxisAlignedBB srcBox = AxisAlignedBB.getBoundingBox( x, y, z, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1 );
|
||||
|
||||
@@ -278,10 +281,10 @@ public class StorageHelper
|
||||
}
|
||||
|
||||
for (WorldCoord wc : cDst.updates)
|
||||
cDst.wrld.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, 0 );
|
||||
cDst.wrld.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, Platform.air );
|
||||
|
||||
for (WorldCoord wc : cSrc.updates)
|
||||
cSrc.wrld.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, 0 );
|
||||
cSrc.wrld.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, Platform.air );
|
||||
|
||||
transverseEdges( x - 1, y - 1, z - 1, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1, new triggerUpdates( src ) );
|
||||
transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new triggerUpdates( dst ) );
|
||||
@@ -290,9 +293,8 @@ public class StorageHelper
|
||||
transverseEdges( i, j, k, i + scaleX, j + scaleY, k + scaleZ, new triggerUpdates( dst ) );
|
||||
|
||||
/*
|
||||
* IChunkProvider cp = dest.getChunkProvider(); if ( cp instanceof
|
||||
* ChunkProviderServer ) { ChunkProviderServer srv =
|
||||
* (ChunkProviderServer) cp; srv.unloadAllChunks(); }
|
||||
* IChunkProvider cp = dest.getChunkProvider(); if ( cp instanceof ChunkProviderServer ) { ChunkProviderServer
|
||||
* srv = (ChunkProviderServer) cp; srv.unloadAllChunks(); }
|
||||
*
|
||||
* cp.unloadQueuedChunks();
|
||||
*/
|
||||
|
||||
@@ -33,7 +33,7 @@ public class StorageWorldProvider extends WorldProvider
|
||||
@Override
|
||||
protected void registerWorldChunkManager()
|
||||
{
|
||||
super.worldChunkMgr = new WorldChunkManagerHell( Registration.instance.storageBiome, 1, 1 );
|
||||
super.worldChunkMgr = new WorldChunkManagerHell( Registration.instance.storageBiome, 0.0F );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user