Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelTheColher committed Oct 9, 2023
1 parent b95a9f4 commit 5911aad
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 103 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.3-SNAPSHOT" apply false
id "org.ajoberstar.grgit" version "5.0.0" apply false
id "com.matthewprenger.cursegradle" version "1.4.0" apply false
id "com.modrinth.minotaur" version "2.+" apply false
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
@Mixin(CapeFeatureRenderer.class)
public class MixinCapeFeatureRenderer {

@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntitySolid(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"))
@Redirect(method = "render*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getEntitySolid(Lnet/minecraft/util/Identifier;)Lnet/minecraft/client/render/RenderLayer;"))
private RenderLayer fixCapeTransparency(Identifier texture) {
return RenderLayer.getArmorCutoutNoCull(texture);
}

// Fixes https://bugs.mojang.com/browse/MC-127749
@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 6)
@ModifyVariable(method = "render*", at = @At("STORE"), ordinal = 6)
private float fixCapeInterpolation(float bodyRotation, @Local(argsOnly = true) AbstractClientPlayerEntity playerEntity, @Local(ordinal = 2, argsOnly = true) float partialTicks) {
return playerEntity.prevBodyYaw + (playerEntity.bodyYaw - playerEntity.prevBodyYaw) * partialTicks;
}
Expand Down

This file was deleted.

30 changes: 20 additions & 10 deletions common/src/main/java/me/cael/capes/mixins/MixinPlayerListEntry.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
package me.cael.capes.mixins;

import com.mojang.authlib.GameProfile;
import me.cael.capes.CapeConfig;
import me.cael.capes.Capes;
import me.cael.capes.handler.PlayerHandler;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.util.Identifier;
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;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.function.Supplier;

