From 47eb9fa5af9edc9066bd3d63c31c7b946ec2423d Mon Sep 17 00:00:00 2001 From: opfromthestart Date: Thu, 10 Jun 2021 14:08:35 -0400 Subject: [PATCH] Conservation of Matter -Placing a Test:Sand block now deletes the block and summons a Test:FallingBlock in its place. --- .../test/TestEntityDataFallingBlock.java | 11 +++++++++++ .../test/TestEntityLogicFallingBlock.java | 15 ++++++++++++--- .../progressia/test/gen/TestWorldGenerator.java | 1 - 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/windcorp/progressia/test/TestEntityDataFallingBlock.java b/src/main/java/ru/windcorp/progressia/test/TestEntityDataFallingBlock.java index cf47a29..0b1e1e1 100644 --- a/src/main/java/ru/windcorp/progressia/test/TestEntityDataFallingBlock.java +++ b/src/main/java/ru/windcorp/progressia/test/TestEntityDataFallingBlock.java @@ -13,6 +13,7 @@ public class TestEntityDataFallingBlock extends EntityData { private BlockData block; private boolean isDone = false; + private boolean hasDeleted = false; public TestEntityDataFallingBlock() { this("Test:FallingBlock",new BlockData("Test:Sand")); @@ -24,6 +25,16 @@ public class TestEntityDataFallingBlock extends EntityData { block = blockInput; } + public void setDestroyed() + { + hasDeleted = true; + } + + public boolean hasDestroyed() + { + return hasDeleted; + } + public BlockData getBlock() { return block; diff --git a/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java b/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java index cff6b24..62b8337 100644 --- a/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java +++ b/src/main/java/ru/windcorp/progressia/test/TestEntityLogicFallingBlock.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager; import glm.vec._3.Vec3; 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.world.TickContext; import ru.windcorp.progressia.server.world.entity.EntityLogic; @@ -49,12 +50,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic { { return; } + //LogManager.getLogger().info("NotNull "+entity.toString() + " " + context.toString()); super.tick(entity, context); //friction Vec3 vel = entity.getVelocity(); - float friction = .8f; + float friction = 0f; vel = new Vec3(vel.x*friction,vel.y*friction,vel.z); entity.setVelocity(vel); @@ -66,6 +68,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic { return; } + if (!fallBlock.hasDestroyed()) + { + //LogManager.getLogger().info(fallBlock.getStartPos()); + context.getAccessor().setBlock(fallBlock.getBlockInWorld(null), BlockDataRegistry.getInstance().get("Test:Air")); + fallBlock.setDestroyed(); + } + Vec3i occupiedBlock = fallBlock.getBlockInWorld(null); Vec3i underBlock = occupiedBlock.sub_(0, 0, 1); @@ -81,8 +90,8 @@ public class TestEntityLogicFallingBlock extends EntityLogic { 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()); + fallBlock.setInvisible(); //Until I know how to properly delete it. + //context.getWorldData().removeEntity(entity.getEntityId()); } } } diff --git a/src/main/java/ru/windcorp/progressia/test/gen/TestWorldGenerator.java b/src/main/java/ru/windcorp/progressia/test/gen/TestWorldGenerator.java index 6702856..bb3acc9 100644 --- a/src/main/java/ru/windcorp/progressia/test/gen/TestWorldGenerator.java +++ b/src/main/java/ru/windcorp/progressia/test/gen/TestWorldGenerator.java @@ -82,7 +82,6 @@ public class TestWorldGenerator extends AbstractWorldGenerator { chunk.setBlock(blockInChunk, previous, false); Vec3i chunkWorldPos = chunk.getPosition().mul_(16).add_(blockInChunk); LogManager.getLogger().info(String.valueOf(chunkWorldPos.x)+" "+String.valueOf(chunkWorldPos.y)+" "+String.valueOf(chunkWorldPos.z)); - world.setBlock(chunkWorldPos, BlockDataRegistry.getInstance().get("Test:Glass"), false); } } });