Skip to content

Commit

Permalink
Port ChunkStatusListTransformer
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamaized committed Jun 13, 2024
1 parent 1ba03b3 commit 452c896
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 43 deletions.
13 changes: 7 additions & 6 deletions src/main/java/twilightforest/ASMHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ public static boolean mountFix(boolean o, boolean wantsToStopRiding, boolean isP
/**
* {@link twilightforest.asm.transformers.book.ModifyWrittenBookNameTransformer}<p/>
*
* Injection Point:<br>
* {@link net.minecraft.world.item.WrittenBookItem#getName(net.minecraft.world.item.ItemStack)}<br>
* Injection Point:<br/>
* {@link net.minecraft.world.item.WrittenBookItem#getName(net.minecraft.world.item.ItemStack)}
*/
public static Component modifyWrittenBookName(Component component, ItemStack stack) {
if (stack.has(TFDataComponents.TRANSLATABLE_BOOK)) {
Expand Down Expand Up @@ -294,11 +294,12 @@ public static boolean lead(boolean o, LeashFenceKnotEntity entity) {
}

/**
* Injection Point:<br>
* {@link net.minecraft.world.level.chunk.status.ChunkStatus#getStatusList()}<br>
* [HEAD]
* {@link twilightforest.asm.transformers.chunk.ChunkStatusListTransformer}<p/>
*
* Injection Point:<br/>
* {@link net.minecraft.world.level.chunk.status.ChunkStatus#getStatusList()}
*/
public static void assertChunkBlanketing() {
public static void chunkStatusList() {
// Only need to touch this class to ensure it's classloaded before other classes cache our reconstructed ChunkStatus sequence
ChunkBlanketProcessors.init();
}
Expand Down
35 changes: 0 additions & 35 deletions src/main/resources/META-INF/asm/chunkstatus.js

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/META-INF/coremods.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"shroom": "META-INF/asm/shroom.js",
"cloud": "META-INF/asm/cloud.js",
"lead": "META-INF/asm/lead.js",
"chunkstatus": "META-INF/asm/chunkstatus.js",
"structure_terraform": "META-INF/asm/structure_terraform.js",
"structure_scan": "META-INF/asm/structure_scan.js"
}
6 changes: 5 additions & 1 deletion tf-asm/src/main/java/twilightforest/asm/TFCoreMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import twilightforest.asm.transformers.armor.ArmorVisibilityRenderingTransformer;
import twilightforest.asm.transformers.armor.CancelArmorRenderingTransformer;
import twilightforest.asm.transformers.book.ModifyWrittenBookNameTransformer;
import twilightforest.asm.transformers.chunk.ChunkStatusListTransformer;

import java.util.List;

Expand All @@ -19,7 +20,10 @@ public Iterable<? extends ITransformer<?>> getTransformers() {
new ArmorVisibilityRenderingTransformer(),

// book
new ModifyWrittenBookNameTransformer()
new ModifyWrittenBookNameTransformer(),

// chunk
new ChunkStatusListTransformer()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package twilightforest.asm.transformers.chunk;

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#chunkStatusList}
*/
public class ChunkStatusListTransformer implements ITransformer<MethodNode> {

@Override
public @NotNull MethodNode transform(MethodNode node, ITransformerVotingContext context) {
node.instructions.insert(
ASMAPI.listOf(
new MethodInsnNode(
Opcodes.INVOKESTATIC,
"twilightforest/ASMHooks",
"chunkStatusList",
"()V"
)
)
);
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.chunk.status.ChunkStatus",
"getStatusList",
"()Ljava/util/List;"
));
}

@Override
public @NotNull TargetType<MethodNode> getTargetType() {
return TargetType.METHOD;
}

}

0 comments on commit 452c896

Please sign in to comment.