Skip to content

Commit

Permalink
Fixed resource pack lock issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
VipCoder8 committed Jan 24, 2025
1 parent be22aeb commit 4e803de
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.fyoncle.elysiumdaystweaks.mixin;

import net.minecraft.resource.ResourcePackProfile;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -9,19 +10,28 @@

@Mixin(ResourcePackProfile.class)
public abstract class ResourcePackLock {
private final String ED_RESOURCE_PACK = "elysium-days-tweaks:elysiumdaystweaks";
private final String[] EXCLUDE_FROM_UNPIN_RPS = {
ED_RESOURCE_PACK,
"__moremcmeta-internal__"
};
@Shadow public abstract String getName();

@Inject(at = @At("RETURN"), method = "getInitialPosition", cancellable = true)
public void getInitialPosition(CallbackInfoReturnable<ResourcePackProfile.InsertionPosition> cir) {
if(this.getName().equals("elysium-days-tweaks:elysiumdaystweaks")) {
cir.setReturnValue(ResourcePackProfile.InsertionPosition.TOP);
for (String excludeFromUnpinRp : EXCLUDE_FROM_UNPIN_RPS) {
if (this.getName().equals(excludeFromUnpinRp)) {
cir.setReturnValue(ResourcePackProfile.InsertionPosition.TOP);
}
}
}

@Inject(at = @At("RETURN"), method = "isPinned", cancellable = true)
public void isPinned(CallbackInfoReturnable<Boolean> cir) {
if(this.getName().equals("elysium-days-tweaks:elysiumdaystweaks")) {
cir.setReturnValue(true);
for(int i = 0; i < EXCLUDE_FROM_UNPIN_RPS.length; i++) {
if(this.getName().equals(EXCLUDE_FROM_UNPIN_RPS[i])) {
cir.setReturnValue(true);
}
}
}
}

0 comments on commit 4e803de

Please sign in to comment.