Skip to content

Commit

Permalink
fix dev env mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
techno-sam committed Aug 8, 2024
1 parent 8e0be8f commit 8819065
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
/**
* You bear all the consequences of using this. Don't shoot yourself in the foot I guess? Try wearing proper mixin equipment?
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface DevEnvMixin {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.railwayteam.railways.Railways;
import com.railwayteam.railways.annotation.mixin.DevEnvMixin;
import com.railwayteam.railways.util.DevCapeUtils;
import com.railwayteam.railways.util.Utils;
import net.minecraft.client.multiplayer.PlayerInfo;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
Expand All @@ -48,9 +48,10 @@ public class MixinPlayerInfo {
@Unique private static final ResourceLocation DEV_CAPE = Railways.asResource("textures/misc/dev_cape.png");

// Replaces skin inside the dev env with the conductor skin
@DevEnvMixin
//@DevEnvMixin
@Inject(method = "getSkinLocation", at = @At("HEAD"))
private void registerSkinTextures(CallbackInfoReturnable<ResourceLocation> cir) {
if (!Utils.isDevEnv()) return;
this.textureLocations.put(
MinecraftProfileTexture.Type.SKIN,
Railways.asResource("textures/misc/devenv_skin.png")
Expand All @@ -73,14 +74,15 @@ private void skipCapeIfNeeded(CallbackInfoReturnable<ResourceLocation> cir) {
}

// Replaces skin model inside the dev env with the default "steve" skin model
@DevEnvMixin
//@DevEnvMixin
@Inject(method = "registerTextures",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/resources/SkinManager;registerSkins(Lcom/mojang/authlib/GameProfile;Lnet/minecraft/client/resources/SkinManager$SkinTextureCallback;Z)V"
)
)
private void railways$setModelToLarge(CallbackInfo ci) {
if (!Utils.isDevEnv()) return;
skinModel = "default";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.railwayteam.railways.mixin.CRMixinPlugin;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AnnotationNode;
import org.slf4j.event.Level;
import org.spongepowered.asm.service.MixinService;
import org.spongepowered.asm.util.Annotations;

Expand All @@ -38,6 +39,7 @@

public class ConditionalMixinManager {
public static boolean shouldApply(String className) {
var logger = CRMixinPlugin.LOGGER.atLevel(Utils.isDevEnv() ? Level.INFO : Level.DEBUG);
try {
List<AnnotationNode> annotationNodes = MixinService.getService().getBytecodeProvider().getClassNode(className).visibleAnnotations;
if (annotationNodes == null) return true;
Expand All @@ -49,10 +51,11 @@ public static boolean shouldApply(String className) {
boolean applyIfPresent = Annotations.getValue(node, "applyIfPresent", Boolean.TRUE);
boolean anyModsLoaded = anyModsLoaded(mods);
shouldApply = anyModsLoaded == applyIfPresent;
CRMixinPlugin.LOGGER.debug("{} is{}being applied because the mod(s) {} are{}loaded", className, shouldApply ? " " : " not ", mods, anyModsLoaded ? " " : " not ");
logger.log("{} is{}being applied because the mod(s) {} are{}loaded", className, shouldApply ? " " : " not ", mods, anyModsLoaded ? " " : " not ");
}
if (node.desc.equals(Type.getDescriptor(DevEnvMixin.class))) {
shouldApply &= Utils.isDevEnv();
logger.log("{} is {}being applied because we are {}in a development environment", className, shouldApply ? "" : "not ", Utils.isDevEnv() ? "" : "not ");
}
}
return shouldApply;
Expand Down

0 comments on commit 8819065

Please sign in to comment.