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();
}
private static void renderCompound(
CompoundCollisionModel model,
ShapeRenderHelper helper
) {
private static void renderCompound(CompoundCollisionModel model, ShapeRenderHelper helper) {
for (CollisionModel part : model.getModels()) {
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 aboutFont = font.withColor(0xFF37A3E6).deriveBold();
panel.addChild(
new Label(
"About",
aboutFont,
new MutableStringLocalized("LayerAbout.Title")
)
);
panel.addChild(new Label("About", aboutFont, new MutableStringLocalized("LayerAbout.Title")));
panel.addChild(
new Label(
"Version",
font,
new MutableStringLocalized("LayerAbout.Version").format("pre-alpha 1")
)
);
new Label("Version", font, new MutableStringLocalized("LayerAbout.Version").format("pre-alpha 1")));
panel.addChild(
new Label(
"DebugHint",
font,
new MutableStringLocalized("LayerAbout.DebugHint")
)
);
panel.addChild(new Label("DebugHint", font, new MutableStringLocalized("LayerAbout.DebugHint")));
getRoot().addChild(panel);

View File

@ -58,146 +58,51 @@ public class LayerTestGUI extends GUILayer {
TestPlayerControls tpc = TestPlayerControls.getInstance();
panel.addChild(
new Label(
"IsFlyingDisplay",
font,
tmp_dynFormat("LayerTestGUI.IsFlyingDisplay", tpc::isFlying)
)
);
new Label("IsFlyingDisplay", font, tmp_dynFormat("LayerTestGUI.IsFlyingDisplay", tpc::isFlying)));
panel.addChild(new Label("IsSprintingDisplay", font,
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(
new Label(
"IsSprintingDisplay",
font,
tmp_dynFormat("LayerTestGUI.IsSprintingDisplay", tpc::isSprinting)
)
);
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 Label(
"IsMouseCapturedDisplay",
font,
tmp_dynFormat("LayerTestGUI.IsMouseCapturedDisplay", tpc::isMouseCaptured)
)
);
new DynamicLabel("ChunkUpdatesDisplay", font,
DynamicStrings.builder().addDyn(new MutableStringLocalized("LayerTestGUI.ChunkUpdatesDisplay"))
.addDyn(ClientState.getInstance().getWorld()::getPendingChunkUpdates).buildSupplier(),
128));
panel.addChild(
new Label(
"CameraModeDisplay",
font,
tmp_dynFormat(
"LayerTestGUI.CameraModeDisplay",
ClientState.getInstance().getCamera()::getCurrentModeIndex
)
)
);
panel.addChild(new DynamicLabel("PosDisplay", font, LayerTestGUI::getPos, 128));
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(
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")
)
);
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);
}
@ -266,15 +171,13 @@ public class LayerTestGUI extends GUILayer {
private static final Supplier<CharSequence> TPS_STRING = DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.TPSDisplay"))
.addDyn(() -> TPS_RECORD.update(ServerState.getInstance().getTPS()), 5, 1)
.buildSupplier();
.addDyn(() -> TPS_RECORD.update(ServerState.getInstance().getTPS()), 5, 1).buildSupplier();
private static final Supplier<CharSequence> POS_STRING = DynamicStrings.builder()
.addDyn(new MutableStringLocalized("LayerTestGUI.PosDisplay"))
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().x, 7, 1)
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().y, 7, 1)
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().z, 7, 1)
.buildSupplier();
.addDyn(() -> ClientState.getInstance().getCamera().getLastAnchorPosition().z, 7, 1).buildSupplier();
private static CharSequence getTPS() {
Server server = ServerState.getInstance();
@ -316,93 +219,95 @@ public class LayerTestGUI extends GUILayer {
});
}
// private static class DebugComponent extends Component {
// private final int color;
//
// public DebugComponent(String name, Vec2i size, int color) {
// super(name);
// this.color = color;
//
// setPreferredSize(size);
//
// addListener(new Object() {
// @Subscribe
// public void onHoverChanged(HoverEvent e) {
// requestReassembly();
// }
// });
//
// addListener(KeyEvent.class, this::onClicked);
// }
//
// private boolean onClicked(KeyEvent event) {
// if (!event.isMouse()) {
// return false;
// } else if (event.isPress() && event.isLeftMouseButton()) {
// System.out.println("You pressed a Component!");
// }
// return true;
// }
//
// @Override
// protected void assembleSelf(RenderTarget target) {
// target.fill(getX(), getY(), getWidth(), getHeight(), Colors.BLACK);
//
// target.fill(
// getX() + 2, getY() + 2,
// getWidth() - 4, getHeight() - 4,
// isHovered() ? Colors.DEBUG_YELLOW : color
// );
// }
// }
//
// public LayerTestGUI() {
// super("LayerTestGui", new LayoutAlign(1, 0.75, 5));
//
// Panel panel = new Panel("Alex", new LayoutVertical(5));
//
// panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100), 0x44FF44));
//
// Component charlie = new DebugComponent("Charlie", null, 0x222222);
// charlie.setLayout(new LayoutVertical(5));
//
// //Debug
// Localizer.getInstance().setLanguage("ru-RU");
// MutableString epsilon = new MutableStringLocalized("Epsilon")
// .addListener(() -> ((Label)charlie.getChild(0)).update()).format(34, "thirty-four");
// // These two are swapped in code due to a bug in layouts, fixing ATM
// charlie.addChild(
// new Label(
// "Delta",
// new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
// "Пре-альфа!"
// )
// );
// charlie.addChild(
// new Label(
// "Epsilon",
// new Font().withColor(0x4444BB).deriveItalic(),
// () -> epsilon.get().concat("\u269b")
// )
// );
// panel.addChild(charlie);
//
//
// charlie.addListener(KeyEvent.class, e -> {
// if(e.isPress() && e.getKey() == GLFW.GLFW_KEY_L) {
// Localizer localizer = Localizer.getInstance();
// if (localizer.getLanguage().equals("ru-RU")) {
// localizer.setLanguage("en-US");
// } else {
// localizer.setLanguage("ru-RU");
// }
// return true;
// } return false;
// });
// charlie.setFocusable(true);
// charlie.takeFocus();
//
// getRoot().addChild(panel);
// }
// private static class DebugComponent extends Component {
// private final int color;
//
// public DebugComponent(String name, Vec2i size, int color) {
// super(name);
// this.color = color;
//
// setPreferredSize(size);
//
// addListener(new Object() {
// @Subscribe
// public void onHoverChanged(HoverEvent e) {
// requestReassembly();
// }
// });
//
// addListener(KeyEvent.class, this::onClicked);
// }
//
// private boolean onClicked(KeyEvent event) {
// if (!event.isMouse()) {
// return false;
// } else if (event.isPress() && event.isLeftMouseButton()) {
// System.out.println("You pressed a Component!");
// }
// return true;
// }
//
// @Override
// protected void assembleSelf(RenderTarget target) {
// target.fill(getX(), getY(), getWidth(), getHeight(), Colors.BLACK);
//
// target.fill(
// getX() + 2, getY() + 2,
// getWidth() - 4, getHeight() - 4,
// isHovered() ? Colors.DEBUG_YELLOW : color
// );
// }
// }
//
// public LayerTestGUI() {
// super("LayerTestGui", new LayoutAlign(1, 0.75, 5));
//
// Panel panel = new Panel("Alex", new LayoutVertical(5));
//
// panel.addChild(new DebugComponent("Bravo", new Vec2i(200, 100),
// 0x44FF44));
//
// Component charlie = new DebugComponent("Charlie", null, 0x222222);
// charlie.setLayout(new LayoutVertical(5));
//
// //Debug
// Localizer.getInstance().setLanguage("ru-RU");
// MutableString epsilon = new MutableStringLocalized("Epsilon")
// .addListener(() -> ((Label)charlie.getChild(0)).update()).format(34,
// "thirty-four");
// // These two are swapped in code due to a bug in layouts, fixing ATM
// charlie.addChild(
// new Label(
// "Delta",
// new Font().withColor(0xCCBB44).deriveShadow().deriveBold(),
// "Пре-альфа!"
// )
// );
// charlie.addChild(
// new Label(
// "Epsilon",
// new Font().withColor(0x4444BB).deriveItalic(),
// () -> epsilon.get().concat("\u269b")
// )
// );
// panel.addChild(charlie);
//
//
// charlie.addListener(KeyEvent.class, e -> {
// if(e.isPress() && e.getKey() == GLFW.GLFW_KEY_L) {
// Localizer localizer = Localizer.getInstance();
// if (localizer.getLanguage().equals("ru-RU")) {
// localizer.setLanguage("en-US");
// } else {
// localizer.setLanguage("ru-RU");
// }
// return true;
// } return false;
// });
// charlie.setFocusable(true);
// charlie.takeFocus();
//
// getRoot().addChild(panel);
// }
}

