generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
678522d
commit 4c8f43b
Showing
9 changed files
with
97 additions
and
22 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 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
18 changes: 18 additions & 0 deletions
18
src/main/java/net/mine_diver/spasm/api/transform/PhaseListener.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,18 @@ | ||
package net.mine_diver.spasm.api.transform; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import com.google.common.collect.Sets; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.EnumSet; | ||
|
||
public interface PhaseListener { | ||
ImmutableSet<TransformationPhase> | ||
DEFAULT_PHASES = Sets.immutableEnumSet(TransformationPhase.BEFORE_MIXINS), | ||
ALL_PHASES = Sets.immutableEnumSet(EnumSet.allOf(TransformationPhase.class)); | ||
|
||
|
||
default @NotNull ImmutableSet<TransformationPhase> getPhases() { | ||
return DEFAULT_PHASES; | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/main/java/net/mine_diver/spasm/api/transform/TransformationPhase.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,12 @@ | ||
package net.mine_diver.spasm.api.transform; | ||
|
||
import net.mine_diver.spasm.impl.SpASM; | ||
|
||
public enum TransformationPhase { | ||
BEFORE_MIXINS, | ||
AFTER_MIXINS; | ||
|
||
public static TransformationPhase getCurrent() { | ||
return SpASM.getCurrentPhase(); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/test/java/net/mine_diver/spasm/test/AllPhaseTransformer.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,22 @@ | ||
package net.mine_diver.spasm.test; | ||
|
||
import com.google.common.collect.ImmutableSet; | ||
import net.mine_diver.spasm.api.transform.RawClassTransformer; | ||
import net.mine_diver.spasm.api.transform.TransformationPhase; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.Optional; | ||
|
||
public class AllPhaseTransformer implements RawClassTransformer { | ||
@Override | ||
public @NotNull ImmutableSet<TransformationPhase> getPhases() { | ||
return ALL_PHASES; | ||
} | ||
|
||
@Override | ||
public @NotNull Optional<byte[]> transform(@NotNull ClassLoader classLoader, @NotNull String className, byte @NotNull [] classBytes) { | ||
System.out.println("Phase transformer! " + className + " " + Arrays.hashCode(classBytes) + " " + TransformationPhase.getCurrent()); | ||
return Optional.empty(); | ||
} | ||
} |
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