Conservation of Matter
-Placing a Test:Sand block now deletes the block and summons a Test:FallingBlock in its place.
This commit is contained in:
parent
bf49687ab6
commit
47eb9fa5af
@ -13,6 +13,7 @@ public class TestEntityDataFallingBlock extends EntityData {
|
|||||||
|
|
||||||
private BlockData block;
|
private BlockData block;
|
||||||
private boolean isDone = false;
|
private boolean isDone = false;
|
||||||
|
private boolean hasDeleted = false;
|
||||||
|
|
||||||
public TestEntityDataFallingBlock() {
|
public TestEntityDataFallingBlock() {
|
||||||
this("Test:FallingBlock",new BlockData("Test:Sand"));
|
this("Test:FallingBlock",new BlockData("Test:Sand"));
|
||||||
@ -24,6 +25,16 @@ public class TestEntityDataFallingBlock extends EntityData {
|
|||||||
block = blockInput;
|
block = blockInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDestroyed()
|
||||||
|
{
|
||||||
|
hasDeleted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasDestroyed()
|
||||||
|
{
|
||||||
|
return hasDeleted;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockData getBlock()
|
public BlockData getBlock()
|
||||||
{
|
{
|
||||||
return block;
|
return block;
|
||||||
|
@ -8,6 +8,7 @@ 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.client.ClientState;
|
||||||
|
import ru.windcorp.progressia.common.world.block.BlockDataRegistry;
|
||||||
import ru.windcorp.progressia.common.world.entity.EntityData;
|
import ru.windcorp.progressia.common.world.entity.EntityData;
|
||||||
import ru.windcorp.progressia.server.world.TickContext;
|
import ru.windcorp.progressia.server.world.TickContext;
|
||||||
import ru.windcorp.progressia.server.world.entity.EntityLogic;
|
import ru.windcorp.progressia.server.world.entity.EntityLogic;
|
||||||
@ -49,12 +50,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//LogManager.getLogger().info("NotNull "+entity.toString() + " " + context.toString());
|
//LogManager.getLogger().info("NotNull "+entity.toString() + " " + context.toString());
|
||||||
super.tick(entity, context);
|
super.tick(entity, context);
|
||||||
|
|
||||||
//friction
|
//friction
|
||||||
Vec3 vel = entity.getVelocity();
|
Vec3 vel = entity.getVelocity();
|
||||||
float friction = .8f;
|
float friction = 0f;
|
||||||
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);
|
||||||
|
|
||||||
@ -66,6 +68,13 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
|
|||||||
return;
|
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 occupiedBlock = fallBlock.getBlockInWorld(null);
|
||||||
Vec3i underBlock = occupiedBlock.sub_(0, 0, 1);
|
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));
|
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);
|
||||||
context.getAccessor().setBlock(occupiedBlock, fallBlock.getBlock());
|
context.getAccessor().setBlock(occupiedBlock, fallBlock.getBlock());
|
||||||
//fallBlock.setInvisible(); //Until I know how to properly delete it.
|
fallBlock.setInvisible(); //Until I know how to properly delete it.
|
||||||
context.getWorldData().removeEntity(entity.getEntityId());
|
//context.getWorldData().removeEntity(entity.getEntityId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,6 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
|
|||||||
chunk.setBlock(blockInChunk, previous, false);
|
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));
|
||||||
world.setBlock(chunkWorldPos, BlockDataRegistry.getInstance().get("Test:Glass"), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user