View File

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

View File

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

View File

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

View File

@ -6,6 +6,7 @@ import ru.windcorp.progressia.common.world.entity.EntityData;
/**
* Data for Test:FallingBlock
*
* @author opfromthestart
*
*/
@ -16,39 +17,34 @@ public class TestEntityDataFallingBlock extends EntityData {
private boolean hasDeleted = false;
public TestEntityDataFallingBlock() {
this("Test:FallingBlock",new BlockData("Test:Sand"));
this("Test:FallingBlock", new BlockData("Test:Sand"));
}
protected TestEntityDataFallingBlock(String id, BlockData blockInput) {
super(id);
setCollisionModel(new AABB(0,0,0,1,1,1));
setCollisionModel(new AABB(0, 0, 0, 1, 1, 1));
block = blockInput;
}
public void setDestroyed()
{
public void setDestroyed() {
hasDeleted = true;
}
public boolean hasDestroyed()
{
public boolean hasDestroyed() {
return hasDeleted;
}
public BlockData getBlock()
{
public BlockData getBlock() {
return block;
}
public void setInvisible()
{
//block = new BlockData("Test:Log");
public void setInvisible() {
// block = new BlockData("Test:Log");
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;
}
}

View File

@ -15,6 +15,7 @@ import ru.windcorp.progressia.server.world.entity.EntityLogic;
/**
* Logic for Test:FallingBlock
*
* @author opfromthestart
*
*/
@ -22,8 +23,7 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
public static Set<String> FallingBlocks = new HashSet<String>();
public void addFallables()
{
public void addFallables() {
FallingBlocks.add("Test:Sand");
}
@ -32,46 +32,49 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
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);
}
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);
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;
}
@Override
public void tick(EntityData entity, TickContext context) { //context.getWorldData() ClientState.getInstance().getWorld().getData()
if (entity == null)
{
public void tick(EntityData entity, TickContext context) { // context.getWorldData()
// ClientState.getInstance().getWorld().getData()
if (entity == null) {
return;
}
//LogManager.getLogger().info("NotNull "+entity.toString() + " " + context.toString());
// LogManager.getLogger().info("NotNull "+entity.toString() + " " +
// context.toString());
super.tick(entity, context);
//friction
// friction
Vec3 vel = entity.getVelocity();
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);
TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId()); //ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
//fallBlock = (TestEntityDataFallingBlock) entity;
TestEntityDataFallingBlock fallBlock = (TestEntityDataFallingBlock) ClientState.getInstance().getWorld()
.getData().getEntity(entity.getEntityId()); // ClientState.getInstance().getWorld().getData().getEntity(entity.getEntityId());
// fallBlock = (TestEntityDataFallingBlock) entity;
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null)))
{
if (fallBlock.isDone() || !context.getWorld().isBlockLoaded(fallBlock.getBlockInWorld(null))) {
return;
}
if (!fallBlock.hasDestroyed())
{
//LogManager.getLogger().info(fallBlock.getStartPos());
context.getAccessor().setBlock(fallBlock.getBlockInWorld(null), BlockDataRegistry.getInstance().get("Test:Air"));
if (!fallBlock.hasDestroyed()) {
// LogManager.getLogger().info(fallBlock.getStartPos());
context.getAccessor().setBlock(fallBlock.getBlockInWorld(null),
BlockDataRegistry.getInstance().get("Test:Air"));
fallBlock.setDestroyed();
}
@ -81,17 +84,25 @@ public class TestEntityLogicFallingBlock extends EntityLogic {
Vec3i chunkCoords = trueDiv(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("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
// "+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());
if (context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords)
.getId() != "Test:Air") {
if (context.getWorldData().getChunk(chunkCoords).getBlock(inChunkCoords).getId() != "Test:Air") {
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());
fallBlock.setInvisible(); //Until I know how to properly delete it.
//context.getWorldData().removeEntity(entity.getEntityId());
fallBlock.setInvisible(); // Until I know how to properly delete it.
// context.getWorldData().removeEntity(entity.getEntityId());
}
}
}

View File

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

View File

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

View File

@ -54,11 +54,7 @@ public class TestEntityRenderJavapony extends EntityRender {
public TestEntityRenderJavapony(String 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.head = createHead(texture);
@ -75,49 +71,20 @@ public class TestEntityRenderJavapony extends EntityRender {
Texture tailStartTexture = texture.get(128, 96, 8, 32);
b.addStaticPart(
new PppBuilder(
WorldRenderProgram.getDefault(),
BlockFace.mapToFaces(
tailStartTexture,
tailStartTexture,
tailStartTexture,
tailStartTexture,
tailStartTexture,
tailStartTexture
)
)
.setOrigin(-60, -4, 14)
.setDepth(32, 0, -16).setWidth(8).setHeight(8)
.create()
);
b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(),
BlockFace.mapToFaces(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);
b.addStaticPart(
new PppBuilder(
WorldRenderProgram.getDefault(),
BlockFace.mapToFaces(
neckTexture,
neckTexture,
neckTexture,
neckTexture,
neckTexture,
neckTexture
)
)
.setOrigin(0, -8, 8)
.setWidth(16).setDepth(16).setHeight(2, 0, 16)
.create()
);
b.addStaticPart(new PppBuilder(WorldRenderProgram.getDefault(),
BlockFace.mapToFaces(neckTexture, neckTexture, neckTexture, neckTexture, neckTexture, neckTexture))
.setOrigin(0, -8, 8).setWidth(16).setDepth(16).setHeight(2, 0, 16).create());
b.addDynamicPart(
createTail(texture),
m -> m
.translate(-60, 0, 24)
.rotateX(0.05f * Math.sin(GraphicsInterface.getTime()))
.rotateY(0.05f * Math.sin(Math.PI / 3 * GraphicsInterface.getTime()))
);
b.addDynamicPart(createTail(texture),
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);
}
@ -127,192 +94,62 @@ public class TestEntityRenderJavapony extends EntityRender {
List<Face> faces = new ArrayList<>();
// F BODY
faces.add(
Faces.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
)
);
faces.add(Faces.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
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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
faces.add(
Faces.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
)
);
faces.add(Faces.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
faces.add(
Faces.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
)
);
faces.add(Faces.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
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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)
faces.add(
Faces.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
)
);
faces.add(Faces.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 Face[faces.size()]));
}
private static Renderable createHead(ComplexTexture texture) {
@ -320,86 +157,41 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder();
// Head
b.addPart(
new PppBuilder(
program,
texture.getCuboidTextures(0, 64, 32)
).setOrigin(-16, -16, 0).setSize(32).create()
);
b.addPart(new PppBuilder(program, texture.getCuboidTextures(0, 64, 32)).setOrigin(-16, -16, 0).setSize(32)
.create());
final float hairOffset = 1f;
// Hair
b.addPart(
new PppBuilder(
program,
texture.getCuboidTextures(128, 64, 32)
)
.setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset)
.setSize(32 + 2 * hairOffset)
.create()
);
b.addPart(new PppBuilder(program, texture.getCuboidTextures(128, 64, 32))
.setOrigin(-16 - hairOffset, -16 - hairOffset, -hairOffset).setSize(32 + 2 * hairOffset).create());
// Right ear
b.addPart(
new PppBuilder(
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, -16, 32).setSize(8).create()
);
b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, -16, 32)
.setSize(8).create());
// Left ear
b.addPart(
new PppBuilder(
program,
texture.getCuboidTextures(48, 128 - 80, 8)
).setOrigin(-16 + 3, +16, 32).setSize(8, -8, 8).flip().create()
);
b.addPart(new PppBuilder(program, texture.getCuboidTextures(48, 128 - 80, 8)).setOrigin(-16 + 3, +16, 32)
.setSize(8, -8, 8).flip().create());
// Muzzle
b.addPart(
new PppBuilder(
program,
BlockFace.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()
);
b.addPart(new PppBuilder(program,
BlockFace.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
b.addPart(
new PppBuilder(
program,
BlockFace.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()
);
b.addPart(new PppBuilder(program,
BlockFace.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();
}
private static Renderable createLeg(
ComplexTexture texture,
int textureX,
int textureY,
boolean isLeft
) {
PppBuilder b = new PppBuilder(
WorldRenderProgram.getDefault(),
texture.getCuboidTextures(textureX, textureY, 16, 48, 16)
)
.setOrigin(-8, isLeft ? +8 : -8, -48)
private static Renderable createLeg(ComplexTexture texture, int textureX, 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)
@ -413,59 +205,26 @@ public class TestEntityRenderJavapony extends EntityRender {
StaticModel.Builder b = StaticModel.builder();
// Main tail
b.addPart(
new PppBuilder(
program,
BlockFace.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()
);
b.addPart(new PppBuilder(program,
BlockFace.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();
}
@Override
public EntityRenderable createRenderable(EntityData entity) {
return new QuadripedModel(
entity,
return new QuadripedModel(entity,
new QuadripedModel.Body(body),
new QuadripedModel.Head(
head,
new Vec3(12, 0, 20),
120,
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
),
new QuadripedModel.Head(head, new Vec3(12, 0, 20), 120, 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

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

View File

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

View File

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

View File

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

View File

@ -57,15 +57,22 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
@Override
public void onChunkLoaded(WorldData world, ChunkData chunk) {
findAndPopulate(chunk.getPosition(), world);
chunk.addListener(new ChunkDataListener() { //Falling Block spawning logic
chunk.addListener(new ChunkDataListener() { // Falling Block
// spawning logic
@Override
public void onChunkBlockChanged(ChunkData chunk, Vec3i blockInChunk, BlockData previous,
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())) {
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");
TestEntityDataFallingBlock fallingBlock = new TestEntityDataFallingBlock();
@ -80,8 +87,9 @@ public class TestWorldGenerator extends AbstractWorldGenerator<Boolean> {
chunk.getWorld().addEntity(fallingBlock);
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));
}
}
});