diff --git a/src/main/java/org/teacon/slides/network/SlideData.java b/src/main/java/org/teacon/slides/network/SlideData.java index 828c62b..444e712 100644 --- a/src/main/java/org/teacon/slides/network/SlideData.java +++ b/src/main/java/org/teacon/slides/network/SlideData.java @@ -18,6 +18,8 @@ public final class SlideData implements INBTSerializable { private int imgColor; private Vector2f imgSize; private Vector3f imgOffset; + private boolean backVisibility; + private boolean frontVisibility; public SlideData() { this.url = ""; @@ -62,6 +64,24 @@ public SlideData setOffset(Vector3f offset) { return this; } + public boolean isBackVisible() { + return this.backVisibility; + } + + public SlideData setBackVisible(boolean visible) { + this.backVisibility = visible; + return this; + } + + public boolean isFrontVisible() { + return this.frontVisibility; + } + + public SlideData setFrontVisible(boolean visible) { + this.frontVisibility = visible; + return this; + } + @Override public CompoundNBT serializeNBT() { CompoundNBT nbt = new CompoundNBT(); @@ -72,6 +92,8 @@ public CompoundNBT serializeNBT() { nbt.putFloat("OffsetX", this.imgOffset.getX()); nbt.putFloat("OffsetY", this.imgOffset.getY()); nbt.putFloat("OffsetZ", this.imgOffset.getZ()); + nbt.putBoolean("BackInvisible", !this.backVisibility); + nbt.putBoolean("FrontInvisible", !this.frontVisibility); return nbt; } @@ -81,5 +103,7 @@ public void deserializeNBT(CompoundNBT nbt) { this.imgColor = nbt.getInt("Color"); this.imgSize = new Vector2f(nbt.getFloat("Width"), nbt.getFloat("Height")); this.imgOffset = new Vector3f(nbt.getFloat("OffsetX"), nbt.getFloat("OffsetY"), nbt.getFloat("OffsetZ")); + this.backVisibility = !nbt.getBoolean("BackInvisible"); + this.frontVisibility = !nbt.getBoolean("FrontInvisible"); } } \ No newline at end of file diff --git a/src/main/java/org/teacon/slides/projector/ProjectorBlock.java b/src/main/java/org/teacon/slides/projector/ProjectorBlock.java index ffeaa97..5895ee5 100644 --- a/src/main/java/org/teacon/slides/projector/ProjectorBlock.java +++ b/src/main/java/org/teacon/slides/projector/ProjectorBlock.java @@ -153,6 +153,10 @@ public InternalRotation invert() { return InternalRotation.values()[INV_ORDINALS[this.ordinal()]]; } + public boolean isFlipped() { + return this.ordinal() >= 4; + } + public Matrix4f getTransformation() { return this.transformation; } diff --git a/src/main/java/org/teacon/slides/projector/ProjectorControlScreen.java b/src/main/java/org/teacon/slides/projector/ProjectorControlScreen.java index c7fbfc0..f0b8ace 100644 --- a/src/main/java/org/teacon/slides/projector/ProjectorControlScreen.java +++ b/src/main/java/org/teacon/slides/projector/ProjectorControlScreen.java @@ -40,7 +40,11 @@ public final class ProjectorControlScreen extends ContainerScreen { try { @@ -210,6 +214,21 @@ protected void init() { this.rotation = newRotation; })); this.rotation = this.container.rotation; + + // single sided / double sided + this.switchSingleSided = this.addButton(new Button(this.guiLeft + 9, this.guiTop + 153, 179, 113, 18, 19, new TranslationTextComponent("gui.slide_show.single_double_sided"), () -> { + this.isDoubleSided = false; + this.switchDoubleSided.visible = true; + this.switchSingleSided.visible = false; + })); + this.switchDoubleSided = this.addButton(new Button(this.guiLeft + 9, this.guiTop + 153, 179, 133, 18, 19, new TranslationTextComponent("gui.slide_show.single_double_sided"), () -> { + this.isDoubleSided = true; + this.switchSingleSided.visible = true; + this.switchDoubleSided.visible = false; + })); + this.isDoubleSided = this.rotation.isFlipped() ? this.container.currentSlide.isBackVisible() : this.container.currentSlide.isFrontVisible(); + this.switchDoubleSided.visible = !this.isDoubleSided; + this.switchSingleSided.visible = this.isDoubleSided; } @Override @@ -235,7 +254,9 @@ public void onClose() { .setImageLocation(this.invalidURL ? oldData.getImageLocation() : this.url) .setColor(this.invalidColor ? oldData.getColor() : this.imgColor) .setSize(invalidSize ? oldData.getSize() : this.imgSize) - .setOffset(invalidOffset ? oldData.getOffset() : this.imgOffset); + .setOffset(invalidOffset ? oldData.getOffset() : this.imgOffset) + .setFrontVisible(this.isDoubleSided || this.rotation.isFlipped()) + .setBackVisible(this.isDoubleSided || !this.rotation.isFlipped()); packet.rotation = this.rotation; SlideShow.channel.sendToServer(packet); super.onClose(); @@ -279,7 +300,7 @@ protected void renderHoveredTooltip(MatrixStack stack, int mouseX, int mouseY) { if (offsetX >= 9 && offsetY >= 27 && offsetX < 27 && offsetY < 46) { this.renderTooltip(stack, new TranslationTextComponent("gui.slide_show.url"), mouseX, mouseY); } - if (offsetX >= 17 && offsetY >= 153 && offsetX < 35 && offsetY < 172) { + if (offsetX >= 34 && offsetY >= 153 && offsetX < 52 && offsetY < 172) { this.renderTooltip(stack, new TranslationTextComponent("gui.slide_show.color"), mouseX, mouseY); } if (offsetX >= 9 && offsetY >= 49 && offsetX < 27 && offsetY < 68) { @@ -303,6 +324,9 @@ protected void renderHoveredTooltip(MatrixStack stack, int mouseX, int mouseY) { if (offsetX >= 142 && offsetY >= 153 && offsetX < 160 && offsetY < 172) { this.renderTooltip(stack, new TranslationTextComponent("gui.slide_show.rotate"), mouseX, mouseY); } + if (offsetX >= 9 && offsetY >= 153 && offsetX < 27 && offsetY < 172) { + this.renderTooltip(stack, new TranslationTextComponent("gui.slide_show.single_double_sided"), mouseX, mouseY); + } } @Override @@ -325,7 +349,7 @@ protected void drawGuiContainerForegroundLayer(MatrixStack stack, int mouseX, in int red = (this.imgColor >>> 16) & 255, green = (this.imgColor >>> 8) & 255, blue = this.imgColor & 255; Objects.requireNonNull(this.minecraft).getTextureManager().bindTexture(GUI_TEXTURE); RenderSystem.color4f(red / 255.0F, green / 255.0F, blue / 255.0F, alpha / 255.0F); - this.blit(stack, 21, 157, 180, 194, 10, 10); + this.blit(stack, 38, 157, 180, 194, 10, 10); this.blit(stack, 82, 185, 180, 194, 17, 17); } diff --git a/src/main/java/org/teacon/slides/renderer/ProjectorTileEntityRenderer.java b/src/main/java/org/teacon/slides/renderer/ProjectorTileEntityRenderer.java index 4bc03a2..e8b0d87 100644 --- a/src/main/java/org/teacon/slides/renderer/ProjectorTileEntityRenderer.java +++ b/src/main/java/org/teacon/slides/renderer/ProjectorTileEntityRenderer.java @@ -25,9 +25,10 @@ public void render(ProjectorTileEntity tile, float partialTicks, MatrixStack mat final Matrix4f transformation = matrixStack.getLast().getMatrix(); final float width = tile.currentSlide.getSize().x, height = tile.currentSlide.getSize().y; final SlideRenderEntry entry = SlideRenderData.getEntry(tile.currentSlide.getImageLocation()); + final boolean renderFront = tile.currentSlide.isFrontVisible(), renderBack = tile.currentSlide.isBackVisible(); transformation.mul(tile.getTransformation()); - entry.render(buffer, transformation, width, height, tile.currentSlide.getColor(), combinedLight); + entry.render(buffer, transformation, width, height, tile.currentSlide.getColor(), combinedLight, renderFront, renderBack); matrixStack.pop(); } diff --git a/src/main/java/org/teacon/slides/renderer/SlideRenderEntry.java b/src/main/java/org/teacon/slides/renderer/SlideRenderEntry.java index 440a591..615deca 100644 --- a/src/main/java/org/teacon/slides/renderer/SlideRenderEntry.java +++ b/src/main/java/org/teacon/slides/renderer/SlideRenderEntry.java @@ -14,7 +14,7 @@ public abstract class SlideRenderEntry implements Closeable { - public abstract void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light); + public abstract void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light, boolean renderFront, boolean renderBack); public abstract void close(); @@ -44,25 +44,29 @@ private Impl(NativeImage nativeImage, TextureManager manager) { } @Override - public void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light) { + public void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light, boolean renderFront, boolean renderBack) { int alpha = (color >>> 24) & 255; if (alpha > 0) { int red = (color >>> 16) & 255, green = (color >>> 8) & 255, blue = color & 255; - this.renderSlide(buffer, matrix, alpha, red, green, blue, light); + this.renderSlide(buffer, matrix, alpha, red, green, blue, light, renderFront, renderBack); } } - private void renderSlide(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int red, int green, int blue, int light) { + private void renderSlide(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int red, int green, int blue, int light, boolean renderFront, boolean renderBack) { final IVertexBuilder builder = buffer.getBuffer(this.renderType); // We are using GL11.GL_QUAD, vertex format Pos -> Color -> Tex -> Light -> End. - builder.pos(matrix, 0F, 1F / 256F, 1F).color(red, green, blue, alpha).tex(0F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, 1F).color(red, green, blue, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, 0F).color(red, green, blue, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, 0F).color(red, green, blue, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, 0F).color(red, green, blue, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, 0F).color(red, green, blue, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, 1F).color(red, green, blue, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, 1F).color(red, green, blue, alpha).tex(0F, 1F).lightmap(light).endVertex(); + if (renderFront) { + builder.pos(matrix, 0F, 1F / 256F, 1F).color(red, green, blue, alpha).tex(0F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, 1F).color(red, green, blue, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, 0F).color(red, green, blue, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, 0F).color(red, green, blue, alpha).tex(0F, 0F).lightmap(light).endVertex(); + } + if (renderBack) { + builder.pos(matrix, 0F, -1F / 256F, 0F).color(red, green, blue, alpha).tex(0F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, 0F).color(red, green, blue, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, 1F).color(red, green, blue, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, 1F).color(red, green, blue, alpha).tex(0F, 1F).lightmap(light).endVertex(); + } } @Override @@ -94,31 +98,35 @@ private float getFactor(float width, float height) { } @Override - public void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light) { + public void render(IRenderTypeBuffer buffer, Matrix4f matrix, float width, float height, int color, int light, boolean renderFront, boolean renderBack) { int alpha = (color >>> 24) & 255; if (alpha > 0) { float factor = this.getFactor(width, height); int xSize = Math.round(width / factor), ySize = Math.round(height / factor); - this.renderBackground(buffer, matrix, alpha, light, xSize, ySize); - this.renderIcon(buffer, matrix, alpha, light, xSize, ySize); + this.renderIcon(buffer, matrix, alpha, light, xSize, ySize, renderFront, renderBack); + this.renderBackground(buffer, matrix, alpha, light, xSize, ySize, renderFront, renderBack); } } - private void renderIcon(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int light, int xSize, int ySize) { + private void renderIcon(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int light, int xSize, int ySize, boolean renderFront, boolean renderBack) { IVertexBuilder builder = buffer.getBuffer(this.iconRenderType); // We are using GL11.GL_QUAD, vertex format Pos -> Color -> Tex -> Light -> End. float x1 = (1F - 19F / xSize) / 2F, x2 = 1F - x1, y1 = (1F - 16F / ySize) / 2F, y2 = 1F - y1; - builder.pos(matrix, x1, 1F / 128F, y2).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 128F, y2).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 128F, y1).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 128F, y1).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 128F, y1).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 128F, y1).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 128F, y2).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 128F, y2).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); + if (renderFront) { + builder.pos(matrix, x1, 1F / 128F, y2).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 128F, y2).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 128F, y1).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 128F, y1).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); + } + if (renderBack) { + builder.pos(matrix, x1, -1F / 128F, y1).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 128F, y1).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 128F, y2).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 128F, y2).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); + } } - private void renderBackground(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int light, int xSize, int ySize) { + private void renderBackground(IRenderTypeBuffer buffer, Matrix4f matrix, int alpha, int light, int xSize, int ySize, boolean renderFront, boolean renderBack) { IVertexBuilder builder = buffer.getBuffer(this.backgroundRenderType); // We are using GL11.GL_QUAD, vertex format Pos -> Color -> Tex -> Light -> End. float u1 = 9F / 19F, u2 = 10F / 19F, x1 = 9F / xSize, x2 = 1F - x1, y1 = 9F / ySize, y2 = 1F - y1; @@ -128,88 +136,100 @@ private void renderBackground(IRenderTypeBuffer buffer, Matrix4f matrix, int alp * * xs = [('0F', '0F'), ('x1', 'u1'), ('x2', 'u2'), ('1F', '1F')] * ys = [('0F', '0F'), ('y1', 'u1'), ('y2', 'u2'), ('1F', '1F')] - * fmt = 'builder.pos(matrix, {}, {}, {}).color(255, 255, 255, alpha).tex({}, {}).lightmap(light).endVertex();' + * fmt = ' builder.pos(matrix, {}, {}, {}).color(255, 255, 255, alpha).tex({}, {}).lightmap(light).endVertex();' * + * print('if (renderFront) {') * for i in range(3): * for j in range(3): * a, b, c, d = xs[i], xs[i + 1], ys[j], ys[j + 1] * for k, l in [(a, d), (b, d), (b, c), (a, c)]: * print(fmt.format(k[0], '1F / 256F', l[0], k[1], l[1])) + * print('}') + * + * print('if (renderBack) {') + * for i in range(3): + * for j in range(3): + * a, b, c, d = xs[i], xs[i + 1], ys[j], ys[j + 1] * for k, l in [(a, c), (b, c), (b, d), (a, d)]: * print(fmt.format(k[0], '-1F / 256F', l[0], k[1], l[1])) + * print('}') */ - builder.pos(matrix, 0F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, 0F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 0F, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x1, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, 1F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); - builder.pos(matrix, 1F, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); - builder.pos(matrix, x2, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); + if (renderFront) { + builder.pos(matrix, 0F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, 0F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, 1F).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, 1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, 1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + } + if (renderBack) { + builder.pos(matrix, 0F, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(0F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(0F, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(0F, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); + builder.pos(matrix, 0F, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(0F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u1, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u1, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u1, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x1, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u1, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(u2, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, 0F).color(255, 255, 255, alpha).tex(1F, 0F).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y1).color(255, 255, 255, alpha).tex(u2, u1).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, y1).color(255, 255, 255, alpha).tex(1F, u1).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, y2).color(255, 255, 255, alpha).tex(u2, u2).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, y2).color(255, 255, 255, alpha).tex(1F, u2).lightmap(light).endVertex(); + builder.pos(matrix, 1F, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(1F, 1F).lightmap(light).endVertex(); + builder.pos(matrix, x2, -1F / 256F, 1F).color(255, 255, 255, alpha).tex(u2, 1F).lightmap(light).endVertex(); + } } @Override diff --git a/src/main/resources/assets/slide_show/lang/en_us.json b/src/main/resources/assets/slide_show/lang/en_us.json index d703482..ced844e 100644 --- a/src/main/resources/assets/slide_show/lang/en_us.json +++ b/src/main/resources/assets/slide_show/lang/en_us.json @@ -10,6 +10,7 @@ "gui.slide_show.offset_z": "Move Backward/Forward", "gui.slide_show.flip": "Flip Horizontally", "gui.slide_show.rotate": "Rotate Clockwise", + "gui.slide_show.single_double_sided": "Switch Single-Sided / Double-Sided", "gui.slide_show.section.image": "Image Properties", "gui.slide_show.section.offset": "Slide Offset", diff --git a/src/main/resources/assets/slide_show/lang/zh_cn.json b/src/main/resources/assets/slide_show/lang/zh_cn.json index 03dc67e..9fa1e31 100644 --- a/src/main/resources/assets/slide_show/lang/zh_cn.json +++ b/src/main/resources/assets/slide_show/lang/zh_cn.json @@ -10,6 +10,7 @@ "gui.slide_show.offset_z": "前后平移", "gui.slide_show.flip": "水平翻转", "gui.slide_show.rotate": "顺时针旋转", + "gui.slide_show.single_double_sided": "切换单面/双面", "gui.slide_show.section.image": "图片属性", "gui.slide_show.section.offset": "幻灯片平移",