-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: kumquat-ir <66188216+kumquat-ir@users.noreply.github.com> (cherry picked from commit 8c2f0c6)
- Loading branch information
1 parent
9015d5d
commit ed99845
Showing
8 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,3 +81,5 @@ local.properties | |
run/ | ||
|
||
logs/ | ||
|
||
libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/gregtech/asm/visitors/VintagiumManagerVistor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package gregtech.asm.visitors; | ||
|
||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.FieldVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
public class VintagiumManagerVistor extends ClassVisitor implements Opcodes { | ||
|
||
public static final String TARGET_CLASS_NAME = "me/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass"; | ||
|
||
public VintagiumManagerVistor(ClassVisitor cv) { | ||
super(ASM5, cv); | ||
} | ||
|
||
@Override | ||
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) { | ||
// Make BlockRenderPass.VALUES and BlockRenderPass.COUNT not final | ||
if (name.equals("VALUES") || name.equals("COUNT")) { | ||
return super.visitField(access & ~ACC_FINAL, name, desc, signature, value); | ||
} else { | ||
return super.visitField(access, name, desc, signature, value); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/gregtech/asm/visitors/VintagiumPassManagerVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package gregtech.asm.visitors; | ||
|
||
import gregtech.asm.util.ObfMapping; | ||
|
||
import org.objectweb.asm.MethodVisitor; | ||
import org.objectweb.asm.Opcodes; | ||
|
||
public class VintagiumPassManagerVisitor extends MethodVisitor implements Opcodes { | ||
|
||
public static final String TARGET_CLASS_NAME = "me/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPassManager"; | ||
public static final ObfMapping TARGET_METHOD = new ObfMapping(TARGET_CLASS_NAME, "createDefaultMappings", | ||
"()Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPassManager;"); | ||
public static final ObfMapping GET_BLOOM_LAYER = new ObfMapping("gregtech/client/utils/BloomEffectUtil", | ||
"getBloomLayer", "()Lnet/minecraft/util/BlockRenderLayer;"); | ||
public static final ObfMapping GET_BLOOM_PASS = new ObfMapping("gregtech/client/utils/BloomEffectVintagiumUtil", | ||
"getBloomPass", "()Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass;"); | ||
public static final ObfMapping ADD_MAPPING = new ObfMapping(TARGET_CLASS_NAME, "addMapping", | ||
"(Lnet/minecraft/util/BlockRenderLayer;Lme/jellysquid/mods/sodium/client/render/chunk/passes/BlockRenderPass;)V"); | ||
|
||
public VintagiumPassManagerVisitor(MethodVisitor mv) { | ||
super(ASM5, mv); | ||
} | ||
|
||
@Override | ||
public void visitInsn(int opcode) { | ||
// add mapper.addMapping(BloomEffectUtil.getBloomLayer(), BloomEffectVintagiumUtil.getBloomPass()); | ||
if (opcode == ARETURN) { | ||
GET_BLOOM_LAYER.visitMethodInsn(this, INVOKESTATIC); | ||
GET_BLOOM_PASS.visitMethodInsn(this, INVOKESTATIC); | ||
ADD_MAPPING.visitMethodInsn(this, INVOKESPECIAL); | ||
super.visitVarInsn(ALOAD, 0); | ||
} | ||
super.visitInsn(opcode); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/gregtech/client/utils/BloomEffectVintagiumUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package gregtech.client.utils; | ||
|
||
import net.minecraft.util.BlockRenderLayer; | ||
import net.minecraftforge.common.util.EnumHelper; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; | ||
import me.jellysquid.mods.sodium.client.util.BufferSizeUtil; | ||
import me.jellysquid.mods.sodium.client.util.EnumUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Objects; | ||
|
||
@SideOnly(Side.CLIENT) | ||
public class BloomEffectVintagiumUtil { | ||
|
||
private static BlockRenderPass bloom; | ||
|
||
public static void init() { | ||
EnumUtil.LAYERS = BlockRenderLayer.values(); | ||
BufferSizeUtil.BUFFER_SIZES.put(BloomEffectUtil.getBloomLayer(), 131072); | ||
bloom = EnumHelper.addEnum(BlockRenderPass.class, "BLOOM", | ||
new Class[] { BlockRenderLayer.class, boolean.class }, BloomEffectUtil.getBloomLayer(), true); | ||
|
||
try { | ||
Field values = BlockRenderPass.class.getField("VALUES"); | ||
values.set(null, BlockRenderPass.values()); | ||
Field count = BlockRenderPass.class.getField("COUNT"); | ||
count.set(null, BlockRenderPass.values().length); | ||
} catch (NoSuchFieldException | IllegalAccessException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
/** | ||
* @return {@link BlockRenderPass} instance for the bloom render layer. | ||
*/ | ||
@NotNull | ||
@SuppressWarnings("unused") | ||
public static BlockRenderPass getBloomPass() { | ||
return Objects.requireNonNull(bloom, "Bloom effect is not initialized yet"); | ||
} | ||
} |