Sand Towers Fall

-The listener in TestWorldGenerator updates any block above it if that block is a block that can be affected by gravity.
-Format happened(I forgot)
This commit is contained in:
opfromthestart 2021-06-10 15:56:15 -04:00
parent 47eb9fa5af
commit 3879e5ffac
24 changed files with 433 additions and 1018 deletions

View File

@ -60,10 +60,7 @@ public class CollisionModelRenderer {
helper.popTransform(); helper.popTransform();
} }
private static void renderCompound( private static void renderCompound(CompoundCollisionModel model, ShapeRenderHelper helper) {
CompoundCollisionModel model,
ShapeRenderHelper helper
) {
for (CollisionModel part : model.getModels()) { for (CollisionModel part : model.getModels()) {
renderCollisionModel(part, helper); renderCollisionModel(part, helper);
} }

View File

@ -38,29 +38,12 @@ public class LayerAbout extends GUILayer {
Font font = new Font().withColor(Colors.WHITE).deriveOutlined().withAlign(Typeface.ALIGN_RIGHT); Font font = new Font().withColor(Colors.WHITE).deriveOutlined().withAlign(Typeface.ALIGN_RIGHT);
Font aboutFont = font.withColor(0xFF37A3E6).deriveBold(); Font aboutFont = font.withColor(0xFF37A3E6).deriveBold();
panel.addChild( panel.addChild(new Label("About", aboutFont, new MutableStringLocalized("LayerAbout.Title")));
new Label(
"About",
aboutFont,
new MutableStringLocalized("LayerAbout.Title")
)
);
panel.addChild( panel.addChild(
new Label( new Label("Version", font, new MutableStringLocalized("LayerAbout.Version").format("pre-alpha 1")));
"Version",
font,
new MutableStringLocalized("LayerAbout.Version").format("pre-alpha 1")
)
);
panel.addChild( panel.addChild(new Label("DebugHint", font, new MutableStringLocalized("LayerAbout.DebugHint")));
new Label(
"DebugHint",
font,
new MutableStringLocalized("LayerAbout.DebugHint")
)
);
getRoot().addChild(panel); getRoot().addChild(panel);

View File

@ -58,146 +58,51 @@ public class LayerTestGUI extends GUILayer {
TestPlayerControls tpc = TestPlayerControls.getInstance(); TestPlayerControls tpc = TestPlayerControls.getInstance();
panel.addChild( panel.addChild(
new Label( new Label("IsFlyingDisplay", font, tmp_dynFormat("LayerTestGUI.IsFlyingDisplay", tpc::isFlying)));
"IsFlyingDisplay",
font, panel.addChild(new Label("IsSprintingDisplay", font,
tmp_dynFormat("LayerTestGUI.IsFlyingDisplay", tpc::isFlying) tmp_dynFormat("LayerTestGUI.IsSprintingDisplay", tpc::isSprinting)));
)
); panel.addChild(new Label("IsMouseCapturedDisplay", font,
tmp_dynFormat("LayerTestGUI.IsMouseCapturedDisplay", tpc::isMouseCaptured)));
panel.addChild(new Label("CameraModeDisplay", font, tmp_dynFormat("LayerTestGUI.CameraModeDisplay",
ClientState.getInstance().getCamera()::getCurrentModeIndex)));
panel.addChild(new Label("GravityModeDisplay", font, tmp_dynFormat("LayerTestGUI.GravityModeDisplay",
() -> tpc.useMinecraftGravity() ? "Minecraft" : "Realistic")));
panel.addChild(new Label("LanguageDisplay", font,
tmp_dynFormat("LayerTestGUI.LanguageDisplay", Localizer.getInstance()::getLanguage)));
panel.addChild(new Label("FullscreenDisplay", font,
tmp_dynFormat("LayerTestGUI.IsFullscreen", GraphicsBackend::isFullscreen)));
panel.addChild(new Label("VSyncDisplay", font,
tmp_dynFormat("LayerTestGUI.IsVSync", GraphicsBackend::isVSyncEnabled)));
panel.addChild( panel.addChild(
new Label( new DynamicLabel("FPSDisplay", font,
"IsSprintingDisplay", DynamicStrings.builder().addDyn(new MutableStringLocalized("LayerTestGUI.FPSDisplay"))
font, .addDyn(() -> FPS_RECORD.update(GraphicsInterface.getFPS()), 5, 1).buildSupplier(),
tmp_dynFormat("LayerTestGUI.IsSprintingDisplay", tpc::isSprinting) 128));
)
); panel.addChild(new DynamicLabel("TPSDisplay", font, LayerTestGUI::getTPS, 128));
panel.addChild( panel.addChild(
new Label( new DynamicLabel("ChunkUpdatesDisplay", font,
"IsMouseCapturedDisplay", DynamicStrings.builder().addDyn(new MutableStringLocalized("LayerTestGUI.ChunkUpdatesDisplay"))
font, .addDyn(ClientState.getInstance().getWorld()::getPendingChunkUpdates).buildSupplier(),
tmp_dynFormat("LayerTestGUI.IsMouseCapturedDisplay", tpc::isMouseCaptured) 128));
)
);
panel.addChild( panel.addChild(new DynamicLabel("PosDisplay", font, LayerTestGUI::getPos, 128));
new Label(
"CameraModeDisplay",
font,
tmp_dynFormat(
"LayerTestGUI.CameraModeDisplay",
ClientState.getInstance().getCamera()::getCurrentModeIndex
)
)
);
panel.addChild( panel.addChild(new Label("SelectedBlockDisplay", font, tmp_dynFormat("LayerTestGUI.SelectedBlockDisplay",
new Label( () -> tpc.isBlockSelected() ? ">" : " ", () -> tpc.getSelectedBlock().getId())));
"GravityModeDisplay", panel.addChild(new Label("SelectedTileDisplay", font, tmp_dynFormat("LayerTestGUI.SelectedTileDisplay",
font, () -> tpc.isBlockSelected() ? " " : ">", () -> tpc.getSelectedTile().getId())));
tmp_dynFormat( panel.addChild(new Label("PlacementModeHint", font,
"LayerTestGUI.GravityModeDisplay", new MutableStringLocalized("LayerTestGUI.PlacementModeHint").format("\u2B04")));
() -> tpc.useMinecraftGravity() ? "Minecraft" : "Realistic"
)
)
);
panel.addChild(
new Label(
"LanguageDisplay",
font,
tmp_dynFormat("LayerTestGUI.LanguageDisplay", Localizer.getInstance()::getLanguage)
)
);
panel.addChild(
new Label(
"FullscreenDisplay",
font,
tmp_dynFormat("LayerTestGUI.IsFullscreen", GraphicsBackend::isFullscreen)
)
);
panel.addChild(
new Label(
"VSyncDisplay",
font,
tmp_dynFormat("LayerTestGUI.IsVSync", GraphicsBackend::isVSyncEnabled)
)
);
panel.addChild(
new DynamicLabel(
"FPSDisplay",
font,
DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.FPSDisplay"))
.addDyn(() -> FPS_RECORD.update(GraphicsInterface.getFPS()), 5, 1)
.buildSupplier(),
128
)
);
panel.addChild(
new DynamicLabel(
"TPSDisplay",
font,
LayerTestGUI::getTPS,
128
)
);
panel.addChild(
new DynamicLabel(
"ChunkUpdatesDisplay",
font,
DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.ChunkUpdatesDisplay"))
.addDyn(ClientState.getInstance().getWorld()::getPendingChunkUpdates)
.buildSupplier(),
128
)
);
panel.addChild(
new DynamicLabel(
"PosDisplay",
font,
LayerTestGUI::getPos,
128
)
);
panel.addChild(
new Label(
"SelectedBlockDisplay",
font,
tmp_dynFormat(
"LayerTestGUI.SelectedBlockDisplay",
() -> tpc.isBlockSelected() ? ">" : " ",
() -> tpc.getSelectedBlock().getId()
)
)
);
panel.addChild(
new Label(
"SelectedTileDisplay",
font,
tmp_dynFormat(
"LayerTestGUI.SelectedTileDisplay",
() -> tpc.isBlockSelected() ? " " : ">",
() -> tpc.getSelectedTile().getId()
)
)
);
panel.addChild(
new Label(
"PlacementModeHint",
font,
new MutableStringLocalized("LayerTestGUI.PlacementModeHint").format("\u2B04")
)
);
getRoot().addChild(panel); getRoot().addChild(panel);
} }
@ -266,15 +171,13 @@ public class LayerTestGUI extends GUILayer {
private static final Supplier<CharSequence> TPS_STRING = DynamicStrings.builder() private static final Supplier<CharSequence> TPS_STRING = DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.TPSDisplay")) .addDyn(new MutableStringLocalized("LayerTestGUI.TPSDisplay"))
.addDyn(() -> TPS_RECORD.update(ServerState.getInstance().getTPS()), 5, 1) .addDyn(() -> TPS_RECORD.update(ServerState.getInstance().getTPS()), 5, 1).buildSupplier();
.buildSupplier();
private static final Supplier<CharSequence> POS_STRING = DynamicStrings.builder() private static final Supplier<CharSequence> POS_STRING = DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.PosDisplay")) .addDyn(new MutableStringLocalized("LayerTestGUI.PosDisplay"))
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().x, 7, 1) .addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().x, 7, 1)
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().y, 7, 1) .addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().y, 7, 1)
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().z, 7, 1) .addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().z, 7, 1).buildSupplier();
.buildSupplier();
private static CharSequence getTPS() { private static CharSequence getTPS() {
Server server = ServerState.getInstance(); Server server = ServerState.getInstance();
@ -361,7 +264,8 @@ public class LayerTestGUI extends GUILayer {
// //
// Panel panel = new Panel("Alex", new LayoutVertical(5)); // Panel panel = new Panel("Alex", new LayoutVertical(5));
// //
// panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100), 0x44FF44)); // panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100),
// 0x44FF44));
// //
// Component charlie = new DebugComponent("Charlie", null, 0x222222); // Component charlie = new DebugComponent("Charlie", null, 0x222222);
// charlie.setLayout(new LayoutVertical(5)); // charlie.setLayout(new LayoutVertical(5));
@ -369,7 +273,8 @@ public class LayerTestGUI extends GUILayer {
// //Debug // //Debug
// Localizer.getInstance().setLanguage("ru-RU"); // Localizer.getInstance().setLanguage("ru-RU");
// MutableString epsilon = new MutableStringLocalized("Epsilon") // MutableString epsilon = new MutableStringLocalized("Epsilon")
// .addListener(() -> ((Label)charlie.getChild(0)).update()).format(34, "thirty-four"); // .addListener(() -> ((Label)charlie.getChild(0)).update()).format(34,
// "thirty-four");
// // These two are swapped in code due to a bug in layouts, fixing ATM // // These two are swapped in code due to a bug in layouts, fixing ATM
// charlie.addChild( // charlie.addChild(
// new Label( // new Label(

View File

@ -75,17 +75,10 @@ public class LayerTestUI extends AssembledFlatLayer {
target.drawTexture(texShadow, -texShadow, texSize, texSize, Colors.BLACK, compassBg); target.drawTexture(texShadow, -texShadow, texSize, texSize, Colors.BLACK, compassBg);
target.drawTexture(0, 0, texSize, texSize, compassBg); target.drawTexture(0, 0, texSize, texSize, compassBg);
target.addCustomRenderer( target.addCustomRenderer(new LambdaModel(LambdaModel.lambdaBuilder().addDynamicPart(
new LambdaModel(
LambdaModel.lambdaBuilder()
.addDynamicPart(
target.createRectagle(0, 0, texSize, texSize, Colors.WHITE, compassFg), target.createRectagle(0, 0, texSize, texSize, Colors.WHITE, compassFg),
mat -> mat.translate(texSize / 2, texSize / 2, 0) mat -> mat.translate(texSize / 2, texSize / 2, 0).rotateZ(getCompassRotation()).translate(-texSize / 2,
.rotateZ(getCompassRotation()) -texSize / 2, 0))));
.translate(-texSize / 2, -texSize / 2, 0)
)
)
);
target.popTransform(); target.popTransform();
drawCross(target); drawCross(target);
@ -110,37 +103,15 @@ public class LayerTestUI extends AssembledFlatLayer {
final Vec4 borderColor = Colors.BLACK; final Vec4 borderColor = Colors.BLACK;
final Vec4 fillColor = Colors.WHITE; final Vec4 fillColor = Colors.WHITE;
target.fill( target.fill(cx - length - thickness / 2, cy - thickness / 2, 2 * length + thickness, thickness, borderColor);
cx - length - thickness / 2,
cy - thickness / 2,
2 * length + thickness,
thickness,
borderColor
);
target.fill( target.fill(cx - thickness / 2, cy - length - thickness / 2, thickness, 2 * length + thickness, borderColor);
cx - thickness / 2,
cy - length - thickness / 2,
thickness,
2 * length + thickness,
borderColor
);
target.fill( target.fill(cx - length - thickness / 2 + borderSize, cy - thickness / 2 + borderSize,
cx - length - thickness / 2 + borderSize, 2 * length + thickness - 2 * borderSize, thickness - 2 * borderSize, fillColor);
cy - thickness / 2 + borderSize,
2 * length + thickness - 2 * borderSize,
thickness - 2 * borderSize,
fillColor
);
target.fill( target.fill(cx - thickness / 2 + borderSize, cy - length - thickness / 2 + borderSize,
cx - thickness / 2 + borderSize, thickness - 2 * borderSize, 2 * length + thickness - 2 * borderSize, fillColor);
cy - length - thickness / 2 + borderSize,
thickness - 2 * borderSize,
2 * length + thickness - 2 * borderSize,
fillColor
);
} }
@Override @Override

View File

@ -85,8 +85,7 @@ public class TestChunkCodec extends ChunkCodec {
@Override @Override
public ChunkData decode(WorldData world, Vec3i position, DataInputStream input, IOContext context) public ChunkData decode(WorldData world, Vec3i position, DataInputStream input, IOContext context)
throws DecodingException, throws DecodingException, IOException {
IOException {
BlockData[] blockPalette = readBlockPalette(input); BlockData[] blockPalette = readBlockPalette(input);
TileData[] tilePalette = readTilePalette(input); TileData[] tilePalette = readTilePalette(input);

View File

@ -129,17 +129,9 @@ public class TestContent {
register(new BlockLogic("Test:Concrete")); register(new BlockLogic("Test:Concrete"));
register(new BlockData("Test:Log")); register(new BlockData("Test:Log"));
register( register(new BlockRenderOpaqueCube("Test:Log", getBlockTexture("LogTop"), getBlockTexture("LogTop"),
new BlockRenderOpaqueCube( getBlockTexture("LogSide"), getBlockTexture("LogSide"), getBlockTexture("LogSide"),
"Test:Log", getBlockTexture("LogSide")));
getBlockTexture("LogTop"),
getBlockTexture("LogTop"),
getBlockTexture("LogSide"),
getBlockTexture("LogSide"),
getBlockTexture("LogSide"),
getBlockTexture("LogSide")
)
);
register(new BlockLogic("Test:Log")); register(new BlockLogic("Test:Log"));
register(new BlockData("Test:WoodenPlank")); register(new BlockData("Test:WoodenPlank"));
@ -257,49 +249,24 @@ public class TestContent {
ControlLogicRegistry logic = ControlLogicRegistry.getInstance(); ControlLogicRegistry logic = ControlLogicRegistry.getInstance();
data.register("Test:BreakBlock", ControlBreakBlockData::new); data.register("Test:BreakBlock", ControlBreakBlockData::new);
triggers.register( triggers.register(ControlTriggers.of("Test:BreakBlock", KeyEvent.class, TestContent::onBlockBreakTrigger,
ControlTriggers.of( KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_LEFT).matcher(), i -> isAnythingSelected()));
"Test:BreakBlock",
KeyEvent.class,
TestContent::onBlockBreakTrigger,
KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_LEFT).matcher(),
i -> isAnythingSelected()
)
);
logic.register(ControlLogic.of("Test:BreakBlock", TestContent::onBlockBreakReceived)); logic.register(ControlLogic.of("Test:BreakBlock", TestContent::onBlockBreakReceived));
data.register("Test:PlaceBlock", ControlPlaceBlockData::new); data.register("Test:PlaceBlock", ControlPlaceBlockData::new);
triggers.register( triggers.register(ControlTriggers.of("Test:PlaceBlock", KeyEvent.class, TestContent::onBlockPlaceTrigger,
ControlTriggers.of(
"Test:PlaceBlock",
KeyEvent.class,
TestContent::onBlockPlaceTrigger,
KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_RIGHT).matcher(), KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_RIGHT).matcher(),
i -> isAnythingSelected() && TestPlayerControls.getInstance().isBlockSelected() i -> isAnythingSelected() && TestPlayerControls.getInstance().isBlockSelected()));
)
);
logic.register(ControlLogic.of("Test:PlaceBlock", TestContent::onBlockPlaceReceived)); logic.register(ControlLogic.of("Test:PlaceBlock", TestContent::onBlockPlaceReceived));
data.register("Test:PlaceTile", ControlPlaceTileData::new); data.register("Test:PlaceTile", ControlPlaceTileData::new);
triggers.register( triggers.register(ControlTriggers.of("Test:PlaceTile", KeyEvent.class, TestContent::onTilePlaceTrigger,
ControlTriggers.of(
"Test:PlaceTile",
KeyEvent.class,
TestContent::onTilePlaceTrigger,
KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_RIGHT).matcher(), KeyMatcher.of(GLFW.GLFW_MOUSE_BUTTON_RIGHT).matcher(),
i -> isAnythingSelected() && !TestPlayerControls.getInstance().isBlockSelected() i -> isAnythingSelected() && !TestPlayerControls.getInstance().isBlockSelected()));
)
);
logic.register(ControlLogic.of("Test:PlaceTile", TestContent::onTilePlaceReceived)); logic.register(ControlLogic.of("Test:PlaceTile", TestContent::onTilePlaceReceived));
triggers.register( triggers.register(ControlTriggers.localOf("Test:StartNextMusic", KeyEvent.class, TestMusicPlayer::startNextNow,
ControlTriggers.localOf( KeyMatcher.of(GLFW.GLFW_KEY_M).matcher()));
"Test:StartNextMusic",
KeyEvent.class,
TestMusicPlayer::startNextNow,
KeyMatcher.of(GLFW.GLFW_KEY_M).matcher()
)
);
} }
private static void register(BlockData x) { private static void register(BlockData x) {
@ -310,17 +277,11 @@ public class TestContent {
TileDataRegistry.getInstance().register(x); TileDataRegistry.getInstance().register(x);
} }
private static void register( private static void register(String id, Factory<EntityData> factory) {
String id,
Factory<EntityData> factory
) {
EntityDataRegistry.getInstance().register(id, factory); EntityDataRegistry.getInstance().register(id, factory);
} }
private static void registerEntityData( private static void registerEntityData(String id, Consumer<EntityData> transform) {
String id,
Consumer<EntityData> transform
) {
EntityDataRegistry.getInstance().register(id, new Factory<EntityData>() { EntityDataRegistry.getInstance().register(id, new Factory<EntityData>() {
@Override @Override
public EntityData build() { public EntityData build() {
@ -379,27 +340,19 @@ public class TestContent {
sfx.play(false); sfx.play(false);
} }
private static void onBlockBreakReceived( private static void onBlockBreakReceived(Server server, PacketControl packet,
Server server, ru.windcorp.progressia.server.comms.Client client) {
PacketControl packet,
ru.windcorp.progressia.server.comms.Client client
) {
Vec3i blockInWorld = ((ControlBreakBlockData) packet.getControl()).getBlockInWorld(); Vec3i blockInWorld = ((ControlBreakBlockData) packet.getControl()).getBlockInWorld();
server.getWorldAccessor().setBlock(blockInWorld, BlockDataRegistry.getInstance().get("Test:Air")); server.getWorldAccessor().setBlock(blockInWorld, BlockDataRegistry.getInstance().get("Test:Air"));
} }
private static void onBlockPlaceTrigger(ControlData control) { private static void onBlockPlaceTrigger(ControlData control) {
((ControlPlaceBlockData) control).set( ((ControlPlaceBlockData) control).set(TestPlayerControls.getInstance().getSelectedBlock(),
TestPlayerControls.getInstance().getSelectedBlock(), getSelection().getBlock().add_(getSelection().getSurface().getVector()));
getSelection().getBlock().add_(getSelection().getSurface().getVector())
);
} }
private static void onBlockPlaceReceived( private static void onBlockPlaceReceived(Server server, PacketControl packet,
Server server, ru.windcorp.progressia.server.comms.Client client) {
PacketControl packet,
ru.windcorp.progressia.server.comms.Client client
) {
ControlPlaceBlockData controlData = ((ControlPlaceBlockData) packet.getControl()); ControlPlaceBlockData controlData = ((ControlPlaceBlockData) packet.getControl());
BlockData block = controlData.getBlock(); BlockData block = controlData.getBlock();
Vec3i blockInWorld = controlData.getBlockInWorld(); Vec3i blockInWorld = controlData.getBlockInWorld();
@ -409,18 +362,12 @@ public class TestContent {
} }
private static void onTilePlaceTrigger(ControlData control) { private static void onTilePlaceTrigger(ControlData control) {
((ControlPlaceTileData) control).set( ((ControlPlaceTileData) control).set(TestPlayerControls.getInstance().getSelectedTile(),
TestPlayerControls.getInstance().getSelectedTile(), getSelection().getBlock(), getSelection().getSurface());
getSelection().getBlock(),
getSelection().getSurface()
);
} }
private static void onTilePlaceReceived( private static void onTilePlaceReceived(Server server, PacketControl packet,
Server server, ru.windcorp.progressia.server.comms.Client client) {
PacketControl packet,
ru.windcorp.progressia.server.comms.Client client
) {
ControlPlaceTileData controlData = ((ControlPlaceTileData) packet.getControl()); ControlPlaceTileData controlData = ((ControlPlaceTileData) packet.getControl());
TileData tile = controlData.getTile(); TileData tile = controlData.getTile();
Vec3i blockInWorld = controlData.getBlockInWorld(); Vec3i blockInWorld = controlData.getBlockInWorld();

View File

@ -6,6 +6,7 @@ import ru.windcorp.progressia.common.world.entity.EntityData;
/** /**
* Data for Test:FallingBlock * Data for Test:FallingBlock
*
* @author opfromthestart * @author opfromthestart
* *
*/ */
@ -25,30 +26,25 @@ public class TestEntityDataFallingBlock extends EntityData {
block = blockInput; block = blockInput;
} }
public void setDestroyed() public void setDestroyed() {
{
hasDeleted = true; hasDeleted = true;
} }
public boolean hasDestroyed() public boolean hasDestroyed() {
{
return hasDeleted; return hasDeleted;
} }
public BlockData getBlock() public BlockData getBlock() {
{
return block; return block;
} }
public void setInvisible() public void setInvisible() {
{
// block = new BlockData("Test:Log"); // block = new BlockData("Test:Log");
isDone = true; isDone = true;
setCollisionModel(new AABB(0, 0, 0, .5f, 0.5f, 0.5f)); setCollisionModel(new AABB(0, 0, 0, .5f, 0.5f, 0.5f));
} }
public boolean isDone() public boolean isDone() {
{
return isDone; return isDone;
} }
} }

View File

@ -15,6 +15,7 @@ import ru.windcorp.progressia.server.world.entity.EntityLogic;
/** /**
* Logic for Test:FallingBlock * Logic for Test:FallingBlock
*
* @author opfromthestart * @author opfromthestart
* *
*/ */
@ -22,8 +23,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
public static Set<String> FallingBlocks = new HashSet<String>(); public static Set<String> FallingBlocks = new HashSet<String>();
public void addFallables() public void addFallables() {
{
FallingBlocks.add("Test:Sand"); FallingBlocks.add("Test:Sand");
} }
@ -32,12 +32,14 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
addFallables(); addFallables();
} }
private Vec3i trueMod(Vec3i input,Vec3i modulus) //Move this to a class in Vec or something private Vec3i trueMod(Vec3i input, Vec3i modulus) // Move this to a class in
// Vec or something
{ {
return input.mod_(modulus).add_(modulus).mod_(modulus); return input.mod_(modulus).add_(modulus).mod_(modulus);
} }
private Vec3i trueDiv(Vec3i input,Vec3i divisor) //Move this to a class in Vec or something private Vec3i trueDiv(Vec3i input, Vec3i divisor) // Move this to a class in
// Vec or something
{ {
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));
@ -45,13 +47,14 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
} }
@Override @Override
public void tick(EntityData entity, TickContext context) { //context.getWorldData() ClientState.getInstance().getWorld().getData() public void tick(EntityData entity, TickContext context) { // context.getWorldData()
if (entity == null) // ClientState.getInstance().getWorld().getData()
{ if (entity == null) {
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
@ -60,18 +63,18 @@ 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()); //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))) {
{
return; return;
} }
if (!fallBlock.hasDestroyed()) if (!fallBlock.hasDestroyed()) {
{
// LogManager.getLogger().info(fallBlock.getStartPos()); // LogManager.getLogger().info(fallBlock.getStartPos());
context.getAccessor().setBlock(fallBlock.getBlockInWorld(null), BlockDataRegistry.getInstance().get("Test:Air")); context.getAccessor().setBlock(fallBlock.getBlockInWorld(null),
BlockDataRegistry.getInstance().get("Test:Air"));
fallBlock.setDestroyed(); fallBlock.setDestroyed();
} }
@ -81,14 +84,22 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
Vec3i chunkCoords = trueDiv(underBlock, new Vec3i(16)); Vec3i chunkCoords = trueDiv(underBlock, new Vec3i(16));
Vec3i inChunkCoords = trueMod(underBlock, new Vec3i(16)); Vec3i inChunkCoords = trueMod(underBlock, new Vec3i(16));
//LogManager.getLogger().info("InChunk "+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("InChunk
//LogManager.getLogger().info("FallingBlock is at "+String.valueOf(occupiedBlock.x)+" "+String.valueOf(occupiedBlock.y)+" "+String.valueOf(occupiedBlock.z)); // "+String.valueOf(chunkCoords.x)+" "+String.valueOf(chunkCoords.y)+"
//LogManager.getLogger().info("Block is of type " + context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId()); // "+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());
if (context.getWorldData().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);
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());

View File

@ -41,10 +41,12 @@ public class TestEntityRenderFallingBlock extends EntityRender {
// LogManager.getLogger().info("Rendering FallingBlock"); // LogManager.getLogger().info("Rendering FallingBlock");
if (((TestEntityDataFallingBlock) entity).isDone()) { if (((TestEntityDataFallingBlock) entity).isDone()) {
return; return;
//setTexture(new SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/LogSide"), // setTexture(new
// SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/LogSide"),
// new AtlasGroup("Blocks", 1 << 12)))); // new AtlasGroup("Blocks", 1 << 12))));
} }
//setTexture(new SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/Sand"), // setTexture(new
// SimpleTexture(Atlases.getSprite(ResourceManager.getTextureResource("blocks/Sand"),
// new AtlasGroup("Blocks", 1 << 12)))); // new AtlasGroup("Blocks", 1 << 12))));
cube.render(renderer); cube.render(renderer);
} }

View File

@ -56,11 +56,7 @@ public class TestEntityRenderHuman extends EntityRender {
this.skin = fetchSkin(); this.skin = fetchSkin();
ComplexTexture texture = new ComplexTexture( ComplexTexture texture = new ComplexTexture(this.skin, 16, 16);
this.skin,
16,
16
);
this.body = createBody(texture); this.body = createBody(texture);
this.head = createHead(texture); this.head = createHead(texture);
@ -80,109 +76,37 @@ public class TestEntityRenderHuman extends EntityRender {
} }
private Renderable createBody(ComplexTexture texture) { private Renderable createBody(ComplexTexture texture) {
return createLayeredCuboid( return createLayeredCuboid(texture, 4, 8, 4, 4, 2, 3, 1, -0.5f, -1, 3, 1, 2, 3);
texture,
4,
8,
4,
4,
2,
3,
1,
-0.5f,
-1,
3,
1,
2,
3
);
} }
private Renderable createHead(ComplexTexture texture) { private Renderable createHead(ComplexTexture texture) {
return createLayeredCuboid( return createLayeredCuboid(texture, 0, 12, 8, 12, 2, 2, 2, -1, -1, 0, 2, 2, 2);
texture,
0,
12,
8,
12,
2,
2,
2,
-1,
-1,
0,
2,
2,
2
);
} }
private Renderable createLimb( private Renderable createLimb(ComplexTexture texture, int tx, int ty, int tx2, int ty2, boolean isArm,
ComplexTexture texture, boolean isLeft) {
int tx, Renderable model = createLayeredCuboid(texture, tx, ty, tx2, ty2, 1, 3, 1, -0.5f, -0.5f, isArm ? -2.5f : -3f, 1,
int ty, 1, 3);
int tx2,
int ty2,
boolean isArm,
boolean isLeft
) {
Renderable model = createLayeredCuboid(
texture,
tx,
ty,
tx2,
ty2,
1,
3,
1,
-0.5f,
-0.5f,
isArm ? -2.5f : -3f,
1,
1,
3
);
if (isArm) { if (isArm) {
return LambdaModel.animate( return LambdaModel.animate(model, mat -> {
model,
mat -> {
double phase = GraphicsInterface.getTime() + (isLeft ? 0 : Math.PI / 3); double phase = GraphicsInterface.getTime() + (isLeft ? 0 : Math.PI / 3);
mat.rotateX((isLeft ? +1 : -1) * 1 / 40f * (sin(phase) + 1)); mat.rotateX((isLeft ? +1 : -1) * 1 / 40f * (sin(phase) + 1));
mat.rotateY(1 / 20f * sin(Math.PI / 3 * phase)); mat.rotateY(1 / 20f * sin(Math.PI / 3 * phase));
} });
);
} else { } else {
return model; return model;
} }
} }
private Renderable createLayeredCuboid( private Renderable createLayeredCuboid(ComplexTexture texture, int tx, int ty, int tx2, int ty2, int tw, int th,
ComplexTexture texture, int td, float ox, float oy, float oz, float sx, float sy, float sz) {
int tx,
int ty,
int tx2,
int ty2,
int tw,
int th,
int td,
float ox,
float oy,
float oz,
float sx,
float sy,
float sz
) {
WorldRenderProgram program = WorldRenderProgram.getDefault(); WorldRenderProgram program = WorldRenderProgram.getDefault();
StaticModel.Builder b = StaticModel.builder(); StaticModel.Builder b = StaticModel.builder();
// First layer // First layer
b.addPart( b.addPart(new PppBuilder(program, texture.getCuboidTextures(tx, ty, tw, th, td)).setOrigin(ox, oy, oz)
new PppBuilder( .setSize(sx, sy, sz).create());
program,
texture.getCuboidTextures(tx, ty, tw, th, td)
).setOrigin(ox, oy, oz).setSize(sx, sy, sz).create()
);
ox -= SECOND_LAYER_OFFSET; ox -= SECOND_LAYER_OFFSET;
oy -= SECOND_LAYER_OFFSET; oy -= SECOND_LAYER_OFFSET;
@ -193,54 +117,24 @@ public class TestEntityRenderHuman extends EntityRender {
sz += SECOND_LAYER_OFFSET * 2; sz += SECOND_LAYER_OFFSET * 2;
// Second layer // Second layer
b.addPart( b.addPart(new PppBuilder(program, texture.getCuboidTextures(tx2, ty2, tw, th, td)).setOrigin(ox, oy, oz)
new PppBuilder( .setSize(sx, sy, sz).create());
program,
texture.getCuboidTextures(tx2, ty2, tw, th, td)
).setOrigin(ox, oy, oz).setSize(sx, sy, sz).create()
);
return b.build(); return b.build();
} }
@Override @Override
public EntityRenderable createRenderable(EntityData entity) { public EntityRenderable createRenderable(EntityData entity) {
return new HumanoidModel( return new HumanoidModel(entity,
entity,
new HumanoidModel.Body(body), new HumanoidModel.Body(body),
new HumanoidModel.Head( new HumanoidModel.Head(head, new Vec3(0, 0, 6), 70, 25, new Vec3(1.2f, 0, 1.5f)),
head, new HumanoidModel.Arm(leftArm, new Vec3(0, +1.5f, 3 + 3 - 0.5f), 0.0f),
new Vec3(0, 0, 6), new HumanoidModel.Arm(rightArm, new Vec3(0, -1.5f, 3 + 3 - 0.5f), FloatMathUtil.PI_F),
70, new HumanoidModel.Leg(leftLeg, new Vec3(0, +0.5f, 3), FloatMathUtil.PI_F),
25, new HumanoidModel.Leg(rightLeg, new Vec3(0, -0.5f, 3), 0.0f),
new Vec3(1.2f, 0, 1.5f)
),
new HumanoidModel.Arm(
leftArm,
new Vec3(0, +1.5f, 3 + 3 - 0.5f),
0.0f
),
new HumanoidModel.Arm(
rightArm,
new Vec3(0, -1.5f, 3 + 3 - 0.5f),
FloatMathUtil.PI_F
),
new HumanoidModel.Leg(
leftLeg,
new Vec3(0, +0.5f, 3),
FloatMathUtil.PI_F
),
new HumanoidModel.Leg(
rightLeg,
new Vec3(0, -0.5f, 3),
0.0f
),
1.8f / (3 + 3 + 2) 1.8f / (3 + 3 + 2)).setWalkingArmSwing((float) toRadians(30)).setWalkingLegSwing((float) toRadians(50))
)
.setWalkingArmSwing((float) toRadians(30))
.setWalkingLegSwing((float) toRadians(50))
.setWalkingFrequency(0.15f / 60.0f); .setWalkingFrequency(0.15f / 60.0f);
} }

View File

@ -54,11 +54,7 @@ public class TestEntityRenderJavapony extends EntityRender {
public TestEntityRenderJavapony(String id) { public TestEntityRenderJavapony(String id) {
super(id); super(id);
ComplexTexture texture = new ComplexTexture( ComplexTexture texture = new ComplexTexture(EntityRenderRegistry.getEntityTexture("javapony"), 256, 128);
EntityRenderRegistry.getEntityTexture("javapony"),
256,
128
);
this.body = createBody(texture); this.body = createBody(texture);
this.head = createHead(texture); this.head = createHead(texture);
@ -75,49 +71,20 @@ public class TestEntityRenderJavapony extends EntityRender {
Texture tailStartTexture = texture.get(128, 96, 8, 32); Texture tailStartTexture = texture.get(128, 96, 8, 32);
b.addStaticPart( b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(),
new PppBuilder( BlockFace.mapToFaces(tailStartTexture, tailStartTexture, tailStartTexture, tailStartTexture,
WorldRenderProgram.getDefault(), tailStartTexture, tailStartTexture)).setOrigin(-60, -4, 14).setDepth(32, 0, -16).setWidth(8)
BlockFace.mapToFaces( .setHeight(8).create());
tailStartTexture,
tailStartTexture,
tailStartTexture,
tailStartTexture,
tailStartTexture,
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( b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(),
new PppBuilder( BlockFace.mapToFaces(neckTexture, neckTexture, neckTexture, neckTexture, neckTexture, neckTexture))
WorldRenderProgram.getDefault(), .setOrigin(0, -8, 8).setWidth(16).setDepth(16).setHeight(2, 0, 16).create());
BlockFace.mapToFaces(
neckTexture,
neckTexture,
neckTexture,
neckTexture,
neckTexture,
neckTexture
)
)
.setOrigin(0, -8, 8)
.setWidth(16).setDepth(16).setHeight(2, 0, 16)
.create()
);
b.addDynamicPart( b.addDynamicPart(createTail(texture),
createTail(texture), m -> m.translate(-60, 0, 24).rotateX(0.05f * Math.sin(GraphicsInterface.getTime()))
m -> m .rotateY(0.05f * Math.sin(Math.PI / 3 * GraphicsInterface.getTime())));
.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);
} }
@ -127,192 +94,62 @@ public class TestEntityRenderJavapony extends EntityRender {
List<Face> faces = new ArrayList<>(); List<Face> faces = new ArrayList<>();
// F BODY // F BODY
faces.add( faces.add(Faces.createRectangle(program, texture.get(80, 16, 32, 32), Colors.WHITE, new Vec3(+16, -16, -16),
Faces.createRectangle( new Vec3(0, +32, 0), new Vec3(0, 0, +32), false));
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.add(Faces.createRectangle(program, texture.get(80, 48, 32, 16), Colors.WHITE, new Vec3(+16, -16, +16),
Faces.createRectangle( new Vec3(0, +32, 0), new Vec3(-16, 0, 0), false));
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.add(Faces.createRectangle(program, texture.get(128, 0, 32, 48), Colors.WHITE, new Vec3(0, -16, +16),
Faces.createRectangle( new Vec3(0, +32, 0), new Vec3(-48, 0, 0), false));
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.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, 0),
Faces.createRectangle( new Vec3(0, 32, 0), new Vec3(0, 0, 16), true));
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.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, -16),
Faces.createRectangle( new Vec3(0, 32, 0), new Vec3(0, 0, 16), true));
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.add(Faces.createRectangle(program, texture.get(144, 48, 32, 16), Colors.WHITE, new Vec3(-48, -16, -16),
Faces.createRectangle( new Vec3(0, 32, 0), new Vec3(16, 0, 0), false));
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.add(Faces.createRectangle(program, texture.get(224, 96, 32, 32), Colors.WHITE, new Vec3(-32, -16, -16),
Faces.createRectangle( new Vec3(0, 32, 0), new Vec3(32, 0, 0), false));
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.add(Faces.createRectangle(program, texture.get(112, 48, 32, 16), Colors.WHITE, new Vec3(+16, -16, -16),
Faces.createRectangle( new Vec3(0, 32, 0), new Vec3(-16, 0, 0), true));
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.add(Faces.createRectangle(program, texture.get(112, 16, 16, 32), Colors.WHITE, new Vec3(+16, +16, -16),
Faces.createRectangle( new Vec3(-16, 0, 0), new Vec3(0, 0, +32), false));
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.add(Faces.createRectangle(program, texture.get(96, 96, 32, 32), Colors.WHITE, new Vec3(0, +16, -16),
Faces.createRectangle( new Vec3(-32, 0, 0), new Vec3(0, 0, +32), false));
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.add(Faces.createRectangle(program, texture.get(16, 96, 16, 32), Colors.WHITE, new Vec3(-32, +16, -16),
Faces.createRectangle( new Vec3(-16, 0, 0), new Vec3(0, 0, +32), false));
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.add(Faces.createRectangle(program, texture.get(64, 16, 16, 32), Colors.WHITE, new Vec3(0, -16, -16),
Faces.createRectangle( new Vec3(+16, 0, 0), new Vec3(0, 0, +32), false));
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.add(Faces.createRectangle(program, texture.get(96, 96, 32, 32), Colors.WHITE, new Vec3(0, -16, -16),
Faces.createRectangle( new Vec3(-32, 0, 0), new Vec3(0, 0, +32), true));
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.add(Faces.createRectangle(program, texture.get(16, 96, 16, 32), Colors.WHITE, new Vec3(-32, -16, -16),
Faces.createRectangle( new Vec3(-16, 0, 0), new Vec3(0, 0, +32), true));
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( return new Shape(Usage.STATIC, program, faces.toArray(new Face[faces.size()]));
Usage.STATIC,
program,
faces.toArray(new Face[faces.size()])
);
} }
private static Renderable createHead(ComplexTexture texture) { private static Renderable createHead(ComplexTexture texture) {
@ -320,86 +157,41 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder(); StaticModel.Builder b = StaticModel.builder();
// Head // Head
b.addPart( b.addPart(new PppBuilder(program, texture.getCuboidTextures(0, 64, 32)).setOrigin(-16, -16, 0).setSize(32)
new PppBuilder( .create());
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( b.addPart(new PppBuilder(program, texture.getCuboidTextures(128, 64, 32))
new PppBuilder( .setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset).setSize(32 + 2 * hairOffset).create());
program,
texture.getCuboidTextures(128, 64, 32)
)
.setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset)
.setSize(32 + 2 * hairOffset)
.create()
);
// Right ear // Right ear
b.addPart( b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, -16, 32)
new PppBuilder( .setSize(8).create());
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, -16, 32).setSize(8).create()
);
// Left ear // Left ear
b.addPart( b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, +16, 32)
new PppBuilder( .setSize(8, -8, 8).flip().create());
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, +16, 32).setSize(8, -8, 8).flip().create()
);
// Muzzle // Muzzle
b.addPart( b.addPart(new PppBuilder(program,
new PppBuilder( BlockFace.mapToFaces(texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0),
program, texture.get(32 + 8, 64, 16, 8), texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0),
BlockFace.mapToFaces( texture.get(32, 64, 0, 0))).setOrigin(16, -8, 0).setSize(4, 16, 8).create());
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( b.addPart(new PppBuilder(program,
new PppBuilder( BlockFace.mapToFaces(texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0),
program, texture.get(32 + 12, 64 + 8, 8, 4), texture.get(32, 64, 0, 0), texture.get(32, 64, 0, 0),
BlockFace.mapToFaces( texture.get(32, 64, 0, 0))).setOrigin(16, -4, 8).setSize(4, 8, 4).create());
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( private static Renderable createLeg(ComplexTexture texture, int textureX, int textureY, boolean isLeft) {
ComplexTexture texture, PppBuilder b = new PppBuilder(WorldRenderProgram.getDefault(),
int textureX, texture.getCuboidTextures(textureX, textureY, 16, 48, 16)).setOrigin(-8, isLeft ? +8 : -8, -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); .setSize(16, isLeft ? -16 : +16, 48);
if (isLeft) if (isLeft)
@ -413,59 +205,26 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder(); StaticModel.Builder b = StaticModel.builder();
// Main tail // Main tail
b.addPart( b.addPart(new PppBuilder(program,
new PppBuilder( BlockFace.mapToFaces(texture.get(128, 96, 16, 16), texture.get(128, 96, 16, 16),
program, texture.get(128, 96, 16, 32), texture.get(128, 96, 16, 32), texture.get(144, 96, 16, 32),
BlockFace.mapToFaces( texture.get(144, 96, 16, 32))).setOrigin(-8, -8, -32).setSize(16, 16, 32).create());
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( return new QuadripedModel(entity,
entity,
new QuadripedModel.Body(body), new QuadripedModel.Body(body),
new QuadripedModel.Head( new QuadripedModel.Head(head, new Vec3(12, 0, 20), 120, 45, new Vec3(16, 0, 20)),
head, new QuadripedModel.Leg(leftForeLeg, new Vec3(6, +8.1f, -16), 0.0f),
new Vec3(12, 0, 20), new QuadripedModel.Leg(rightForeLeg, new Vec3(6, -8.1f, -16), 2.5f),
120, new QuadripedModel.Leg(leftHindLeg, new Vec3(-36, +8.2f, -16), 2.5f),
45, new QuadripedModel.Leg(rightHindLeg, new Vec3(-36, -8.2f, -16), 0.0f),
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

@ -29,12 +29,8 @@ import ru.windcorp.progressia.common.world.entity.EntityData;
public class TestEntityRenderStatie extends EntityRender { public class TestEntityRenderStatie extends EntityRender {
private final Renderable cube = new Shapes.PppBuilder( private final Renderable cube = new Shapes.PppBuilder(WorldRenderProgram.getDefault(), (Texture) null)
WorldRenderProgram.getDefault(), .setColorMultiplier(1, 1, 0).create();
(Texture) null
)
.setColorMultiplier(1, 1, 0)
.create();
public TestEntityRenderStatie(String id) { public TestEntityRenderStatie(String id) {
super(id); super(id);
@ -45,9 +41,7 @@ public class TestEntityRenderStatie extends EntityRender {
return new EntityRenderable(entity) { return new EntityRenderable(entity) {
@Override @Override
public void render(ShapeRenderHelper renderer) { public void render(ShapeRenderHelper renderer) {
renderer.pushTransform().scale( renderer.pushTransform().scale(((TestEntityDataStatie) entity).getSize() / 24.0f);
((TestEntityDataStatie) entity).getSize() / 24.0f
);
cube.render(renderer); cube.render(renderer);

View File

@ -141,7 +141,8 @@ public class TestMusicPlayer implements Runnable {
} }
public static void startNextNow() { public static void startNextNow() {
if (instance == null) return; if (instance == null)
return;
synchronized (instance) { synchronized (instance) {
instance.nextStart = System.currentTimeMillis(); instance.nextStart = System.currentTimeMillis();

View File

@ -119,12 +119,8 @@ public class TestPlayerControls {
desiredVelocity.z = movementUp; desiredVelocity.z = movementUp;
desiredVelocity.mul(speed); desiredVelocity.mul(speed);
Vec3 change = new Vec3() Vec3 change = new Vec3().set(desiredVelocity).sub(player.getVelocity())
.set(desiredVelocity) .mul((float) Math.exp(-authority * GraphicsInterface.getFrameLength())).negate().add(desiredVelocity);
.sub(player.getVelocity())
.mul((float) Math.exp(-authority * GraphicsInterface.getFrameLength()))
.negate()
.add(desiredVelocity);
if (!isFlying) { if (!isFlying) {
change.z = player.getVelocity().z; change.z = player.getVelocity().z;
@ -356,12 +352,8 @@ public class TestPlayerControls {
EntityData player = getEntity(); EntityData player = getEntity();
normalizeAngles( normalizeAngles(player.getDirection().add((float) (event.getChangeX() * yawScale),
player.getDirection().add( (float) (event.getChangeY() * pitchScale)));
(float) (event.getChangeX() * yawScale),
(float) (event.getChangeY() * pitchScale)
)
);
} }
private void normalizeAngles(Vec2 dir) { private void normalizeAngles(Vec2 dir) {
@ -369,11 +361,7 @@ public class TestPlayerControls {
dir.x = FloatMathUtil.normalizeAngle(dir.x); dir.x = FloatMathUtil.normalizeAngle(dir.x);
// Clamp pitch // Clamp pitch
dir.y = Glm.clamp( dir.y = Glm.clamp(dir.y, -FloatMathUtil.PI_F / 2, +FloatMathUtil.PI_F / 2);
dir.y,
-FloatMathUtil.PI_F / 2,
+FloatMathUtil.PI_F / 2
);
} }
private void onWheelScroll(WheelScrollEvent event) { private void onWheelScroll(WheelScrollEvent event) {

View File

@ -52,29 +52,15 @@ public class TestWorldDiskIO {
return; return;
try { try {
LOG.debug( LOG.debug("Saving {} {} {}", chunk.getPosition().x, chunk.getPosition().y, chunk.getPosition().z);
"Saving {} {} {}",
chunk.getPosition().x,
chunk.getPosition().y,
chunk.getPosition().z
);
Files.createDirectories(SAVE_DIR); Files.createDirectories(SAVE_DIR);
Path path = SAVE_DIR.resolve( Path path = SAVE_DIR.resolve(String.format("chunk_%+d_%+d_%+d.progressia_chunk", chunk.getPosition().x,
String.format( chunk.getPosition().y, chunk.getPosition().z));
"chunk_%+d_%+d_%+d.progressia_chunk",
chunk.getPosition().x,
chunk.getPosition().y,
chunk.getPosition().z
)
);
try ( try (DataOutputStream output = new DataOutputStream(
DataOutputStream output = new DataOutputStream( new DeflaterOutputStream(new BufferedOutputStream(Files.newOutputStream(path))))) {
new DeflaterOutputStream(new BufferedOutputStream(Files.newOutputStream(path)))
)
) {
ChunkIO.save(chunk, output, IOContext.SAVE); ChunkIO.save(chunk, output, IOContext.SAVE);
writeGenerationHint(chunk, output, server); writeGenerationHint(chunk, output, server);
} }
@ -92,22 +78,11 @@ public class TestWorldDiskIO {
if (!ENABLE) if (!ENABLE)
return null; return null;
Path path = SAVE_DIR.resolve( Path path = SAVE_DIR
String.format( .resolve(String.format("chunk_%+d_%+d_%+d.progressia_chunk", chunkPos.x, chunkPos.y, chunkPos.z));
"chunk_%+d_%+d_%+d.progressia_chunk",
chunkPos.x,
chunkPos.y,
chunkPos.z
)
);
if (!Files.exists(path)) { if (!Files.exists(path)) {
LOG.debug( LOG.debug("Not found {} {} {}", chunkPos.x, chunkPos.y, chunkPos.z);
"Not found {} {} {}",
chunkPos.x,
chunkPos.y,
chunkPos.z
);
return null; return null;
} }
@ -115,34 +90,20 @@ public class TestWorldDiskIO {
try { try {
ChunkData result = load(path, chunkPos, world, server); ChunkData result = load(path, chunkPos, world, server);
LOG.debug( LOG.debug("Loaded {} {} {}", chunkPos.x, chunkPos.y, chunkPos.z);
"Loaded {} {} {}",
chunkPos.x,
chunkPos.y,
chunkPos.z
);
return result; return result;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
LOG.debug( LOG.debug("Could not load {} {} {}", chunkPos.x, chunkPos.y, chunkPos.z);
"Could not load {} {} {}",
chunkPos.x,
chunkPos.y,
chunkPos.z
);
return null; return null;
} }
} }
private static ChunkData load(Path path, Vec3i chunkPos, WorldData world, Server server) private static ChunkData load(Path path, Vec3i chunkPos, WorldData world, Server server)
throws IOException, throws IOException, DecodingException {
DecodingException { try (DataInputStream input = new DataInputStream(
try ( new InflaterInputStream(new BufferedInputStream(Files.newInputStream(path))))) {
DataInputStream input = new DataInputStream(
new InflaterInputStream(new BufferedInputStream(Files.newInputStream(path)))
)
) {
ChunkData chunk = ChunkIO.load(world, chunkPos, input, IOContext.SAVE); ChunkData chunk = ChunkIO.load(world, chunkPos, input, IOContext.SAVE);
readGenerationHint(chunk, input, server); readGenerationHint(chunk, input, server);
return chunk; return chunk;
@ -150,8 +111,7 @@ public class TestWorldDiskIO {
} }
private static void readGenerationHint(ChunkData chunk, DataInputStream input, Server server) private static void readGenerationHint(ChunkData chunk, DataInputStream input, Server server)
throws IOException, throws IOException, DecodingException {
DecodingException {
chunk.setGenerationHint(server.getWorld().getGenerator().readGenerationHint(input)); chunk.setGenerationHint(server.getWorld().getGenerator().readGenerationHint(input));
} }

View File

@ -57,15 +57,22 @@ 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() { //Falling Block spawning logic 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) {
Vec3i chunkWorldPos = chunk.getPosition().mul_(16).add_(blockInChunk);
if (TestEntityLogicFallingBlock.FallingBlocks.contains(chunk.getWorld()
.getBlock(chunkWorldPos.add_(0, 0, 1)).getId())) {
chunk.getWorld().setBlock(chunkWorldPos.add_(0, 0, 1), BlockDataRegistry.getInstance().get(chunk.getWorld().getBlock(chunkWorldPos.add_(0,0,1)).getId()), true);
}
if (!TestEntityLogicFallingBlock.FallingBlocks.contains(current.getId())) { if (!TestEntityLogicFallingBlock.FallingBlocks.contains(current.getId())) {
return; return;
} }
if (chunk.getWorld().getBlock(chunk.getPosition().mul_(16).add_(blockInChunk.add_(0, 0, -1))).getId() == "Test:Air") if (chunk.getWorld().getBlock(chunkWorldPos.add_(0, 0, -1))
{ .getId() == "Test:Air") {
LogManager.getLogger().info("Inserting FallingBlock"); LogManager.getLogger().info("Inserting FallingBlock");
TestEntityDataFallingBlock fallingBlock = new TestEntityDataFallingBlock(); TestEntityDataFallingBlock fallingBlock = new TestEntityDataFallingBlock();
@ -80,8 +87,9 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
chunk.getWorld().addEntity(fallingBlock); chunk.getWorld().addEntity(fallingBlock);
chunk.setBlock(blockInChunk, previous, false); 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)); LogManager.getLogger().info(String.valueOf(chunkWorldPos.x) + " "
+ String.valueOf(chunkWorldPos.y) + " " + String.valueOf(chunkWorldPos.z));
} }
} }
}); });