Skip to content

Instantly share code, notes, and snippets.

@anuar2k
Created December 29, 2017 00:06
Show Gist options
  • Save anuar2k/7d91ca899c57a60bab32c250abbc004c to your computer and use it in GitHub Desktop.
Save anuar2k/7d91ca899c57a60bab32c250abbc004c to your computer and use it in GitHub Desktop.
@ReceiveEvent
public void test(ActivateEvent event, EntityRef entity) {
entity = event.getTarget();
if (entity.hasComponent(PathDescriptorComponent.class)) {
PathDescriptorComponent desc = entity.getComponent(PathDescriptorComponent.class);
for (Prefab p : desc.descriptors) {
logger.info("Prefab name: {}", p.getName());
for (Component c : p.iterateComponents()) {
if (c instanceof PathComponent) {
PathComponent comp = (PathComponent) c;
logger.info("PathComponent");
for (PathComponent.CubicBezier a : comp.path) {
logger.info("{},{},{}", a.f1.x, a.f1.y, a.f1.z);
logger.info("{},{},{}", a.f2.x, a.f2.y, a.f2.z);
logger.info("{},{},{}", a.f3.x, a.f3.y, a.f3.z);
logger.info("{},{},{}", a.f4.x, a.f4.y, a.f4.z);
}
logger.info("Path rotation: {}", comp.rotation);
logger.info("Path sb: {},{},{}", comp.startingBinormal.x, comp.startingBinormal.y, comp.startingBinormal.z);
}
}
}
}
BlockComponent bComp = entity.getComponent(BlockComponent.class);
Block block = worldProvider.getBlock(bComp.getPosition());
BlockFamily blockFamily = block.getBlockFamily();
if (blockFamily instanceof PathFamily) {
Rotation rotation = ((PathFamily) blockFamily).getRotationFor(block.getURI());
logger.info("Rotation: {}, {}, {}", rotation.getYaw(), rotation.getPitch(), rotation.getRoll());
}
String str = block.getURI().getIdentifier().toString();
if (!str.isEmpty()) {
byte connections = Byte.parseByte(str);
logger.info("Sides: {}", boi(connections));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment