forked from TeamTwilight/twilightforest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
48 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
This file was deleted.
Oops, something went wrong.
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
62 changes: 62 additions & 0 deletions
62
tf-asm/src/main/java/twilightforest/asm/transformers/cloud/IsRainingAtTransformer.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,62 @@ | ||
package twilightforest.asm.transformers.cloud; | ||
|
||
import cpw.mods.modlauncher.api.ITransformer; | ||
import cpw.mods.modlauncher.api.ITransformerVotingContext; | ||
import cpw.mods.modlauncher.api.TargetType; | ||
import cpw.mods.modlauncher.api.TransformerVoteResult; | ||
import net.neoforged.coremod.api.ASMAPI; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.tree.MethodInsnNode; | ||
import org.objectweb.asm.tree.MethodNode; | ||
import org.objectweb.asm.tree.VarInsnNode; | ||
import twilightforest.asm.AsmUtil; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* {@link twilightforest.ASMHooks#isRainingAt} | ||
*/ | ||
public class IsRainingAtTransformer implements ITransformer<MethodNode> { | ||
|
||
@Override | ||
public @NotNull MethodNode transform(MethodNode node, ITransformerVotingContext context) { | ||
AsmUtil.findInstructions( | ||
node, | ||
Opcodes.IRETURN | ||
).forEach(target -> node.instructions.insertBefore( | ||
target, | ||
ASMAPI.listOf( | ||
new VarInsnNode(Opcodes.ALOAD, 0), | ||
new VarInsnNode(Opcodes.ALOAD, 1), | ||
new MethodInsnNode( | ||
Opcodes.INVOKESTATIC, | ||
"twilightforest/ASMHooks", | ||
"isRainingAt", | ||
"(ZLnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z" | ||
) | ||
) | ||
)); | ||
return node; | ||
} | ||
|
||
@Override | ||
public @NotNull TransformerVoteResult castVote(ITransformerVotingContext context) { | ||
return TransformerVoteResult.YES; | ||
} | ||
|
||
@Override | ||
public @NotNull Set<Target<MethodNode>> targets() { | ||
return Set.of(Target.targetMethod( | ||
"net.minecraft.world.level.Level", | ||
"isRainingAt", | ||
"(Lnet/minecraft/core/BlockPos;)Z" | ||
)); | ||
} | ||
|
||
@Override | ||
public @NotNull TargetType<MethodNode> getTargetType() { | ||
return TargetType.METHOD; | ||
} | ||
|
||
} |