Better performance maybe?
-Changed as many of the ClientState statements to context as I could. -Only looks for a sand based update once per block update(I think it was twice before)
This commit is contained in:
parent
b3ae829383
commit
bf49687ab6
@ -44,7 +44,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick(EntityData entity, TickContext context) {
|
public void tick(EntityData entity, TickContext context) { //context.getWorldData() ClientState.getInstance().getWorld().getData()
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -58,7 +58,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
|
|||||||
vel = new Vec3(vel.x*friction,vel.y*friction,vel.z);
|
vel = new Vec3(vel.x*friction,vel.y*friction,vel.z);
|
||||||
entity.setVelocity(vel);
|
entity.setVelocity(vel);
|
||||||
|
|
||||||
TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
|
TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId()); //ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
|
||||||
//fallBlock = (TestEntityDataFallingBlock) entity;
|
//fallBlock = (TestEntityDataFallingBlock) entity;
|
||||||
|
|
||||||
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null)))
|
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null)))
|
||||||
@ -76,12 +76,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
|
|||||||
//LogManager.getLogger().info("FallingBlock is at "+String.valueOf(occupiedBlock.x)+" "+String.valueOf(occupiedBlock.y)+" "+String.valueOf(occupiedBlock.z));
|
//LogManager.getLogger().info("FallingBlock is at "+String.valueOf(occupiedBlock.x)+" "+String.valueOf(occupiedBlock.y)+" "+String.valueOf(occupiedBlock.z));
|
||||||
//LogManager.getLogger().info("Block is of type " + context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId());
|
//LogManager.getLogger().info("Block is of type " + context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId());
|
||||||
|
|
||||||
if (ClientState.getInstance().getWorld().getData().getChunk(chunkCoords).getBlock(inChunkCoords)
|
if (context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords)
|
||||||
.getId() != "Test:Air") {
|
.getId() != "Test:Air") {
|
||||||
LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x));
|
LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x));
|
||||||
ClientState.getInstance().getWorld().getData().setBlock(occupiedBlock, fallBlock.getBlock(),true);
|
//ClientState.getInstance().getWorld().getData().setBlock(occupiedBlock, fallBlock.getBlock(),true);
|
||||||
fallBlock.setInvisible(); //Until I know how to properly delete it.
|
context.getAccessor().setBlock(occupiedBlock, fallBlock.getBlock());
|
||||||
//ClientState.getInstance().getWorld().getData().removeEntity(entity.getEntityId());
|
//fallBlock.setInvisible(); //Until I know how to properly delete it.
|
||||||
|
context.getWorldData().removeEntity(entity.getEntityId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
|
|
||||||
import glm.vec._3.Vec3;
|
import glm.vec._3.Vec3;
|
||||||
import glm.vec._3.i.Vec3i;
|
import glm.vec._3.i.Vec3i;
|
||||||
import ru.windcorp.progressia.client.ClientState;
|
|
||||||
import ru.windcorp.progressia.common.util.VectorUtil;
|
import ru.windcorp.progressia.common.util.VectorUtil;
|
||||||
import ru.windcorp.progressia.common.util.Vectors;
|
import ru.windcorp.progressia.common.util.Vectors;
|
||||||
import ru.windcorp.progressia.common.world.ChunkData;
|
import ru.windcorp.progressia.common.world.ChunkData;
|
||||||
@ -58,7 +57,7 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
@Override
|
@Override
|
||||||
public void onChunkLoaded(WorldData world, ChunkData chunk) {
|
public void onChunkLoaded(WorldData world, ChunkData chunk) {
|
||||||
findAndPopulate(chunk.getPosition(), world);
|
findAndPopulate(chunk.getPosition(), world);
|
||||||
chunk.addListener(new ChunkDataListener() {
|
chunk.addListener(new ChunkDataListener() { //Falling Block spawning logic
|
||||||
@Override
|
@Override
|
||||||
public void onChunkBlockChanged(ChunkData chunk, Vec3i blockInChunk, BlockData previous,
|
public void onChunkBlockChanged(ChunkData chunk, Vec3i blockInChunk, BlockData previous,
|
||||||
BlockData current) {
|
BlockData current) {
|
||||||
@ -79,10 +78,11 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
+ String.valueOf(new Random().nextFloat())).hashCode());
|
+ String.valueOf(new Random().nextFloat())).hashCode());
|
||||||
|
|
||||||
chunk.getWorld().addEntity(fallingBlock);
|
chunk.getWorld().addEntity(fallingBlock);
|
||||||
chunk.setBlock(blockInChunk, previous, true);
|
|
||||||
|
chunk.setBlock(blockInChunk, previous, false);
|
||||||
Vec3i chunkWorldPos = chunk.getPosition().mul_(16).add_(blockInChunk);
|
Vec3i chunkWorldPos = chunk.getPosition().mul_(16).add_(blockInChunk);
|
||||||
LogManager.getLogger().info(String.valueOf(chunkWorldPos.x)+" "+String.valueOf(chunkWorldPos.y)+" "+String.valueOf(chunkWorldPos.z));
|
LogManager.getLogger().info(String.valueOf(chunkWorldPos.x)+" "+String.valueOf(chunkWorldPos.y)+" "+String.valueOf(chunkWorldPos.z));
|
||||||
ClientState.getInstance().getWorld().getData().setBlock(chunkWorldPos, BlockDataRegistry.getInstance().get("Test:Glass"), true);
|
world.setBlock(chunkWorldPos, BlockDataRegistry.getInstance().get("Test:Glass"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user