From d99d12974754d162b22bebedb9aa31288431d1a0 Mon Sep 17 00:00:00 2001 From: ExE Boss Date: Sun, 26 Feb 2017 00:11:02 +0100 Subject: [PATCH] BW Rendering work --- .../v17/wrapper/block/backward/BWBlock.java | 17 +++++++++++++++++ .../mc/forge/v17/wrapper/item/BWItem.java | 4 ++-- .../v18/wrapper/block/backward/BWBlock.java | 15 ++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java index 4d7bdf10c..298005f36 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/block/backward/BWBlock.java @@ -21,6 +21,7 @@ package nova.core.wrapper.mc.forge.v17.wrapper.block.backward; import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.init.Blocks; import net.minecraft.item.Item; @@ -48,8 +49,12 @@ import nova.core.wrapper.mc.forge.v17.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import java.nio.DoubleBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -103,8 +108,20 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { components.add(new StaticRenderer()) .onRender(model -> { model.addChild(new CustomModel(self -> { + GL11.glPushMatrix(); + DoubleBuffer buffer = BufferUtils.createDoubleBuffer(4 * 4); + double[] flatArray = Arrays.stream(self.matrix.getMatrix().getData()) + .flatMapToDouble(Arrays::stream) + .toArray(); + buffer.put(flatArray); + buffer.position(0); + GL11.glMultMatrix(buffer); + IBlockAccess backup = RenderBlocks.getInstance().blockAccess; + RenderBlocks.getInstance().blockAccess = getMcBlockAccess(); RenderBlocks.getInstance() .renderBlockByRenderType(mcBlock, x(), y(), z()); + RenderBlocks.getInstance().blockAccess = backup; + GL11.glPopMatrix(); })); }); getTileEntity().ifPresent(tileEntity -> { diff --git a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItem.java b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItem.java index 044f84d7c..91d1f27cf 100644 --- a/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItem.java +++ b/minecraft/1.7/src/main/java/nova/core/wrapper/mc/forge/v17/wrapper/item/BWItem.java @@ -58,7 +58,7 @@ public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag) { components.add(new StaticRenderer()) .onRender(model -> { model.addChild(new CustomModel(self -> { - Tessellator.instance.draw(); +// Tessellator.instance.draw(); GL11.glPushMatrix(); DoubleBuffer buffer = BufferUtils.createDoubleBuffer(4 * 4); double[] flatArray = Arrays.stream(self.matrix.getMatrix().getData()) @@ -69,7 +69,7 @@ public BWItem(net.minecraft.item.Item item, int meta, NBTTagCompound tag) { GL11.glMultMatrix(buffer); RenderItem.getInstance().doRender(fakeEntity, 0, 0, 0, 0, 0); GL11.glPopMatrix(); - Tessellator.instance.startDrawingQuads(); +// Tessellator.instance.startDrawingQuads(); })); }); } diff --git a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java index ce0cf4c12..d78f3fad1 100644 --- a/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java +++ b/minecraft/1.8/src/main/java/nova/core/wrapper/mc/forge/v18/wrapper/block/backward/BWBlock.java @@ -52,8 +52,12 @@ import nova.core.wrapper.mc.forge.v18.wrapper.block.world.BWWorld; import nova.internal.core.Game; import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import java.nio.DoubleBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; @@ -107,8 +111,17 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { components.add(new StaticRenderer()) .onRender(model -> { model.addChild(new CustomModel(self -> { + GL11.glPushMatrix(); + DoubleBuffer buffer = BufferUtils.createDoubleBuffer(4 * 4); + double[] flatArray = Arrays.stream(self.matrix.getMatrix().getData()) + .flatMapToDouble(Arrays::stream) + .toArray(); + buffer.put(flatArray); + buffer.position(0); + GL11.glMultMatrix(buffer); Minecraft.getMinecraft().getBlockRendererDispatcher() .renderBlock(blockState(), new BlockPos(x(), y(), z()), getMcBlockAccess(), Tessellator.getInstance().getWorldRenderer()); + GL11.glPopMatrix(); })); }); getTileEntity().ifPresent(tileEntity -> { @@ -119,7 +132,7 @@ public BWBlock(net.minecraft.block.Block block, World world, Vector3D pos) { })); }); }); - + WrapperEvent.BWBlockCreate event = new WrapperEvent.BWBlockCreate(world, pos, this, mcBlock); Game.events().publish(event); }