Skip to content

Commit 82e1b43

Browse files
committed
Update BlockRender API to be more flexible.
1 parent ea9ce19 commit 82e1b43

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

loader/src/main/java/com/fox2code/foxloader/client/BlockRender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.fox2code.foxloader.client;
2525

26+
import net.minecraft.client.renderer.world.RenderBlocks;
2627
import net.minecraft.common.block.Block;
2728
import net.minecraft.common.world.BlockAccess;
2829

@@ -34,7 +35,7 @@ public BlockRender(boolean renderItemIn3D) {
3435
this.renderItemIn3D = renderItemIn3D;
3536
}
3637

37-
public abstract boolean renderBlock(BlockAccess blockAccess, Block block, int x, int y, int z);
38+
public abstract boolean renderBlock(RenderBlocks renderBlocks, BlockAccess blockAccess, Block block, int x, int y, int z);
3839

3940
public final int getAssignedID() {
4041
return this.assignedID;

loader/src/main/java/com/fox2code/foxloader/client/BlockRenderManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.fox2code.foxloader.client;
2525

26+
import net.minecraft.client.renderer.world.RenderBlocks;
2627
import net.minecraft.common.block.Block;
2728
import net.minecraft.common.world.BlockAccess;
2829

@@ -53,12 +54,12 @@ public static void registerBlockRender(BlockRender blockRender) {
5354
}
5455

5556
public static final class Internal {
56-
public static boolean renderBlockByType(BlockAccess blockAccess, Block block, int x, int y, int z, int renderType) {
57+
public static boolean renderBlockByType(RenderBlocks renderBlocks, BlockAccess blockAccess, Block block, int x, int y, int z, int renderType) {
5758
if (renderType < FL_INITIAL_ID || renderType > FL_MAX_ID) {
5859
return false;
5960
}
6061
BlockRender blockRender = blockRenders[renderType - FL_INITIAL_ID];
61-
return blockRender != null && blockRender.renderBlock(blockAccess, block, x, y, z);
62+
return blockRender != null && blockRender.renderBlock(renderBlocks, blockAccess, block, x, y, z);
6263
}
6364

6465
public static boolean renderItemIn3D(int renderType) {

patching/src/main/java/com/fox2code/foxloader/patching/game/RenderPatch.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private static void patchRenderBlocks(ClassNode classNode) {
7575
FieldNode blockAccess = TransformerUtils.getField(classNode, "blockAccess");
7676
InsnList renderBlockByRenderTypeFLX = new InsnList();
7777
renderBlockByRenderTypeFLX.add(new VarInsnNode(ALOAD, 0));
78+
renderBlockByRenderTypeFLX.add(new VarInsnNode(ALOAD, 0));
7879
renderBlockByRenderTypeFLX.add(new FieldInsnNode(GETFIELD,
7980
RenderBlocks, blockAccess.name, blockAccess.desc));
8081
renderBlockByRenderTypeFLX.add(new VarInsnNode(ALOAD, 1));
@@ -84,7 +85,7 @@ private static void patchRenderBlocks(ClassNode classNode) {
8485
renderBlockByRenderTypeFLX.add(new VarInsnNode(ILOAD, 5));
8586
renderBlockByRenderTypeFLX.add(new MethodInsnNode(INVOKESTATIC,
8687
BlockRenderManager$Internal, "renderBlockByType",
87-
"(L" + BlockAccess + ";L" + Block + ";IIII)Z"));
88+
"(L" + RenderBlocks + ";L" + BlockAccess + ";L" + Block + ";IIII)Z"));
8889
renderBlockByRenderTypeFLX.add(new InsnNode(IRETURN));
8990
insertDefaultSwitchCodeTail(renderBlockByRenderType, renderBlockByRenderTypeFLX);
9091
}

0 commit comments

Comments
 (0)