Fixed some stuff

-Added default gravity block check in server
-Some things I had to copy since i didnt merge right
-Adds all gravity blocks to FallingBlock list
-LogTop debug thing to check for good textures
-Some texture rendering(see above)
-Some control changes since I need to get to the edge quickly
This commit is contained in:
opfromthestart 2021-08-23 13:33:18 -04:00
parent 59129f95c9
commit 175f092673
9 changed files with 527 additions and 135 deletions

View File

@ -18,6 +18,8 @@
package ru.windcorp.progressia.server; package ru.windcorp.progressia.server;
import java.util.List;
import java.util.Random;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
@ -25,12 +27,20 @@ import org.apache.logging.log4j.LogManager;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import glm.vec._3.Vec3;
import glm.vec._3.i.Vec3i; import glm.vec._3.i.Vec3i;
import ru.windcorp.jputil.functions.ThrowingRunnable; import ru.windcorp.jputil.functions.ThrowingRunnable;
import ru.windcorp.progressia.common.Units; import ru.windcorp.progressia.common.Units;
import ru.windcorp.progressia.common.util.TaskQueue; import ru.windcorp.progressia.common.util.TaskQueue;
import ru.windcorp.progressia.common.util.crash.ReportingEventBus; import ru.windcorp.progressia.common.util.crash.ReportingEventBus;
import ru.windcorp.progressia.common.world.ChunkDataListener;
import ru.windcorp.progressia.common.world.Coordinates;
import ru.windcorp.progressia.common.world.DefaultChunkData;
import ru.windcorp.progressia.common.world.DefaultWorldData; import ru.windcorp.progressia.common.world.DefaultWorldData;
import ru.windcorp.progressia.common.world.GravityModelRegistry;
import ru.windcorp.progressia.common.world.WorldDataListener;
import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.block.BlockDataRegistry;
import ru.windcorp.progressia.common.world.rels.AbsFace; import ru.windcorp.progressia.common.world.rels.AbsFace;
import ru.windcorp.progressia.common.world.rels.AxisRotations; import ru.windcorp.progressia.common.world.rels.AxisRotations;
import ru.windcorp.progressia.server.comms.ClientManager; import ru.windcorp.progressia.server.comms.ClientManager;
@ -50,6 +60,8 @@ import ru.windcorp.progressia.server.world.tasks.WorldAccessor;
import ru.windcorp.progressia.server.world.ticking.Change; import ru.windcorp.progressia.server.world.ticking.Change;
import ru.windcorp.progressia.server.world.ticking.Evaluation; import ru.windcorp.progressia.server.world.ticking.Evaluation;
import ru.windcorp.progressia.server.world.ticking.TickerCoordinator; import ru.windcorp.progressia.server.world.ticking.TickerCoordinator;
import ru.windcorp.progressia.test.TestEntityDataFallingBlock;
import ru.windcorp.progressia.test.TestEntityLogicFallingBlock;
public class Server { public class Server {
@ -79,6 +91,71 @@ public class Server {
private final TickingSettings tickingSettings = new TickingSettings(); private final TickingSettings tickingSettings = new TickingSettings();
public Server(DefaultWorldData world, Function<Server, WorldGenerator> generatorCreator) { public Server(DefaultWorldData world, Function<Server, WorldGenerator> generatorCreator) {
world.addListener(new WorldDataListener() {
@Override
public void onChunkLoaded(DefaultWorldData world, DefaultChunkData chunk) {
//PlanetGenerator.this.planet;
//LogManager.getLogger().info("Loaded chunk");
GravityModelRegistry.getInstance().get("Test:PlanetGravityModel");
chunk.addListener(new ChunkDataListener() { // Falling Block
// spawning logic
@Override
public void onChunkBlockChanged(DefaultChunkData chunk_2, Vec3i blockInChunk, BlockData previous,
BlockData current) {
Vec3i chunkWorldPos = new Vec3i(0,0,0);
Coordinates.getInWorld(chunk_2.getPosition(), blockInChunk, chunkWorldPos);
/*List<Vec3i> underBlocks = getGoodCardinals(fallBlock.getUpVector().negate_());
boolean notSupported = false;
for (Vec3i v3 : underBlocks)
{
Vec3i inWorld = occupiedBlock.sub_(v3);
if (context.getBlock(inWorld).getId()=="Test:Air") {
notSupported=true;
break;
}
}*/
//chunk.getPosition().mul_(16).add_(blockInChunk);
//LogManager.getLogger().info("Put block {} at {}<{}<{}",current.getId(),chunkWorldPos.x,chunkWorldPos.y,chunkWorldPos.z);
if (TestEntityLogicFallingBlock.FallingBlocks
.contains(chunk_2.getWorld().getBlock(chunkWorldPos.add_(0, 0, 1)).getId())) {
chunk_2.getWorld().setBlock(chunkWorldPos.add_(0, 0, 1), BlockDataRegistry.getInstance()
.get(chunk_2.getWorld().getBlock(chunkWorldPos.add_(0, 0, 1)).getId()), true);
}
if (!TestEntityLogicFallingBlock.FallingBlocks.contains(current.getId())) {
return;
}
//LogManager.getLogger().info("Cont");
if (chunk_2.getWorld().getBlock(chunkWorldPos.add_(0, 0, -1)).getId() == "Test:Air") {
LogManager.getLogger().info("Inserting FallingBlock {},{},{}",
chunkWorldPos.x,chunkWorldPos.y,chunkWorldPos.z);
TestEntityDataFallingBlock fallingBlock = new TestEntityDataFallingBlock(current);
Vec3i worldPos = chunk_2.getPosition().mul_(16).add_(blockInChunk);
Vec3 floatWorldPos = new Vec3(worldPos.x, worldPos.y, worldPos.z);
fallingBlock.setPosition(floatWorldPos);
fallingBlock.setEntityId(("Test:FallingBlock" + floatWorldPos.toString()
+ String.valueOf(new Random().nextFloat())).hashCode());
chunk.getWorld().addEntity(fallingBlock);
//invokeLater(() -> world.addEntity(fallingBlock));
//chunk.setBlock(blockInChunk, previous, false);
//invokeLater(() -> world.setBlock(chunkWorldPos, BlockDataRegistry.getInstance().get("Test:Air"), false));
//LogManager.getLogger().info(String.valueOf(chunkWorldPos.x) + " "
// + String.valueOf(chunkWorldPos.y) + " " + String.valueOf(chunkWorldPos.z));
}
}
});
}
});
this.world = new DefaultWorldLogic( this.world = new DefaultWorldLogic(
world, world,
this, this,

View File

@ -21,7 +21,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
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.common.util.FloatRangeMap; import ru.windcorp.progressia.common.util.FloatRangeMap;
@ -58,6 +57,8 @@ public class PlanetGenerator extends AbstractWorldGenerator<Boolean> {
this.terrainGenerator = new PlanetTerrainGenerator(this, heightMap, layers); this.terrainGenerator = new PlanetTerrainGenerator(this, heightMap, layers);
this.featureGenerator = new PlanetFeatureGenerator(this, features); this.featureGenerator = new PlanetFeatureGenerator(this, features);
} }
/** /**

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package ru.windcorp.progressia.test; package ru.windcorp.progressia.test;
import java.io.DataInput; import java.io.DataInput;
@ -33,13 +33,14 @@ import gnu.trove.map.TObjectIntMap;
import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.map.hash.TObjectIntHashMap;
import ru.windcorp.jputil.functions.ThrowingConsumer; import ru.windcorp.jputil.functions.ThrowingConsumer;
import ru.windcorp.progressia.common.state.IOContext; import ru.windcorp.progressia.common.state.IOContext;
import ru.windcorp.progressia.common.world.ChunkData; import ru.windcorp.progressia.common.world.DefaultChunkData;
import ru.windcorp.progressia.common.world.DecodingException; import ru.windcorp.progressia.common.world.DecodingException;
import ru.windcorp.progressia.common.world.WorldData; import ru.windcorp.progressia.common.world.DefaultWorldData;
import ru.windcorp.progressia.common.world.block.BlockData; import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.block.BlockDataRegistry; import ru.windcorp.progressia.common.world.block.BlockDataRegistry;
import ru.windcorp.progressia.common.world.block.BlockFace; import ru.windcorp.progressia.common.world.generic.GenericChunks;
import ru.windcorp.progressia.common.world.io.ChunkCodec; import ru.windcorp.progressia.common.world.io.ChunkCodec;
import ru.windcorp.progressia.common.world.rels.RelFace;
import ru.windcorp.progressia.common.world.tile.TileData; import ru.windcorp.progressia.common.world.tile.TileData;
import ru.windcorp.progressia.common.world.tile.TileDataRegistry; import ru.windcorp.progressia.common.world.tile.TileDataRegistry;
@ -75,7 +76,7 @@ public class TestChunkCodec extends ChunkCodec {
} }
@Override @Override
public boolean shouldEncode(ChunkData chunk, IOContext context) { public boolean shouldEncode(DefaultChunkData chunk, IOContext context) {
return true; return true;
} }
@ -84,12 +85,14 @@ public class TestChunkCodec extends ChunkCodec {
*/ */
@Override @Override
public ChunkData decode(WorldData world, Vec3i position, DataInputStream input, IOContext context) public DefaultChunkData decode(DefaultWorldData world, Vec3i position, DataInputStream input, IOContext context)
throws DecodingException, IOException { throws DecodingException,
IOException {
BlockData[] blockPalette = readBlockPalette(input); BlockData[] blockPalette = readBlockPalette(input);
TileData[] tilePalette = readTilePalette(input); TileData[] tilePalette = readTilePalette(input);
ChunkData chunk = new ChunkData(position, world); DefaultChunkData chunk = new DefaultChunkData(position, world);
readBlocks(input, blockPalette, chunk); readBlocks(input, blockPalette, chunk);
readTiles(input, tilePalette, chunk); readTiles(input, tilePalette, chunk);
@ -118,9 +121,9 @@ public class TestChunkCodec extends ChunkCodec {
return palette; return palette;
} }
private void readBlocks(DataInput input, BlockData[] blockPalette, ChunkData chunk) throws IOException { private void readBlocks(DataInput input, BlockData[] blockPalette, DefaultChunkData chunk) throws IOException {
try { try {
chunk.forEachBiC(guard(v -> { GenericChunks.forEachBiC(guard(v -> {
chunk.setBlock(v, blockPalette[input.readInt()], false); chunk.setBlock(v, blockPalette[input.readInt()], false);
})); }));
} catch (UncheckedIOException e) { } catch (UncheckedIOException e) {
@ -128,7 +131,7 @@ public class TestChunkCodec extends ChunkCodec {
} }
} }
private void readTiles(DataInput input, TileData[] tilePalette, ChunkData chunk) throws IOException { private void readTiles(DataInput input, TileData[] tilePalette, DefaultChunkData chunk) throws IOException {
Vec3i bic = new Vec3i(); Vec3i bic = new Vec3i();
while (true) { while (true) {
@ -137,7 +140,7 @@ public class TestChunkCodec extends ChunkCodec {
break; break;
bic.set(xOrEndMarker, input.readByte() & 0xFF, input.readByte() & 0xFF); bic.set(xOrEndMarker, input.readByte() & 0xFF, input.readByte() & 0xFF);
BlockFace face = BlockFace.getFaces().get(input.readByte() & 0xFF); RelFace face = RelFace.getFaces().get(input.readByte() & 0xFF);
int tiles = input.readByte() & 0xFF; int tiles = input.readByte() & 0xFF;
@ -154,7 +157,7 @@ public class TestChunkCodec extends ChunkCodec {
*/ */
@Override @Override
public void encode(ChunkData chunk, DataOutputStream output, IOContext context) throws IOException { public void encode(DefaultChunkData chunk, DataOutputStream output, IOContext context) throws IOException {
Palette<BlockData> blockPalette = createBlockPalette(chunk); Palette<BlockData> blockPalette = createBlockPalette(chunk);
Palette<TileData> tilePalette = createTilePalette(chunk); Palette<TileData> tilePalette = createTilePalette(chunk);
@ -165,13 +168,13 @@ public class TestChunkCodec extends ChunkCodec {
writeTiles(chunk, tilePalette, output); writeTiles(chunk, tilePalette, output);
} }
private Palette<BlockData> createBlockPalette(ChunkData chunk) { private Palette<BlockData> createBlockPalette(DefaultChunkData chunk) {
Palette<BlockData> blockPalette = new Palette<>(); Palette<BlockData> blockPalette = new Palette<>();
chunk.forEachBiC(v -> blockPalette.add(chunk.getBlock(v))); GenericChunks.forEachBiC(v -> blockPalette.add(chunk.getBlock(v)));
return blockPalette; return blockPalette;
} }
private Palette<TileData> createTilePalette(ChunkData chunk) { private Palette<TileData> createTilePalette(DefaultChunkData chunk) {
Palette<TileData> tilePalette = new Palette<>(); Palette<TileData> tilePalette = new Palette<>();
chunk.forEachTile((ts, t) -> tilePalette.add(t)); chunk.forEachTile((ts, t) -> tilePalette.add(t));
return tilePalette; return tilePalette;
@ -193,9 +196,9 @@ public class TestChunkCodec extends ChunkCodec {
} }
} }
private void writeBlocks(ChunkData chunk, Palette<BlockData> blockPalette, DataOutput output) throws IOException { private void writeBlocks(DefaultChunkData chunk, Palette<BlockData> blockPalette, DataOutput output) throws IOException {
try { try {
chunk.forEachBiC(guard(v -> { GenericChunks.forEachBiC(guard(v -> {
output.writeInt(blockPalette.getNid(chunk.getBlock(v))); output.writeInt(blockPalette.getNid(chunk.getBlock(v)));
})); }));
} catch (UncheckedIOException e) { } catch (UncheckedIOException e) {
@ -203,7 +206,7 @@ public class TestChunkCodec extends ChunkCodec {
} }
} }
private void writeTiles(ChunkData chunk, Palette<TileData> tilePalette, DataOutput output) throws IOException { private void writeTiles(DefaultChunkData chunk, Palette<TileData> tilePalette, DataOutput output) throws IOException {
Vec3i bic = new Vec3i(); Vec3i bic = new Vec3i();
try { try {

View File

@ -256,6 +256,10 @@ public class TestContent {
register("Test:Statie", TestEntityDataStatie::new); register("Test:Statie", TestEntityDataStatie::new);
register(new TestEntityRenderStatie("Test:Statie")); register(new TestEntityRenderStatie("Test:Statie"));
register(new TestEntityLogicStatie("Test:Statie")); register(new TestEntityLogicStatie("Test:Statie"));
register("Test:FallingBlock", TestEntityDataFallingBlock::new);
register(new TestEntityLogicFallingBlock("Test:FallingBlock"));
register(new TestEntityRenderFallingBlock("Test:FallingBlock"));
} }
private static void regsiterControls() { private static void regsiterControls() {

View File

@ -1,5 +1,7 @@
package ru.windcorp.progressia.test; package ru.windcorp.progressia.test;
import org.apache.logging.log4j.LogManager;
import ru.windcorp.progressia.common.collision.AABB; import ru.windcorp.progressia.common.collision.AABB;
import ru.windcorp.progressia.common.world.block.BlockData; import ru.windcorp.progressia.common.world.block.BlockData;
import ru.windcorp.progressia.common.world.entity.EntityData; import ru.windcorp.progressia.common.world.entity.EntityData;
@ -17,13 +19,18 @@ public class TestEntityDataFallingBlock extends EntityData {
private boolean hasDeleted = false; private boolean hasDeleted = false;
public TestEntityDataFallingBlock() { public TestEntityDataFallingBlock() {
this("Test:FallingBlock", new BlockData("Test:Sand")); this("Test:FallingBlock", new BlockData("Test:LogTop"));
}
public TestEntityDataFallingBlock(BlockData data) {
this("Test:FallingBlock", data);
} }
protected TestEntityDataFallingBlock(String id, BlockData blockInput) { protected TestEntityDataFallingBlock(String id, BlockData blockInput) {
super(id); super(id);
setCollisionModel(new AABB(0, 0, 0, 1, 1, 1)); setCollisionModel(new AABB(0, 0, 0, 1, 1, 1));
block = blockInput; block = blockInput;
LogManager.getLogger().info(blockInput.getId());
} }
public void setDestroyed() { public void setDestroyed() {

View File

@ -1,6 +1,8 @@
package ru.windcorp.progressia.test; package ru.windcorp.progressia.test;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -10,9 +12,10 @@ 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.block.BlockDataRegistry;
import ru.windcorp.progressia.common.world.entity.EntityData; import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.server.Server; import ru.windcorp.progressia.server.world.context.ServerWorldContext;
import ru.windcorp.progressia.server.world.TickContext;
import ru.windcorp.progressia.server.world.entity.EntityLogic; import ru.windcorp.progressia.server.world.entity.EntityLogic;
import ru.windcorp.progressia.test.Rocks.Rock;
import ru.windcorp.progressia.test.Rocks.RockVariant;
/** /**
* Logic for Test:FallingBlock * Logic for Test:FallingBlock
@ -26,6 +29,11 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
public void addFallables() { public void addFallables() {
FallingBlocks.add("Test:Sand"); FallingBlocks.add("Test:Sand");
for (Rock rock : TestContent.ROCKS.getRocks())
{
FallingBlocks.add(rock.getBlock(RockVariant.GRAVEL).getId());
FallingBlocks.add(rock.getBlock(RockVariant.SAND).getId());
}
} }
public TestEntityLogicFallingBlock(String id) { public TestEntityLogicFallingBlock(String id) {
@ -33,7 +41,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
addFallables(); addFallables();
} }
private Vec3i trueMod(Vec3i input, Vec3i modulus) // Move this to a class in /*private Vec3i trueMod(Vec3i input, Vec3i modulus) // Move this to a class in
// Vec or something // Vec or something
{ {
return input.mod_(modulus).add_(modulus).mod_(modulus); return input.mod_(modulus).add_(modulus).mod_(modulus);
@ -45,28 +53,71 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
Vec3i temp = input.div_(divisor); Vec3i temp = input.div_(divisor);
temp.add(new Vec3i(input.x < 0 ? -1 : 0, input.y < 0 ? -1 : 0, input.z < 0 ? -1 : 0)); temp.add(new Vec3i(input.x < 0 ? -1 : 0, input.y < 0 ? -1 : 0, input.z < 0 ? -1 : 0));
return temp; return temp;
}*/
public Vec3i getBestCardinal(Vec3 dir)
{
Vec3 a = dir.abs_();
if (a.x>a.y && a.x>a.z)
{
return new Vec3i(dir.x>0 ? 1 : -1,0,0);
}
else if (a.y>a.z)
{
return new Vec3i(0,dir.y>0 ? 1 : -1,0);
}
return new Vec3i(0,0,dir.z>0 ? 1 : -1);
}
public List<Vec3i> getGoodCardinals(Vec3 dir)
{
return getGoodCardinals(dir,.05f);
}
public List<Vec3i> getGoodCardinals(Vec3 dir, float d) {
List<Vec3i> list = new ArrayList<>();
Vec3 a = dir.abs_();
if (a.x>d)
{
list.add(new Vec3i(dir.x>0 ? 1 : -1,0,0));
}
if (a.y>d)
{
list.add(new Vec3i(0,dir.y>0 ? 1 : -1,0));
}
if (a.z>d)
{
list.add(new Vec3i(0,0,dir.z>0 ? 1 : -1));
}
return list;
} }
@Override @Override
public void tick(EntityData entity, TickContext context) { // context.getWorldData() public void tick(EntityData entity, ServerWorldContext context) { // context.getWorldData()
// ClientState.getInstance().getWorld().getData() // ClientState.getInstance().getWorld().getData()
if (entity == null) { if (entity == null) {
return; return;
} }
// LogManager.getLogger().info("NotNull "+entity.toString()+" // LogManager.getLogger().info("NotNull "+entity.toString()+"
// "+String.valueOf(entity!=null) + " " + // "+String.valueOf(entity!=null) + " " +
// context.toString()); // context.toString());
super.tick(entity, context); super.tick(entity, context);
// friction // friction
Vec3 vel = entity.getVelocity(); Vec3 vel = entity.getVelocity();
float friction = 0f; 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);
//TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) context.//context.getEntity(entity.getEntityId());
TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld() TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld()
.getData().getEntity(entity.getEntityId()); // ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId()); .getData().getEntity(entity.getEntityId());
TestEntityDataFallingBlock fallBlock2 = (TestEntityDataFallingBlock) entity;// ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
// fallBlock = (TestEntityDataFallingBlock) entity; // fallBlock = (TestEntityDataFallingBlock) entity;
// LogManager.getLogger().info("NotNull FB // LogManager.getLogger().info("NotNull FB
@ -74,46 +125,56 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
if (fallBlock == null) { if (fallBlock == null) {
return; return;
} }
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null))) { if (fallBlock.isDone() || context.getBlock(fallBlock.getBlockInWorld(null)) == null) {
return; return;
} }
//LogManager.getLogger().info("wut");
if (!fallBlock.hasDestroyed()) { if (!fallBlock.hasDestroyed()) {
// LogManager.getLogger().info(fallBlock.getStartPos()); LogManager.getLogger().info(fallBlock.getPosition().x);
context.getAccessor().setBlock(fallBlock.getBlockInWorld(null), context.setBlock(fallBlock.getBlockInWorld(null),
BlockDataRegistry.getInstance().get("Test:Air")); BlockDataRegistry.getInstance().get("Test:Air"));
fallBlock.setDestroyed(); fallBlock.setDestroyed();
} }
Vec3i occupiedBlock = fallBlock.getBlockInWorld(null); Vec3i occupiedBlock = fallBlock.getBlockInWorld(null);
Vec3i underBlock = occupiedBlock.sub_(0, 0, 1); Vec3i underBlock = occupiedBlock.sub_(getBestCardinal(fallBlock.getUpVector()));
List<Vec3i> underBlocks = getGoodCardinals(fallBlock.getUpVector());
boolean notSupported = false;
for (Vec3i v3 : underBlocks)
{
Vec3i inWorld = occupiedBlock.sub_(v3);
if (context.getBlock(inWorld).getId()=="Test:Air") {
notSupported=true;
break;
}
}
Vec3i chunkCoords = trueDiv(underBlock, new Vec3i(16)); //LogManager.getLogger().info("InChunk
Vec3i inChunkCoords = trueMod(underBlock, new Vec3i(16)); //"+String.valueOf(chunkCoords.x)+" "+String.valueOf(chunkCoords.y)+"
//"+String.valueOf(chunkCoords.z)+" "+String.valueOf(inChunkCoords.x)+"
////"+String.valueOf(inChunkCoords.y)+"
//"+String.valueOf(inChunkCoords.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("InChunk if (context.getBlock(underBlock) != null
// "+String.valueOf(chunkCoords.x)+" "+String.valueOf(chunkCoords.y)+" // && context.getBlock(underBlock).getId() != "Test:Air") {
// "+String.valueOf(chunkCoords.z)+" "+String.valueOf(inChunkCoords.x)+" && !notSupported) {
// "+String.valueOf(inChunkCoords.y)+"
// "+String.valueOf(inChunkCoords.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());
if (context.getWorldData().isBlockLoaded(occupiedBlock)
&& context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId() != "Test:Air") {
LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x) + " " + String.valueOf(occupiedBlock.y) + " " + String.valueOf(occupiedBlock.z)); LogManager.getLogger().info("Deleting FallingBlock at " + String.valueOf(occupiedBlock.x) + " " + String.valueOf(occupiedBlock.y) + " " + String.valueOf(occupiedBlock.z));
// ClientState.getInstance().getWorld().getData().setBlock(occupiedBlock, context.setBlock(occupiedBlock, fallBlock2.getBlock());
// fallBlock.getBlock(),true); fallBlock.setInvisible();
context.getAccessor().setBlock(occupiedBlock, fallBlock.getBlock()); //server.invokeLater(() -> server.getWorld().getData().removeEntity(entity.getEntityId()));
fallBlock.setInvisible(); // Until I know how to properly delete it. context.removeEntity(fallBlock);
//ClientState.getInstance().getWorld().getData().removeEntity(entity.getEntityId());// context.getWorldData().removeEntity(entity.getEntityId());
Server server = context.getServer();
server.invokeLater(() -> server.getWorld().getData().removeEntity(entity.getEntityId()));
} }
} }
} }

View File

@ -1,5 +1,6 @@
package ru.windcorp.progressia.test; package ru.windcorp.progressia.test;
import ru.windcorp.progressia.client.ClientState;
import ru.windcorp.progressia.client.graphics.model.Renderable; import ru.windcorp.progressia.client.graphics.model.Renderable;
import ru.windcorp.progressia.client.graphics.model.ShapeRenderHelper; import ru.windcorp.progressia.client.graphics.model.ShapeRenderHelper;
import ru.windcorp.progressia.client.graphics.model.Shapes; import ru.windcorp.progressia.client.graphics.model.Shapes;
@ -21,7 +22,7 @@ public class TestEntityRenderFallingBlock extends EntityRender {
public TestEntityRenderFallingBlock(String id) { public TestEntityRenderFallingBlock(String id) {
super(id); super(id);
String dflt = "Sand";//(String) TestEntityLogicFallingBlock.FallingBlocks.toArray()[0]; String dflt = TestEntityLogicFallingBlock.FallingBlocks.toArray()[0].toString().substring(5);
cube = new Shapes.PppBuilder(WorldRenderProgram.getDefault(), BlockRenderRegistry.getBlockTexture(dflt ) )// TODO idk actual ggood this cube = new Shapes.PppBuilder(WorldRenderProgram.getDefault(), BlockRenderRegistry.getBlockTexture(dflt ) )// TODO idk actual ggood this
.create(); .create();
} }
@ -34,7 +35,7 @@ public class TestEntityRenderFallingBlock extends EntityRender {
public EntityRenderable createRenderable(EntityData entity) { public EntityRenderable createRenderable(EntityData entity) {
return new EntityRenderable(entity) { return new EntityRenderable(entity) {
@Override @Override
public void render(ShapeRenderHelper renderer) { public void doRender(ShapeRenderHelper renderer) {
// LogManager.getLogger().info("Rendering FallingBlock"); // LogManager.getLogger().info("Rendering FallingBlock");
if (((TestEntityDataFallingBlock) entity).isDone()) { if (((TestEntityDataFallingBlock) entity).isDone()) {
return; return;
@ -42,6 +43,8 @@ public class TestEntityRenderFallingBlock extends EntityRender {
// SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/LogSide"), // SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/LogSide"),
// new AtlasGroup("Blocks", 1 << 12)))); // new AtlasGroup("Blocks", 1 << 12))));
} }
TestEntityDataFallingBlock fallEntity = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
setTexture(BlockRenderRegistry.getBlockTexture(fallEntity.getBlock().getId().substring(5)));
// setTexture(new // setTexture(new
// SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/Sand"), // SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/Sand"),
// new AtlasGroup("Blocks", 1 << 12)))); // new AtlasGroup("Blocks", 1 << 12))));

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package ru.windcorp.progressia.test; package ru.windcorp.progressia.test;
import java.util.ArrayList; import java.util.ArrayList;
@ -25,8 +25,8 @@ import glm.vec._3.Vec3;
import ru.windcorp.progressia.client.graphics.Colors; import ru.windcorp.progressia.client.graphics.Colors;
import ru.windcorp.progressia.client.graphics.backend.GraphicsInterface; import ru.windcorp.progressia.client.graphics.backend.GraphicsInterface;
import ru.windcorp.progressia.client.graphics.backend.Usage; import ru.windcorp.progressia.client.graphics.backend.Usage;
import ru.windcorp.progressia.client.graphics.model.Face; import ru.windcorp.progressia.client.graphics.model.ShapePart;
import ru.windcorp.progressia.client.graphics.model.Faces; import ru.windcorp.progressia.client.graphics.model.ShapeParts;
import ru.windcorp.progressia.client.graphics.model.LambdaModel; import ru.windcorp.progressia.client.graphics.model.LambdaModel;
import ru.windcorp.progressia.client.graphics.model.Renderable; import ru.windcorp.progressia.client.graphics.model.Renderable;
import ru.windcorp.progressia.client.graphics.model.Shape; import ru.windcorp.progressia.client.graphics.model.Shape;
@ -39,8 +39,8 @@ import ru.windcorp.progressia.client.world.entity.EntityRender;
import ru.windcorp.progressia.client.world.entity.EntityRenderRegistry; import ru.windcorp.progressia.client.world.entity.EntityRenderRegistry;
import ru.windcorp.progressia.client.world.entity.EntityRenderable; import ru.windcorp.progressia.client.world.entity.EntityRenderable;
import ru.windcorp.progressia.client.world.entity.QuadripedModel; import ru.windcorp.progressia.client.world.entity.QuadripedModel;
import ru.windcorp.progressia.common.world.block.BlockFace;
import ru.windcorp.progressia.common.world.entity.EntityData; import ru.windcorp.progressia.common.world.entity.EntityData;
import ru.windcorp.progressia.common.world.rels.AbsFace;
public class TestEntityRenderJavapony extends EntityRender { public class TestEntityRenderJavapony extends EntityRender {
@ -54,7 +54,11 @@ public class TestEntityRenderJavapony extends EntityRender {
public TestEntityRenderJavapony(String id) { public TestEntityRenderJavapony(String id) {
super(id); super(id);
ComplexTexture texture = new ComplexTexture(EntityRenderRegistry.getEntityTexture("javapony"), 256, 128); ComplexTexture texture = new ComplexTexture(
EntityRenderRegistry.getEntityTexture("javapony"),
256,
128
);
this.body = createBody(texture); this.body = createBody(texture);
this.head = createHead(texture); this.head = createHead(texture);
@ -71,85 +75,230 @@ public class TestEntityRenderJavapony extends EntityRender {
Texture tailStartTexture = texture.get(128, 96, 8, 32); Texture tailStartTexture = texture.get(128, 96, 8, 32);
b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(), b.addStaticPart(
BlockFace.mapToFaces(tailStartTexture, tailStartTexture, tailStartTexture, tailStartTexture, new PppBuilder(
tailStartTexture, tailStartTexture)).setOrigin(-60, -4, 14).setDepth(32, 0, -16).setWidth(8) WorldRenderProgram.getDefault(),
.setHeight(8).create()); tailStartTexture
)
.setOrigin(-60, -4, 14)
.setDepth(32, 0, -16).setWidth(8).setHeight(8)
.create()
);
Texture neckTexture = texture.get(0, 48, 16, 16); Texture neckTexture = texture.get(0, 48, 16, 16);
b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(), b.addStaticPart(
BlockFace.mapToFaces(neckTexture, neckTexture, neckTexture, neckTexture, neckTexture, neckTexture)) new PppBuilder(
.setOrigin(0, -8, 8).setWidth(16).setDepth(16).setHeight(2, 0, 16).create()); WorldRenderProgram.getDefault(),
neckTexture
)
.setOrigin(0, -8, 8)
.setWidth(16).setDepth(16).setHeight(2, 0, 16)
.create()
);
b.addDynamicPart(createTail(texture), b.addDynamicPart(
m -> m.translate(-60, 0, 24).rotateX(0.05f * Math.sin(GraphicsInterface.getTime())) createTail(texture),
.rotateY(0.05f * Math.sin(Math.PI / 3 * GraphicsInterface.getTime()))); m -> m
.translate(-60, 0, 24)
.rotateX(0.05f * Math.sin(GraphicsInterface.getTime()))
.rotateY(0.05f * Math.sin(Math.PI / 3 * GraphicsInterface.getTime()))
);
return new LambdaModel(b); return new LambdaModel(b);
} }
private static Renderable createMainBody(ComplexTexture texture) { private static Renderable createMainBody(ComplexTexture texture) {
WorldRenderProgram program = WorldRenderProgram.getDefault(); WorldRenderProgram program = WorldRenderProgram.getDefault();
List<Face> faces = new ArrayList<>(); List<ShapePart> faces = new ArrayList<>();
// F BODY // F BODY
faces.add(Faces.createRectangle(program, texture.get(80, 16, 32, 32), Colors.WHITE, new Vec3(+16, -16, -16), faces.add(
new Vec3(0, +32, 0), new Vec3(0, 0, +32), false)); ShapeParts.createRectangle(
program,
texture.get(80, 16, 32, 32),
Colors.WHITE,
new Vec3(+16, -16, -16),
new Vec3(0, +32, 0),
new Vec3(0, 0, +32),
false
)
);
// NECK BASE // NECK BASE
faces.add(Faces.createRectangle(program, texture.get(80, 48, 32, 16), Colors.WHITE, new Vec3(+16, -16, +16), faces.add(
new Vec3(0, +32, 0), new Vec3(-16, 0, 0), false)); ShapeParts.createRectangle(
program,
texture.get(80, 48, 32, 16),
Colors.WHITE,
new Vec3(+16, -16, +16),
new Vec3(0, +32, 0),
new Vec3(-16, 0, 0),
false
)
);
// T BODY (BACK) // T BODY (BACK)
faces.add(Faces.createRectangle(program, texture.get(128, 0, 32, 48), Colors.WHITE, new Vec3(0, -16, +16), faces.add(
new Vec3(0, +32, 0), new Vec3(-48, 0, 0), false)); ShapeParts.createRectangle(
program,
texture.get(128, 0, 32, 48),
Colors.WHITE,
new Vec3(0, -16, +16),
new Vec3(0, +32, 0),
new Vec3(-48, 0, 0),
false
)
);
// BOTTOM B (upper) // BOTTOM B (upper)
faces.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, 0), faces.add(
new Vec3(0, 32, 0), new Vec3(0, 0, 16), true)); ShapeParts.createRectangle(
program,
texture.get(144, 48, 32, 16),
Colors.WHITE,
new Vec3(-48, -16, 0),
new Vec3(0, 32, 0),
new Vec3(0, 0, 16),
true
)
);
// BOTTOM B (lower) // BOTTOM B (lower)
faces.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, -16), faces.add(
new Vec3(0, 32, 0), new Vec3(0, 0, 16), true)); ShapeParts.createRectangle(
program,
texture.get(144, 48, 32, 16),
Colors.WHITE,
new Vec3(-48, -16, -16),
new Vec3(0, 32, 0),
new Vec3(0, 0, 16),
true
)
);
// BOTTOM B (stomach) // BOTTOM B (stomach)
faces.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, -16), faces.add(
new Vec3(0, 32, 0), new Vec3(16, 0, 0), false)); ShapeParts.createRectangle(
program,
texture.get(144, 48, 32, 16),
Colors.WHITE,
new Vec3(-48, -16, -16),
new Vec3(0, 32, 0),
new Vec3(16, 0, 0),
false
)
);
// STOMACH // STOMACH
faces.add(Faces.createRectangle(program, texture.get(224, 96, 32, 32), Colors.WHITE, new Vec3(-32, -16, -16), faces.add(
new Vec3(0, 32, 0), new Vec3(32, 0, 0), false)); ShapeParts.createRectangle(
program,
texture.get(224, 96, 32, 32),
Colors.WHITE,
new Vec3(-32, -16, -16),
new Vec3(0, 32, 0),
new Vec3(32, 0, 0),
false
)
);
// BOTTOM F // BOTTOM F
faces.add(Faces.createRectangle(program, texture.get(112, 48, 32, 16), Colors.WHITE, new Vec3(+16, -16, -16), faces.add(
new Vec3(0, 32, 0), new Vec3(-16, 0, 0), true)); ShapeParts.createRectangle(
program,
texture.get(112, 48, 32, 16),
Colors.WHITE,
new Vec3(+16, -16, -16),
new Vec3(0, 32, 0),
new Vec3(-16, 0, 0),
true
)
);
// BODY L // BODY L
faces.add(Faces.createRectangle(program, texture.get(112, 16, 16, 32), Colors.WHITE, new Vec3(+16, +16, -16), faces.add(
new Vec3(-16, 0, 0), new Vec3(0, 0, +32), false)); ShapeParts.createRectangle(
program,
texture.get(112, 16, 16, 32),
Colors.WHITE,
new Vec3(+16, +16, -16),
new Vec3(-16, 0, 0),
new Vec3(0, 0, +32),
false
)
);
// BODY SIDES (left) // BODY SIDES (left)
faces.add(Faces.createRectangle(program, texture.get(96, 96, 32, 32), Colors.WHITE, new Vec3(0, +16, -16), faces.add(
new Vec3(-32, 0, 0), new Vec3(0, 0, +32), false)); ShapeParts.createRectangle(
program,
texture.get(96, 96, 32, 32),
Colors.WHITE,
new Vec3(0, +16, -16),
new Vec3(-32, 0, 0),
new Vec3(0, 0, +32),
false
)
);
// QT MARK (left) // QT MARK (left)
faces.add(Faces.createRectangle(program, texture.get(16, 96, 16, 32), Colors.WHITE, new Vec3(-32, +16, -16), faces.add(
new Vec3(-16, 0, 0), new Vec3(0, 0, +32), false)); ShapeParts.createRectangle(
program,
texture.get(16, 96, 16, 32),
Colors.WHITE,
new Vec3(-32, +16, -16),
new Vec3(-16, 0, 0),
new Vec3(0, 0, +32),
false
)
);
// BODY R // BODY R
faces.add(Faces.createRectangle(program, texture.get(64, 16, 16, 32), Colors.WHITE, new Vec3(0, -16, -16), faces.add(
new Vec3(+16, 0, 0), new Vec3(0, 0, +32), false)); ShapeParts.createRectangle(
program,
texture.get(64, 16, 16, 32),
Colors.WHITE,
new Vec3(0, -16, -16),
new Vec3(+16, 0, 0),
new Vec3(0, 0, +32),
false
)
);
// BODY SIDES (right) // BODY SIDES (right)
faces.add(Faces.createRectangle(program, texture.get(96, 96, 32, 32), Colors.WHITE, new Vec3(0, -16, -16), faces.add(
new Vec3(-32, 0, 0), new Vec3(0, 0, +32), true)); ShapeParts.createRectangle(
program,
texture.get(96, 96, 32, 32),
Colors.WHITE,
new Vec3(0, -16, -16),
new Vec3(-32, 0, 0),
new Vec3(0, 0, +32),
true
)
);
// QT MARK (right) // QT MARK (right)
faces.add(Faces.createRectangle(program, texture.get(16, 96, 16, 32), Colors.WHITE, new Vec3(-32, -16, -16), faces.add(
new Vec3(-16, 0, 0), new Vec3(0, 0, +32), true)); ShapeParts.createRectangle(
program,
texture.get(16, 96, 16, 32),
Colors.WHITE,
new Vec3(-32, -16, -16),
new Vec3(-16, 0, 0),
new Vec3(0, 0, +32),
true
)
);
return new Shape(Usage.STATIC, program, faces.toArray(new Face[faces.size()])); return new Shape(
Usage.STATIC,
program,
faces.toArray(new ShapePart[faces.size()])
);
} }
private static Renderable createHead(ComplexTexture texture) { private static Renderable createHead(ComplexTexture texture) {
@ -157,42 +306,87 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder(); StaticModel.Builder b = StaticModel.builder();
// Head // Head
b.addPart(new PppBuilder(program, texture.getCuboidTextures(0, 64, 32)).setOrigin(-16, -16, 0).setSize(32) b.addPart(
.create()); new PppBuilder(
program,
texture.getCuboidTextures(0, 64, 32)
).setOrigin(-16, -16, 0).setSize(32).create()
);
final float hairOffset = 1f; final float hairOffset = 1f;
// Hair // Hair
b.addPart(new PppBuilder(program, texture.getCuboidTextures(128, 64, 32)) b.addPart(
.setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset).setSize(32 + 2 * hairOffset).create()); new PppBuilder(
program,
texture.getCuboidTextures(128, 64, 32)
)
.setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset)
.setSize(32 + 2 * hairOffset)
.create()
);
// Right ear // Right ear
b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, -16, 32) b.addPart(
.setSize(8).create()); new PppBuilder(
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, -16, 32).setSize(8).create()
);
// Left ear // Left ear
b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, +16, 32) b.addPart(
.setSize(8, -8, 8).flip().create()); new PppBuilder(
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, +16, 32).setSize(8, -8, 8).flip().create()
);
// Muzzle // Muzzle
b.addPart(new PppBuilder(program, b.addPart(
BlockFace.mapToFaces(texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0), new PppBuilder(
texture.get(32 + 8, 64, 16, 8), texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0), program,
texture.get(32, 64, 0, 0))).setOrigin(16, -8, 0).setSize(4, 16, 8).create()); AbsFace.mapToFaces(
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0),
texture.get(32 + 8, 64, 16, 8),
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0)
)
).setOrigin(16, -8, 0).setSize(4, 16, 8).create()
);
// Nose // Nose
b.addPart(new PppBuilder(program, b.addPart(
BlockFace.mapToFaces(texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0), new PppBuilder(
texture.get(32 + 12, 64 + 8, 8, 4), texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0), program,
texture.get(32, 64, 0, 0))).setOrigin(16, -4, 8).setSize(4, 8, 4).create()); AbsFace.mapToFaces(
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0),
texture.get(32 + 12, 64 + 8, 8, 4),
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0),
texture.get(32, 64, 0, 0)
)
).setOrigin(16, -4, 8).setSize(4, 8, 4).create()
);
return b.build(); return b.build();
} }
private static Renderable createLeg(ComplexTexture texture, int textureX, int textureY, boolean isLeft) { private static Renderable createLeg(
PppBuilder b = new PppBuilder(WorldRenderProgram.getDefault(), ComplexTexture texture,
texture.getCuboidTextures(textureX, textureY, 16, 48, 16)).setOrigin(-8, isLeft ? +8 : -8, -48) int textureX,
.setSize(16, isLeft ? -16 : +16, 48); int textureY,
boolean isLeft
) {
PppBuilder b = new PppBuilder(
WorldRenderProgram.getDefault(),
texture.getCuboidTextures(textureX, textureY, 16, 48, 16)
)
.setOrigin(-8, isLeft ? +8 : -8, -48)
.setSize(16, isLeft ? -16 : +16, 48);
if (isLeft) if (isLeft)
b.flip(); b.flip();
@ -205,26 +399,59 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder(); StaticModel.Builder b = StaticModel.builder();
// Main tail // Main tail
b.addPart(new PppBuilder(program, b.addPart(
BlockFace.mapToFaces(texture.get(128, 96, 16, 16), texture.get(128, 96, 16, 16), new PppBuilder(
texture.get(128, 96, 16, 32), texture.get(128, 96, 16, 32), texture.get(144, 96, 16, 32), program,
texture.get(144, 96, 16, 32))).setOrigin(-8, -8, -32).setSize(16, 16, 32).create()); AbsFace.mapToFaces(
texture.get(128, 96, 16, 16),
texture.get(128, 96, 16, 16),
texture.get(128, 96, 16, 32),
texture.get(128, 96, 16, 32),
texture.get(144, 96, 16, 32),
texture.get(144, 96, 16, 32)
)
).setOrigin(-8, -8, -32).setSize(16, 16, 32).create()
);
return b.build(); return b.build();
} }
@Override @Override
public EntityRenderable createRenderable(EntityData entity) { public EntityRenderable createRenderable(EntityData entity) {
return new QuadripedModel(entity, return new QuadripedModel(
entity,
new QuadripedModel.Body(body), new QuadripedModel.Body(body),
new QuadripedModel.Head(head, new Vec3(12, 0, 20), 120, 45, new Vec3(16, 0, 20)), new QuadripedModel.Head(
new QuadripedModel.Leg(leftForeLeg, new Vec3(6, +8.1f, -16), 0.0f), head,
new QuadripedModel.Leg(rightForeLeg, new Vec3(6, -8.1f, -16), 2.5f), new Vec3(12, 0, 20),
new QuadripedModel.Leg(leftHindLeg, new Vec3(-36, +8.2f, -16), 2.5f), 120,
new QuadripedModel.Leg(rightHindLeg, new Vec3(-36, -8.2f, -16), 0.0f), 45,
new Vec3(16, 0, 20)
),
new QuadripedModel.Leg(
leftForeLeg,
new Vec3(6, +8.1f, -16),
0.0f
),
new QuadripedModel.Leg(
rightForeLeg,
new Vec3(6, -8.1f, -16),
2.5f
),
new QuadripedModel.Leg(
leftHindLeg,
new Vec3(-36, +8.2f, -16),
2.5f
),
new QuadripedModel.Leg(
rightHindLeg,
new Vec3(-36, -8.2f, -16),
0.0f
),
1 / 96f); 1 / 96f
);
} }
} }

