Skip to content

Commit

Permalink
Display Positions in errors when loading data.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgorithmX2 committed Nov 11, 2016
1 parent 06bd1ce commit a3dc684
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 13 deletions.
Expand Up @@ -62,7 +62,7 @@ public IBlockState getPrimaryBlockState()

public VoxelBlobStateReference getVoxelRef(
final int version,
final long weight )
final long weight ) throws Exception
{
final VoxelBlobStateReference voxelRef = getRef();

Expand All @@ -71,7 +71,7 @@ public VoxelBlobStateReference getVoxelRef(
return new VoxelBlobStateReference( voxelRef.getByteArray(), weight );
}

return new VoxelBlobStateReference( voxelRef.getVoxelBlob().blobToBytes( version ), weight );
return new VoxelBlobStateReference( voxelRef.getVoxelBlobCatchable().blobToBytes( version ), weight );
}

public NBTBlobConverter()
Expand Down
Expand Up @@ -12,6 +12,7 @@
import mod.chiselsandbits.chiseledblock.data.VoxelNeighborRenderTracker;
import mod.chiselsandbits.client.UndoTracker;
import mod.chiselsandbits.core.ChiselsAndBits;
import mod.chiselsandbits.core.Log;
import mod.chiselsandbits.core.api.BitAccess;
import mod.chiselsandbits.helpers.DeprecationHelper;
import mod.chiselsandbits.helpers.ModUtil;
Expand Down Expand Up @@ -522,11 +523,30 @@ public boolean updateBlob(

final VoxelBlobStateReference originalRef = getBasicState().getValue( BlockChiseled.UProperty_VoxelBlob );

VoxelBlobStateReference voxelRef = null;

sideState = converter.getSideState();
final int b = converter.getPrimaryBlockStateID();
lightlevel = converter.getLightValue();
isNormalCube = converter.isNormalCube();
final VoxelBlobStateReference voxelRef = converter.getVoxelRef( VoxelBlob.VERSION_COMPACT, getPositionRandom( pos ) );

try
{
voxelRef = converter.getVoxelRef( VoxelBlob.VERSION_COMPACT, getPositionRandom( pos ) );
}
catch ( final Exception e )
{
if ( getPos() != null )
{
Log.logError( "Unable to read blob at " + getPos(), e );
}
else
{
Log.logError( "Unable to read blob.", e );
}

voxelRef = new VoxelBlobStateReference( 0, getPositionRandom( pos ) );
}

IExtendedBlockState newstate = getBasicState()
.withProperty( BlockChiseled.UProperty_Primary_BlockState, b )
Expand Down
Expand Up @@ -86,16 +86,7 @@ public VoxelBlob getBlob()
{
try
{
VoxelBlob vb = blob == null ? null : blob.get();

if ( vb == null )
{
vb = new VoxelBlob();
vb.blobFromBytes( voxelBytes );
blob = new SoftReference<VoxelBlob>( vb );
}

return new VoxelBlob( vb );
return getBlobCatchable();
}
catch ( final Exception e )
{
Expand All @@ -104,6 +95,20 @@ public VoxelBlob getBlob()
}
}

public VoxelBlob getBlobCatchable() throws Exception
{
VoxelBlob vb = blob == null ? null : blob.get();

if ( vb == null )
{
vb = new VoxelBlob();
vb.blobFromBytes( voxelBytes );
blob = new SoftReference<VoxelBlob>( vb );
}

return new VoxelBlob( vb );
}

private AxisAlignedBB[] getBoxType(
final int type )
{
Expand Down
Expand Up @@ -103,6 +103,11 @@ public VoxelBlob getVoxelBlob()
return data.getBlob();
}

public VoxelBlob getVoxelBlobCatchable() throws Exception
{
return data.getBlobCatchable();
}

public VoxelBlobStateReference(
final VoxelBlob blob,
final long weight )
Expand Down

0 comments on commit a3dc684

Please sign in to comment.