-
Notifications
You must be signed in to change notification settings - Fork 10
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
d177aa2
commit b24d8df
Showing
8 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
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
4 changes: 4 additions & 0 deletions
4
src/client/java/dev/enjarai/trickster/mixin/client/SodiumLevelSliceMixin.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,4 @@ | ||
package dev.enjarai.trickster.mixin.client; | ||
|
||
public class SodiumLevelSliceMixin { | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/dev/enjarai/trickster/ConditionalMixins.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,58 @@ | ||
package dev.enjarai.trickster; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import net.fabricmc.loader.api.FabricLoader; | ||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
|
||
// stole this impl from https://github.com/Juuxel/Adorn/blob/bd70a2955640897bc68ff1f4f201fe5e6c10bc32/fabric/src/main/java/juuxel/adorn/AdornMixinPlugin.java | ||
public class ClientConditionalMixins implements IMixinConfigPlugin { | ||
private static final Supplier<Boolean> TRUE = () -> true; | ||
|
||
private static final Map<String, Supplier<Boolean>> CONDITIONS = ImmutableMap.of( | ||
"dev.enjarai.trickster.mixin.client.SodiumLevelSliceMixin", () -> FabricLoader.getInstance().isModLoaded("sodium") | ||
); | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
return CONDITIONS.getOrDefault(mixinClassName, TRUE).get(); | ||
} | ||
|
||
// Boilerplate | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
|
||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
|
||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
|
||
} | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/dev/enjarai/trickster/spell/tricks/func/IteratorTrick.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,42 @@ | ||
package dev.enjarai.trickster.spell.tricks.func; | ||
|
||
import dev.enjarai.trickster.spell.Fragment; | ||
import dev.enjarai.trickster.spell.Pattern; | ||
import dev.enjarai.trickster.spell.SpellContext; | ||
import dev.enjarai.trickster.spell.fragment.FragmentType; | ||
import dev.enjarai.trickster.spell.fragment.ListFragment; | ||
import dev.enjarai.trickster.spell.fragment.NumberFragment; | ||
import dev.enjarai.trickster.spell.tricks.Trick; | ||
import dev.enjarai.trickster.spell.tricks.blunder.BlunderException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class IteratorTrick extends Trick { | ||
public IteratorTrick() { | ||
super(Pattern.of(3, 6, 4, 0, 1, 2, 5, 8, 7, 4, 3)); | ||
} | ||
|
||
@Override | ||
public Fragment activate(SpellContext ctx, List<Fragment> fragments) throws BlunderException { | ||
var executable = expectInput(fragments, FragmentType.SPELL_PART, 0); | ||
var list = expectInput(fragments, FragmentType.LIST, 1); | ||
var result = new ArrayList<Fragment>(); | ||
int index = 0; | ||
|
||
for (var item : list.fragments()) { | ||
var args = new ArrayList<Fragment>(); | ||
args.add(item); | ||
args.add(new NumberFragment(index)); | ||
args.addAll(fragments.subList(1, fragments.size())); | ||
ctx.pushPartGlyph(args); | ||
ctx.pushStackTrace(-2); | ||
result.add(executable.run(ctx)); | ||
ctx.popStackTrace(); | ||
ctx.popPartGlyph(); | ||
index++; | ||
} | ||
|
||
return new ListFragment(result); | ||
} | ||
} |
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