View File

@ -22,6 +22,9 @@ import glm.Glm;
import glm.mat._3.Mat3; import glm.mat._3.Mat3;
import glm.mat._4.Mat4; import glm.mat._4.Mat4;
import glm.vec._3.Vec3; import glm.vec._3.Vec3;
import java.util.function.Function;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import ru.windcorp.progressia.client.ClientState; import ru.windcorp.progressia.client.ClientState;
import ru.windcorp.progressia.client.graphics.GUI; import ru.windcorp.progressia.client.graphics.GUI;
@ -58,6 +61,8 @@ public class TestPlayerControls {
// Horizontal and vertical max control speed when flying // Horizontal and vertical max control speed when flying
private static final float FLYING_SPEED = Units.get("6 m/s"); private static final float FLYING_SPEED = Units.get("6 m/s");
private static final Function<Double, Double> SPRINTING_FLYING_SPEED = (f) -> {return Math.pow(f,.75)+2*FLYING_SPEED;};
// (0; 1], 1 is instant change, 0 is no control authority // (0; 1], 1 is instant change, 0 is no control authority
private static final float FLYING_CONTROL_AUTHORITY = Units.get("2 1/s"); private static final float FLYING_CONTROL_AUTHORITY = Units.get("2 1/s");
@ -101,7 +106,8 @@ public class TestPlayerControls {
final float speed, authority; final float speed, authority;
if (isFlying) { if (isFlying) {
speed = FLYING_SPEED; double timeSinceLastSpacePress = GraphicsInterface.getTime() - lastSprintPress;
speed = isSprinting ? SPRINTING_FLYING_SPEED.apply(timeSinceLastSpacePress).floatValue() : FLYING_SPEED;
authority = FLYING_CONTROL_AUTHORITY; authority = FLYING_CONTROL_AUTHORITY;
} else { } else {
speed = isSprinting ? SPRINTING_SPEED : WALKING_SPEED; speed = isSprinting ? SPRINTING_SPEED : WALKING_SPEED;
@ -256,10 +262,11 @@ public class TestPlayerControls {
double timeSinceLastSpacePress = GraphicsInterface.getTime() - lastSpacePress; double timeSinceLastSpacePress = GraphicsInterface.getTime() - lastSpacePress;
if (isPressed && timeSinceLastSpacePress < MODE_SWITCH_MAX_DELAY) { if (isPressed && timeSinceLastSpacePress < MODE_SWITCH_MAX_DELAY) {
isSprinting = false; //isSprinting = false;
isFlying = !isFlying; isFlying = !isFlying;
updateGUI(); updateGUI();
movementUp = +1; movementUp = +1;
timeSinceLastSpacePress = MODE_SWITCH_MAX_DELAY;
} else { } else {
if (isFlying) { if (isFlying) {
movementUp += +1 * multiplier; movementUp += +1 * multiplier;
@ -274,10 +281,12 @@ public class TestPlayerControls {
} }
private void handleSprint(KeyEvent event) { private void handleSprint(KeyEvent event) {
//LogManager.getLogger().info("hi");
double timeSinceLastSpacePress = GraphicsInterface.getTime() - lastSprintPress; double timeSinceLastSpacePress = GraphicsInterface.getTime() - lastSprintPress;
if (event.isPress() && timeSinceLastSpacePress < MODE_SPRINT_SWITCH_MAX_DELAY && !isFlying) { if (event.isPress() && timeSinceLastSpacePress < MODE_SPRINT_SWITCH_MAX_DELAY) {
isSprinting = !isSprinting; isSprinting = !isSprinting;
updateGUI(); updateGUI();
} }