Skip to content

Commit

Permalink
BW Rendering work
Browse files Browse the repository at this point in the history
  • Loading branch information
ExE-Boss committed Mar 2, 2017
1 parent e43aeb3 commit d99d129
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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();
}));
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 -> {
Expand All @@ -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);
}
Expand Down

0 comments on commit d99d129

Please sign in to comment.