Fixed forge lighting working incorrectly outside 0x1000000 coordinates.
This commit is contained in:
parent
0d06ea6758
commit
11d237f5f2
3 changed files with 23 additions and 6 deletions
|
@ -22,6 +22,7 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
return new VertexLighterFlat();
|
||||
}
|
||||
};
|
||||
|
||||
private final ThreadLocal<VertexLighterSmoothAo> lighterSmooth = new ThreadLocal<VertexLighterSmoothAo>()
|
||||
{
|
||||
@Override
|
||||
|
@ -31,6 +32,8 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
}
|
||||
};
|
||||
|
||||
private final ThreadLocal<WorldRendererConsumer> wrFlat = new ThreadLocal<WorldRendererConsumer>();
|
||||
private final ThreadLocal<WorldRendererConsumer> wrSmooth = new ThreadLocal<WorldRendererConsumer>();
|
||||
private final ThreadLocal<WorldRenderer> lastRendererFlat = new ThreadLocal<WorldRenderer>();
|
||||
private final ThreadLocal<WorldRenderer> lastRendererSmooth = new ThreadLocal<WorldRenderer>();
|
||||
|
||||
|
@ -42,8 +45,11 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
if(wr != lastRendererFlat.get())
|
||||
{
|
||||
lastRendererFlat.set(wr);
|
||||
lighterFlat.get().setParent(new WorldRendererConsumer(wr));
|
||||
WorldRendererConsumer newCons = new WorldRendererConsumer(wr);
|
||||
wrFlat.set(newCons);
|
||||
lighterFlat.get().setParent(newCons);
|
||||
}
|
||||
wrFlat.get().setOffset(pos);
|
||||
return render(lighterFlat.get(), world, model, block, pos, wr, checkSides);
|
||||
}
|
||||
else
|
||||
|
@ -60,8 +66,11 @@ public class ForgeBlockModelRenderer extends BlockModelRenderer
|
|||
if(wr != lastRendererSmooth.get())
|
||||
{
|
||||
lastRendererSmooth.set(wr);
|
||||
lighterSmooth.get().setParent(new WorldRendererConsumer(wr));
|
||||
WorldRendererConsumer newCons = new WorldRendererConsumer(wr);
|
||||
wrSmooth.set(newCons);
|
||||
lighterSmooth.get().setParent(newCons);
|
||||
}
|
||||
wrSmooth.get().setOffset(pos);
|
||||
return render(lighterSmooth.get(), world, model, block, pos, wr, checkSides);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -144,12 +144,13 @@ public class VertexLighterFlat extends QuadGatheringTransformer
|
|||
switch(parent.getVertexFormat().getElement(e).getUsage())
|
||||
{
|
||||
case POSITION:
|
||||
float[] pos = new float[4];
|
||||
// position adding moved to WorldRendererConsumer due to x and z not fitting completely into a float
|
||||
/*float[] pos = new float[4];
|
||||
System.arraycopy(position[v], 0, pos, 0, position[v].length);
|
||||
pos[0] += blockInfo.getBlockPos().getX();
|
||||
pos[1] += blockInfo.getBlockPos().getY();
|
||||
pos[2] += blockInfo.getBlockPos().getZ();
|
||||
parent.put(e, pos);
|
||||
pos[2] += blockInfo.getBlockPos().getZ();*/
|
||||
parent.put(e, position[v]);
|
||||
break;
|
||||
case NORMAL: if(normalIndex != -1)
|
||||
{
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
/**
|
||||
|
@ -14,6 +15,7 @@ public class WorldRendererConsumer implements IVertexConsumer
|
|||
private final WorldRenderer renderer;
|
||||
private final int[] quadData;
|
||||
private int v = 0;
|
||||
private BlockPos offset = BlockPos.ORIGIN;
|
||||
|
||||
public WorldRendererConsumer(WorldRenderer renderer)
|
||||
{
|
||||
|
@ -36,13 +38,18 @@ public class WorldRendererConsumer implements IVertexConsumer
|
|||
if(v == 4)
|
||||
{
|
||||
renderer.addVertexData(quadData);
|
||||
renderer.putPosition(0, 0, 0);
|
||||
renderer.putPosition(offset.getX(), offset.getY(), offset.getZ());
|
||||
Arrays.fill(quadData, 0);
|
||||
v = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setOffset(BlockPos offset)
|
||||
{
|
||||
this.offset = new BlockPos(offset);
|
||||
}
|
||||
|
||||
public void setQuadTint(int tint) {}
|
||||
public void setQuadOrientation(EnumFacing orientation) {}
|
||||
public void setQuadColored() {}
|
||||
|
|
Loading…
Reference in a new issue