@Mixin(PlayerListEntry.class)
public class MixinPlayerListEntry {
@Shadow @Final private GameProfile profile;
@Shadow private boolean texturesLoaded;

@Inject(method = "loadTextures", at = @At("HEAD"))
private void loadTextures(CallbackInfo ci) {
if (!texturesLoaded) {
PlayerHandler.Companion.onLoadTexture(profile);
}
@Inject(method = "texturesSupplier", at = @At("HEAD"))
private static void loadTextures(GameProfile profile, CallbackInfoReturnable<Supplier<SkinTextures>> cir) {
PlayerHandler.Companion.onLoadTexture(profile);
}

@Inject(method = "getCapeTexture", at = @At("TAIL"), cancellable = true)
private void getCapeTexture(CallbackInfoReturnable<Identifier> cir) {
@Inject(method = "getSkinTextures", at = @At("TAIL"), cancellable = true)
private void getCapeTexture(CallbackInfoReturnable<SkinTextures> cir) {
PlayerHandler handler = PlayerHandler.Companion.fromProfile(profile);
if (handler.getHasCape()) {
cir.setReturnValue(handler.getCape());
CapeConfig config = Capes.INSTANCE.getCONFIG();
SkinTextures oldTextures = cir.getReturnValue();
Identifier capeTexture = handler.getCape();
Identifier elytraTexture = handler.getHasElytraTexture() && config.getEnableElytraTexture() ? capeTexture : new Identifier("textures/entity/elytra.png");
SkinTextures newTextures = new SkinTextures(
oldTextures.texture(), oldTextures.textureUrl(),
capeTexture, elytraTexture,
oldTextures.model(), oldTextures.secure());
cir.setReturnValue(newTextures);
}
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.option.GameOptionsScreen;
import net.minecraft.client.gui.screen.option.SkinOptionsScreen;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.client.gui.widget.TextIconButtonWidget;
import net.minecraft.client.option.GameOptions;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(SkinOptionsScreen.class)
public class MixinSkinOptionsScreen extends GameOptionsScreen {

private static final Identifier CAPE_OPTIONS_ICON_TEXTURE = new Identifier("capes","textures/gui/options.png");
@Unique
private static final Identifier CAPE_OPTIONS_ICON_TEXTURE = new Identifier("capes","icon/cape_options");
@Unique
private final SelectorMenu selectorMenu = new SelectorMenu(this, this.gameOptions);

public MixinSkinOptionsScreen(Screen parent, GameOptions gameOptions, Text title) {
Expand All @@ -25,6 +28,6 @@ public MixinSkinOptionsScreen(Screen parent, GameOptions gameOptions, Text title

@Inject(method = "init", at = @At("RETURN"))
protected void init(CallbackInfo info) {
this.addDrawableChild(new TexturedButtonWidget(this.width / 2 - 179, this.height / 6, 20, 20, 0, 0, 20, CAPE_OPTIONS_ICON_TEXTURE,32, 64, (buttonWidget) -> this.client.setScreen(selectorMenu)));
this.addDrawableChild(TextIconButtonWidget.builder(Text.empty(), (buttonWidget) -> this.client.setScreen(selectorMenu), true).dimension(20, 20).texture(CAPE_OPTIONS_ICON_TEXTURE, 16, 16).build()).setPosition(this.width / 2 - 179, this.height / 6);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PlayerHandler(var profile: GameProfile) {

fun onLoadTexture(profile: GameProfile) {
val playerHandler = fromProfile(profile)
if (profile == MinecraftClient.getInstance().session.profile) {
if (profile == MinecraftClient.getInstance().gameProfile) {
playerHandler.hasCape = false
playerHandler.hasAnimatedCape = false
val config = Capes.CONFIG
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/kotlin/me/cael/capes/menu/MainMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ open class MainMenu(parent: Screen, gameOptions: GameOptions) : GameOptionsScree
}

override fun render(context: DrawContext, mouseX: Int, mouseY: Int, delta: Float) {
this.renderBackground(context)
this.renderBackground(context, mouseX, mouseY, delta)
context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 20, 16777215)
super.render(context, mouseX, mouseY, delta)
}
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/kotlin/me/cael/capes/menu/OtherMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class OtherMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent, gam
val random1Bi = BigInteger(128, Random())
val random2Bi = BigInteger(128, Random(System.identityHashCode(Object()).toLong()))
val serverId = random1Bi.xor(random2Bi).toString(16)
client!!.sessionService.joinServer(client!!.session.profile, client!!.session.accessToken, serverId)
val url = "https://optifine.net/capeChange?u=${client!!.session.uuid}&n=${client!!.session.username}&s=$serverId"
client!!.sessionService.joinServer(client!!.gameProfile.id, client!!.session.accessToken, serverId)
val url = "https://optifine.net/capeChange?u=${client!!.gameProfile.id}&n=${client!!.session.username}&s=$serverId"
client!!.setScreen(ConfirmLinkScreen({ bool: Boolean ->
if (bool) {
Util.getOperatingSystem().open(url)
Expand Down
7 changes: 1 addition & 6 deletions common/src/main/kotlin/me/cael/capes/menu/SelectorMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package me.cael.capes.menu

import com.mojang.blaze3d.systems.RenderSystem
import me.cael.capes.Capes
import me.cael.capes.mixins.AccessorPlayerListEntry
import me.cael.capes.render.DisplayPlayerEntityRenderer
import me.cael.capes.render.PlaceholderEntity
import net.minecraft.client.MinecraftClient
Expand Down Expand Up @@ -32,10 +31,6 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,
config.save()
it.message = config.clientCapeType.getText()
PlaceholderEntity.capeLoaded = false
if (this.client?.player != null) {
val playerListEntry = this.client!!.networkHandler!!.getPlayerListEntry(this.client!!.player!!.uuid) as AccessorPlayerListEntry
playerListEntry.setTexturesLoaded(false)
}
}.position((width / 2) - (buttonW / 2), 60).size(buttonW, 20).build())

addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE) {
Expand Down Expand Up @@ -113,7 +108,7 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,
override fun mouseDragged(mouseX: Double, mouseY: Double, button: Int, deltaX: Double, deltaY: Double): Boolean {
super.mouseDragged(mouseX, mouseY, button, deltaX, deltaY)
PlaceholderEntity.prevYaw = PlaceholderEntity.yaw
PlaceholderEntity.yaw = PlaceholderEntity.yaw - deltaX.toFloat()
PlaceholderEntity.yaw -= deltaX.toFloat()
return true
}

Expand Down
26 changes: 10 additions & 16 deletions common/src/main/kotlin/me/cael/capes/render/PlaceholderEntity.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
package me.cael.capes.render

import com.google.common.collect.Maps
import com.mojang.authlib.minecraft.MinecraftProfileTexture
import me.cael.capes.Capes
import me.cael.capes.handler.PlayerHandler
import net.minecraft.client.MinecraftClient
import net.minecraft.client.util.DefaultSkinHelper
import net.minecraft.client.util.SkinTextures
import net.minecraft.util.Identifier
import java.util.*
import kotlin.math.sqrt

object PlaceholderEntity {
private val textures: EnumMap<MinecraftProfileTexture.Type, Identifier> = Maps.newEnumMap(MinecraftProfileTexture.Type::class.java)
val gameProfile = MinecraftClient.getInstance().gameProfile

val gameProfile = MinecraftClient.getInstance().session.profile
var skin: SkinTextures = DefaultSkinHelper.getTexture(gameProfile)

var slim = false

var showBody = true
var showElytra = false
var capeLoaded = false
Expand All @@ -28,15 +27,10 @@ object PlaceholderEntity {
var prevX = 0.0

init {
MinecraftClient.getInstance().skinProvider.loadSkin(gameProfile,
{ type: MinecraftProfileTexture.Type, identifier: Identifier, texture: MinecraftProfileTexture ->
this.textures[type] = identifier
if (type == MinecraftProfileTexture.Type.SKIN) {
slim = texture.getMetadata("model") == "slim"
}
},
true
)
MinecraftClient.getInstance().skinProvider.fetchSkinTextures(gameProfile).thenAccept {
skin = it
slim = skin.model == SkinTextures.Model.SLIM
}
}

fun updateLimbs() {
Expand All @@ -56,7 +50,7 @@ object PlaceholderEntity {
PlayerHandler.onLoadTexture(gameProfile)
}
val handler = PlayerHandler.fromProfile(gameProfile)
return if (handler.hasCape) handler.getCape() else textures[MinecraftProfileTexture.Type.CAPE]
return if (handler.hasCape) handler.getCape() else skin.capeTexture
}

fun getElytraTexture(): Identifier {
Expand All @@ -65,5 +59,5 @@ object PlaceholderEntity {
return if (handler.hasElytraTexture && Capes.CONFIG.enableElytraTexture && capeTexture != null) capeTexture else Identifier("textures/entity/elytra.png")
}

fun getSkinTexture(): Identifier = textures.getOrDefault(MinecraftProfileTexture.Type.SKIN, DefaultSkinHelper.getTexture())
fun getSkinTexture(): Identifier = skin.texture
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions common/src/main/resources/capes-common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"mixins": [
],
"client": [
"AccessorPlayerListEntry",
"MixinCapeFeatureRenderer",
"MixinElytraFeatureRenderer",
"MixinPlayerListEntry",
"MixinSkinOptionsScreen"
],
Expand Down
8 changes: 4 additions & 4 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {

include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${rootProject.mixinextras_version}")))

modImplementation "com.ptsmods:devlogin:3.1.1"
modImplementation "com.ptsmods:devlogin:3.4.1"

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
Expand All @@ -52,20 +52,20 @@ shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
injectAccessWidener = true
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "fabric"
archiveClassifier.set "fabric"

from rootProject.file("LICENSE")
}

jar {
classifier "dev"
archiveClassifier.set "dev"
}

sourcesJar {
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"fabricloader": ">=0.14.21",
"fabric": "*",
"fabric-language-kotlin": "*",
"minecraft": ">=1.20",
"minecraft": ">=1.20.2",
"java": ">=17"
}
}
10 changes: 5 additions & 5 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ dependencies {
common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }

modImplementation "thedarkcolour:kotlinforforge:${forge_kotlin_version}"
implementation "thedarkcolour:kotlinforforge:${forge_kotlin_version}"

implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-common:${mixinextras_version}"))
implementation(include("com.github.llamalad7.mixinextras:mixinextras-forge:${mixinextras_version}"))

// modImplementation "com.ptsmods:devlogin:3.1.1"
modImplementation "com.ptsmods:devlogin:3.4.1"
}

processResources {
Expand All @@ -73,19 +73,19 @@ shadowJar {
mergeServiceFiles()

configurations = [project.configurations.shadowCommon]
classifier "dev-shadow"
archiveClassifier.set "dev-shadow"
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
classifier "forge"
archiveClassifier.set "forge"

from rootProject.file("LICENSE")
}

jar {
classifier "dev"
archiveClassifier.set "dev"
}

sourcesJar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.cael.capes.forge;
package me.cael.capes.forge.mixins;

import com.llamalad7.mixinextras.MixinExtrasBootstrap;
import org.objectweb.asm.tree.ClassNode;
Expand Down
8 changes: 4 additions & 4 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ A mod that lets you use capes from Optifine, LabyMod, Cosmetica, Wynntils, Capes
[[dependencies.capes]]
modId = "forge"
mandatory = true
versionRange = "[46,)"
versionRange = "[48,)"
ordering = "NONE"
side = "BOTH"
side = "CLIENT"

[[dependencies.capes]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20,)"
versionRange = "[1.20.2,)"
ordering = "NONE"
side = "BOTH"
side = "CLIENT"
2 changes: 1 addition & 1 deletion forge/src/main/resources/capes-forge.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"minVersion": "0.8",
"package": "me.cael.capes.forge.mixins",
"compatibilityLevel": "JAVA_17",
"plugin": "me.cael.capes.forge.ForgedCapesPlugin",
"plugin": "me.cael.capes.forge.mixins.ForgedCapesPlugin",
"mixins": [
],
"client": [
Expand Down
Loading

0 comments on commit 5911aad

Please sign in to comment.