Bug Fixing and Performance

-Multiple null checks(It doesn't work without them)
-Checks to make sure entities are within loaded chunks
-Actual entity removal
This commit is contained in:
opfromthestart 2021-06-10 17:00:09 -04:00
parent 3879e5ffac
commit ae2980c9de

View File

@ -53,8 +53,8 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
return;
}
// LogManager.getLogger().info("NotNull "+entity.toString() + " " +
// context.toString());
//LogManager.getLogger().info("NotNull "+entity.toString()+" "+String.valueOf(entity!=null) + " " +
//context.toString());
super.tick(entity, context);
// friction
@ -67,6 +67,12 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
.getData().getEntity(entity.getEntityId()); // ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
// fallBlock = (TestEntityDataFallingBlock) entity;
//LogManager.getLogger().info("NotNull FB "+String.valueOf(fallBlock!=null));
if (fallBlock==null)
{
return;
}
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null))) {
return;
}
@ -96,13 +102,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
// LogManager.getLogger().info("Block is of type " +
// context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId());
if (context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId() != "Test:Air") {
if (context.getWorldData().isBlockLoaded(occupiedBlock) && context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId() != "Test:Air") {
LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x));
// ClientState.getInstance().getWorld().getData().setBlock(occupiedBlock,
// fallBlock.getBlock(),true);
context.getAccessor().setBlock(occupiedBlock, fallBlock.getBlock());
fallBlock.setInvisible(); // Until I know how to properly delete it.
// context.getWorldData().removeEntity(entity.getEntityId());
ClientState.getInstance().getWorld().getData().removeEntity(entity.getEntityId());//context.getWorldData().removeEntity(entity.getEntityId());
}
}
}