generated from My-Name-Is-Jeff/basic-mixin-template
-
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
89caa62
commit 50e0630
Showing
6 changed files
with
101 additions
and
7 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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/mynameisjeff/simpletogglesprint/mixins/playerapi/MixinClientPlayerAPI.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,23 @@ | ||
package mynameisjeff.simpletogglesprint.mixins.playerapi; | ||
|
||
import com.mojang.authlib.GameProfile; | ||
import mynameisjeff.simpletogglesprint.SimpleToggleSprint; | ||
import net.minecraft.client.entity.AbstractClientPlayer; | ||
import net.minecraft.client.entity.EntityPlayerSP; | ||
import net.minecraft.client.settings.KeyBinding; | ||
import net.minecraft.world.World; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(EntityPlayerSP.class) | ||
public abstract class MixinClientPlayerAPI extends AbstractClientPlayer { | ||
public MixinClientPlayerAPI(World worldIn, GameProfile playerProfile) { | ||
super(worldIn, playerProfile); | ||
} | ||
|
||
@Redirect(method = "localOnLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/settings/KeyBinding;isKeyDown()Z")) | ||
private boolean setSprintState(KeyBinding keyBinding) { | ||
return SimpleToggleSprint.shouldSetSprint(keyBinding); | ||
}} |
59 changes: 59 additions & 0 deletions
59
src/main/java/mynameisjeff/simpletogglesprint/tweaker/MixinPlugin.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,59 @@ | ||
package mynameisjeff.simpletogglesprint.tweaker; | ||
|
||
import net.minecraftforge.fml.relauncher.CoreModManager; | ||
import org.spongepowered.asm.lib.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; | ||
|
||
public class MixinPlugin implements IMixinConfigPlugin { | ||
|
||
private boolean hasPlayerAPI = false; | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
for (Map.Entry<String, List<String>> e : CoreModManager.getTransformers().entrySet()) { | ||
if (e.getKey().startsWith("PlayerAPIPlugin") && e.getValue().contains("api.player.forge.PlayerAPITransformer")) { | ||
System.out.println("PlayerAPI detected."); | ||
hasPlayerAPI = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
if (mixinClassName.startsWith("mynameisjeff.simpletogglesprint.mixins.playerapi.")) { | ||
return hasPlayerAPI; | ||
} | ||
return true; | ||
} | ||
|
||
@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