From c2a2cc074ae87774848e7e489c2e6ff10bdafa7c Mon Sep 17 00:00:00 2001 From: opfromthestart Date: Tue, 3 Aug 2021 14:44:52 -0400 Subject: [PATCH] Some Stuff to Fix Bugs -Improved debug info of Fallingblock ticking -Fixed unsynchronized access as per OLEGSHA -Maybe better server side deletion of blocks --- .../progressia/client/graphics/world/LayerWorld.java | 4 ++-- .../progressia/test/TestEntityLogicFallingBlock.java | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/client/graphics/world/LayerWorld.java b/src/main/java/ru/windcorp/progressia/client/graphics/world/LayerWorld.java index ccc052a..4af53e9 100644 --- a/src/main/java/ru/windcorp/progressia/client/graphics/world/LayerWorld.java +++ b/src/main/java/ru/windcorp/progressia/client/graphics/world/LayerWorld.java @@ -110,11 +110,11 @@ public class LayerWorld extends Layer { tmp_testControls.applyPlayerControls(); - for (EntityData data : this.client.getWorld().getData().getEntities()) { + this.client.getWorld().getData().getEntities().forEach(data -> { tmp_applyFriction(data, tickLength); tmp_applyGravity(data, tickLength); tmp_renderCollisionModel(data); - } + }); } catch (Throwable e) { e.printStackTrace(); System.err.println("OLEGSHA is to blame. Tell him he vry stupiDD!!"); diff --git a/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java b/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java index 729d857..0730d63 100644 --- a/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java +++ b/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java @@ -10,6 +10,7 @@ import glm.vec._3.i.Vec3i; import ru.windcorp.progressia.client.ClientState; import ru.windcorp.progressia.common.world.block.BlockDataRegistry; import ru.windcorp.progressia.common.world.entity.EntityData; +import ru.windcorp.progressia.server.Server; import ru.windcorp.progressia.server.world.TickContext; import ru.windcorp.progressia.server.world.entity.EntityLogic; @@ -57,7 +58,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic { // "+String.valueOf(entity!=null) + " " + // context.toString()); super.tick(entity, context); - + // friction Vec3 vel = entity.getVelocity(); float friction = 0f; @@ -105,12 +106,14 @@ public class TestEntityLogicFallingBlock extends EntityLogic { if (context.getWorldData().isBlockLoaded(occupiedBlock) && context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId() != "Test:Air") { - LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x)); + LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x) + " " + String.valueOf(occupiedBlock.y) + " " + String.valueOf(occupiedBlock.z)); // 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. - ClientState.getInstance().getWorld().getData().removeEntity(entity.getEntityId());// context.getWorldData().removeEntity(entity.getEntityId()); + //ClientState.getInstance().getWorld().getData().removeEntity(entity.getEntityId());// context.getWorldData().removeEntity(entity.getEntityId()); + Server server = context.getServer(); + server.invokeLater(() -> server.getWorld().getData().removeEntity(entity.getEntityId())); } } }