Removed Dropped Features.

Implemented Spatial Storage.
Fixed bug with ME Chest saying the cell was un-readable.
This commit is contained in:
AlgorithmX2
2014-03-05 01:27:42 -06:00
parent d5182da346
commit 040e948d8e
29 changed files with 606 additions and 324 deletions
+49 -10
View File
@@ -7,10 +7,14 @@ import java.util.List;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S21PacketChunkData;
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.util.ForgeDirection;
@@ -20,6 +24,7 @@ import appeng.api.movable.IMovableRegistry;
import appeng.api.util.WorldCoord;
import appeng.core.AELog;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class CachedPlane
{
@@ -53,6 +58,9 @@ public class CachedPlane
public void setBlockIDWithMetadata(int y, Object[] blk)
{
if ( blk[0] == matrixFrame )
blk[0] = Platform.air;
ExtendedBlockStorage extendedblockstorage = storage[y >> 4];
extendedblockstorage.func_150818_a( x, y & 15, z, (Block) blk[0] );
// extendedblockstorage.setExtBlockID( x, y & 15, z, blk[0] );
@@ -104,6 +112,7 @@ public class CachedPlane
LinkedList<NextTickListEntry> ticks = new LinkedList<NextTickListEntry>();
World wrld;
Block matrixFrame = AEApi.instance().blocks().blockMatrixFrame.block();
LinkedList<WorldCoord> updates = new LinkedList<WorldCoord>();
@@ -385,19 +394,49 @@ public class CachedPlane
for (int z = 0; z < cz_size; z++)
{
// TODO: Fix?
Chunk c = myChunks[x][z];
try
{
WorldServer ws = (WorldServer) c.worldObj;
PlayerManager pm = ws.getPlayerManager();
if ( getOrCreateChunkWatcher == null )
{
getOrCreateChunkWatcher = ReflectionHelper.findMethod( PlayerManager.class, pm, new String[] { "getOrCreateChunkWatcher",
"func_72690_a" }, int.class, int.class, boolean.class );
}
if ( getOrCreateChunkWatcher != null )
{
Object playerinstance = getOrCreateChunkWatcher.invoke( pm, c.xPosition, c.zPosition, false );
if ( playerinstance != null )
{
Playerinstance = playerinstance.getClass();
if ( sendToAllPlayersWatchingChunk == null )
{
sendToAllPlayersWatchingChunk = ReflectionHelper.findMethod( Playerinstance, playerinstance, new String[] {
"sendToAllPlayersWatchingChunk", "func_151251_a" }, Packet.class );
}
if ( sendToAllPlayersWatchingChunk != null )
sendToAllPlayersWatchingChunk.invoke( playerinstance, new S21PacketChunkData( c, false, verticalBits ) );
}
}
}
catch (Throwable t)
{
AELog.error( t );
}
/*
* 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 ) );
*/
}
}
Class Playerinstance;
Method getOrCreateChunkWatcher;
Method sendToAllPlayersWatchingChunk;
}
+16 -1
View File
@@ -3,20 +3,29 @@ package appeng.spatial;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderGenerate;
import appeng.api.AEApi;
import appeng.core.AEConfig;
public class StorageChunkProvider extends ChunkProviderGenerate implements IChunkProvider
{
Block[] ablock = new Block[32768];
World w;
public StorageChunkProvider(World wrd, long i) {
super( wrd, i, false );
this.w = wrd;
Block matrixFrame = AEApi.instance().blocks().blockMatrixFrame.block();
for (int x = 0; x < ablock.length; x++)
ablock[x] = matrixFrame;
}
@Override
@@ -28,7 +37,13 @@ public class StorageChunkProvider extends ChunkProviderGenerate implements IChun
@Override
public Chunk provideChunk(int x, int z)
{
Chunk chunk = new Chunk( w, x, z );
Chunk chunk = new Chunk( w, ablock, x, z );
byte[] abyte = chunk.getBiomeArray();
AEConfig config = AEConfig.instance;
for (int k = 0; k < abyte.length; ++k)
abyte[k] = (byte) config.storageBiomeID;
if ( !chunk.isTerrainPopulated )
{
+22 -2
View File
@@ -1,5 +1,6 @@
package appeng.spatial;
import java.lang.reflect.Method;
import java.util.List;
import net.minecraft.block.Block;
@@ -15,7 +16,9 @@ import net.minecraft.world.WorldServer;
import appeng.api.AEApi;
import appeng.api.util.WorldCoord;
import appeng.block.solids.BlockMatrixFrame;
import appeng.core.AELog;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class StorageHelper
{
@@ -119,6 +122,8 @@ public class StorageHelper
};
Method onEntityRemoved;
/**
* Mostly from dimentional doors.. which mostly got it form X-Comp.
*
@@ -179,8 +184,23 @@ public class StorageHelper
oldWorld.getChunkFromChunkCoords( entX, entZ ).isModified = true;
}
// TODO: Fix?
// oldWorld.onEntityRemoved( entity );
if ( onEntityRemoved == null )
{
onEntityRemoved = ReflectionHelper.findMethod( WorldServer.class, oldWorld, new String[] { "onEntityRemoved", "func_72847_b" },
Entity.class );
}
if ( onEntityRemoved != null )
{
try
{
onEntityRemoved.invoke( oldWorld, entity );
}
catch (Throwable t)
{
AELog.error( t );
}
}
if ( player == null ) // Are we NOT working with a player?
{