Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void renderBlock(IBlockAccess world, Vector3i pos, IBlockState state, IRe

IBlockState camoState = BaseBlockUtils.getBlockStateFromItemStack(stack);
if (blockCanRenderInLayer(camoState.getBlock(), layer)) {
BaseRenderingUtils.renderAlternateBlock(SGCraft.mod, world, pos, camoState, target);
BaseRenderingUtils.renderAlternateBlock(world, pos, camoState, target);
}
}

Expand Down
27 changes: 13 additions & 14 deletions src/main/java/gcewing/sg/utils/rendering/BaseRenderingUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

import org.joml.Vector3i;

import gcewing.sg.BaseMod;
import gcewing.sg.interfaces.IBlockState;
import gcewing.sg.interfaces.IRenderTarget;
import gcewing.sg.renderers.BaseWorldRenderTarget;

public class BaseRenderingUtils {

public static void renderAlternateBlock(BaseMod mod, IBlockAccess world, Vector3i pos, IBlockState state,
IRenderTarget target) {
Block block = state.getBlock();
int meta = getMetaFromBlockState(state);
private static final AltBlockAccess altBlockAccess = new AltBlockAccess();
private static final RenderBlocks altRenderBlocks = new RenderBlocks(altBlockAccess);

public static void renderAlternateBlock(IBlockAccess world, Vector3i pos, IBlockState state, IRenderTarget target) {
final Block block = state.getBlock();
final int meta = getMetaFromBlockState(state);
renderAlternateBlock(world, pos.x, pos.y, pos.z, block, meta, target);
}

Expand All @@ -33,15 +34,13 @@ public static void renderAlternateBlock(IBlockAccess world, int x, int y, int z,
if (block.hasTileEntity(meta)) {
return;
}

altBlockAccess.setup(world, x, y, z, meta);
altRenderBlocks.renderBlockAllFaces(block, x, y, z);
((BaseWorldRenderTarget) target).setRenderingOccurred();
try {
altBlockAccess.setup(world, x, y, z, meta);
altRenderBlocks.renderBlockAllFaces(block, x, y, z);
((BaseWorldRenderTarget) target).setRenderingOccurred();
} finally {
altBlockAccess.base = null;
}
}

// ------------------------------------------------------------------------------------------------

protected static AltBlockAccess altBlockAccess = new AltBlockAccess();
protected static RenderBlocks altRenderBlocks = new RenderBlocks(altBlockAccess);

}
14 changes: 12 additions & 2 deletions src/main/java/gcewing/sg/worldgen/NaquadahOreWorldGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkP
x0 = chunkX * 16;
z0 = chunkZ * 16;
chunk = world.getChunkFromChunkCoords(chunkX, chunkZ);
generateChunk();
try {
generateChunk();
} finally {
this.world = null;
this.chunk = null;
}
}

public void regenerate(Chunk chunk) {
Expand All @@ -70,7 +75,12 @@ public void regenerate(Chunk chunk) {
random.setSeed((xSeed * chunkX + zSeed * chunkZ) ^ worldSeed);
x0 = chunkX * 16;
z0 = chunkZ * 16;
generateChunk();
try {
generateChunk();
} finally {
this.world = null;
this.chunk = null;
}
}

Block getBlock(int x, int y, int z) {
Expand Down
Loading