use of io.xol.chunkstories.core.voxel.components.VoxelComponentSignText in project chunkstories-core by Hugobros3.
the class Sign method translateSignText.
private void translateSignText(VoxelComponent target, MinecraftChunk minecraftChunk, int x, int y, int z) {
NBTCompound root = minecraftChunk.getRootTag();
if (root == null)
return;
NBTList entitiesList = (NBTList) root.getTag("Level.TileEntities");
// Check it exists and is of the right kind
if (target != null && target instanceof VoxelComponentSignText) {
VoxelComponentSignText signTextComponent = (VoxelComponentSignText) target;
signTextComponent.setSignText("<corresponding sign not found :(>");
for (NBTag element : entitiesList.elements) {
NBTCompound entity = (NBTCompound) element;
NBTString entityId = (NBTString) entity.getTag("id");
int tileX = ((NBTInt) entity.getTag("x")).data;
int tileY = ((NBTInt) entity.getTag("y")).data;
int tileZ = ((NBTInt) entity.getTag("z")).data;
if (entityId.data.toLowerCase().equals("sign") || entityId.data.toLowerCase().equals("minecraft:sign")) {
// System.out.println("Looking up sign data for B:"+x+":"+y+":"+z);
if ((tileX & 0xF) != x || tileY != y || (tileZ & 0xF) != z) {
continue;
}
String text1 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text1")).data);
String text2 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text2")).data);
String text3 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text3")).data);
String text4 = SignParseUtil.parseSignData(((NBTString) entity.getTag("Text4")).data);
String textComplete = text1 + "\n" + text2 + "\n" + text3 + "\n" + text4;
signTextComponent.setSignText(textComplete);
System.out.println("OK: " + textComplete);
break;
// ((EntitySign) ((VoxelSign) voxel).getEntity(exported.peekSafely(csCoordinatesX, csCoordinatesY, csCoordinatesZ))).setText(textComplete);
}
// else
// System.out.println("Found "+entityId.data);
}
}
}
use of io.xol.chunkstories.core.voxel.components.VoxelComponentSignText in project chunkstories-core by Hugobros3.
the class SignRenderer method renderVoxels.
@Override
public void renderVoxels(RenderingInterface renderingContext, IterableIterator<ChunkCell> renderableEntitiesIterator) {
setupRender(renderingContext);
renderingContext.setObjectMatrix(null);
for (// .getElementsInFrustrumOnly())
ChunkCell context : // .getElementsInFrustrumOnly())
renderableEntitiesIterator) {
if (renderingContext.getCamera().getCameraPosition().distance(context.getLocation()) > 32)
continue;
Texture2D diffuse = renderingContext.textures().getTexture("./models/sign.png");
diffuse.setLinearFiltering(false);
renderingContext.bindAlbedoTexture(diffuse);
renderingContext.bindNormalTexture(renderingContext.textures().getTexture("./textures/normalnormal.png"));
renderingContext.currentShader().setUniform2f("worldLightIn", context.getBlocklight(), context.getSunlight());
boolean isPost = context.getVoxel().getName().endsWith("_post");
int facing = context.getMetaData();
Matrix4f mutrix = new Matrix4f();
mutrix.translate(new Vector3f(0.5f, 0.0f, 0.5f));
Location loc = context.getLocation();
mutrix.translate((float) loc.x, (float) loc.y, (float) loc.z);
mutrix.rotate((float) Math.PI * 2.0f * (-facing) / 16f, new Vector3f(0, 1, 0));
if (!isPost)
mutrix.translate(new Vector3f(0.0f, 0.0f, -0.5f));
renderingContext.setObjectMatrix(mutrix);
if (!isPost)
renderingContext.meshes().getRenderableMeshByName("./models/sign_post.obj").render(renderingContext);
else
renderingContext.meshes().getRenderableMeshByName("./models/sign.obj").render(renderingContext);
VoxelComponentSignText signTextComponent = (VoxelComponentSignText) context.components().get("signData");
if (signTextComponent == null)
continue;
// bake sign mesh
if (signTextComponent.cachedText == null || !signTextComponent.cachedText.equals(signTextComponent.getSignText())) {
// entitySign.renderData = new TextMeshObject(entitySign.signText.getSignText());
signTextComponent.cachedText = signTextComponent.getSignText();
signTextComponent.renderData = renderingContext.getFontRenderer().newTextMeshObject(renderingContext.getFontRenderer().defaultFont(), signTextComponent.cachedText);
}
// signTextComponent.setSignText("fuck");
// System.out.println("cachedText:"+signTextComponent.getSignText());
// Display it
mutrix.translate(new Vector3f(0.0f, 1.15f, 0.055f));
renderingContext.setObjectMatrix(mutrix);
signTextComponent.renderData.render(renderingContext);
}
}
use of io.xol.chunkstories.core.voxel.components.VoxelComponentSignText in project chunkstories-core by Hugobros3.
the class VoxelSign method whenPlaced.
@Override
public void whenPlaced(FreshChunkCell cell) {
VoxelComponentSignText signTextComponent = new VoxelComponentSignText(cell.components());
cell.registerComponent("signData", signTextComponent);
}
Aggregations