Better Foliage

Better Foliage

35M Downloads

Release source code for ASM injections

Cadiboo opened this issue · 2 comments

commented

I’m making a coremod that alters the same method, and I’m implementing compatibility with your mod right now. My mod also alters the same parts of RenderChunk#rebuildChunk, and it would be appreciated if you released source code of what your doing to the method rather than just injecting the bytecode. I’ve already recompiled a version of the method with your injections added, but I’d like to see exactly what your aim is with your injections, rather than just your implementation of it. My current approach to compatibility with your mod involves removing your injections and replacing them with my own, then calling your methods that would have been injected from my own code. Here is the relevant snippet of your code:

// where: RenderChunk.rebuildChunk()
// what: replace call to BlockRendererDispatcher.renderBlock()
// why: allows us to perform additional rendering for each block
// what: invoke code to overrule result of Block.canRenderInLayer()
// why: allows us to render transparent quads for blocks which are only on the SOLID layer
transformMethod(Refs.rebuildChunk) {
find(invokeRef(Refs.renderBlock))?.replace {
log.info("[BetterFoliageLoader] Applying RenderChunk block render override")
varinsn(ALOAD, if (isOptifinePresent) 22 else 20)
invokeStatic(Refs.renderWorldBlock)
}
if (isOptifinePresent) {
find(varinsn(ISTORE, 23))?.insertAfter {
log.info("[BetterFoliageLoader] Applying RenderChunk block layer override")
varinsn(ALOAD, 19)
varinsn(ALOAD, 18)
varinsn(ALOAD, 22)
invokeStatic(Refs.canRenderBlockInLayer)
varinsn(ISTORE, 23)
}
} else {
find(invokeRef(Refs.canRenderInLayer))?.replace {
log.info("[BetterFoliageLoader] Applying RenderChunk block layer override")
invokeStatic(Refs.canRenderBlockInLayer)
}
}
}

commented

Closed by this mod's migration to Mixins