Skip to content

Commit

Permalink
1.21.2 moment
Browse files Browse the repository at this point in the history
  • Loading branch information
CaelTheColher committed Oct 22, 2024
1 parent 993664b commit 595bdbe
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 115 deletions.
7 changes: 2 additions & 5 deletions 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 "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-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 All @@ -20,10 +20,7 @@ subprojects {

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.layered {
it.mappings("net.fabricmc:yarn:${rootProject.yarn_mappings}:v2")
it.mappings("dev.architectury:yarn-mappings-patch-neoforge:${rootProject.neoforge_yarn_mappings}")
}
mappings "net.fabricmc:yarn:${rootProject.yarn_mappings}:v2"
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package me.cael.capes.mixins;

import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.feature.CapeFeatureRenderer;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(CapeFeatureRenderer.class)
Expand All @@ -17,10 +14,4 @@ public class MixinCapeFeatureRenderer {
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)
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;
}
}
4 changes: 2 additions & 2 deletions common/src/main/kotlin/me/cael/capes/handler/PlayerHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class PlayerHandler(var profile: GameProfile) {
val imgNew = NativeImage(imageWidth, imageHeight, true)
for (x in 0 until srcWidth) {
for (y in 0 until srcHeight) {
imgNew.setColor(x, y, img.getColor(x, y))
imgNew.setColorArgb(x, y, img.getColorArgb(x, y))
}
}
img.close()
Expand All @@ -191,7 +191,7 @@ class PlayerHandler(var profile: GameProfile) {
val frame = NativeImage(img.width, img.width / 2, true)
for (x in 0 until frame.width) {
for (y in 0 until frame.height) {
frame.setColor(x, y, img.getColor(x, y + (currentFrame * (img.width / 2))))
frame.setColorArgb(x, y, img.getColorArgb(x, y + (currentFrame * (img.width / 2))))
}
}
animatedCape[currentFrame] = frame
Expand Down
38 changes: 20 additions & 18 deletions common/src/main/kotlin/me/cael/capes/menu/SelectorMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,16 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,

buttonW = 100

addDrawableChild(ButtonWidget.builder(Text.translatable("options.capes.selector.player")) {
PlaceholderEntity.showBody = !PlaceholderEntity.showBody
}.position((width / 4) - (buttonW / 2), 145).size(buttonW, 20).build())

addDrawableChild(ButtonWidget.builder(Text.translatable("options.capes.selector.elytra")) {
PlaceholderEntity.showElytra = !PlaceholderEntity.showElytra
}.position((width / 4) - (buttonW / 2), 120).size(buttonW, 20).build())

addDrawableChild(ButtonWidget.builder(Text.translatable("options.capes.selector.player")) {
PlaceholderEntity.showBody = !PlaceholderEntity.showBody
}.position((width / 4) - (buttonW / 2), 145).size(buttonW, 20).build())
addDrawableChild(ButtonWidget.builder(Text.literal("DO NOT ASK WHY THIS EXISTS")) {
}.size(0, 0).build())

}

Expand Down Expand Up @@ -73,7 +76,7 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,
matrixStack.pushMatrix()
matrixStack.translate(x.toFloat(), y.toFloat(), 1050.0f)
matrixStack.scale(1.0f, 1.0f, -1.0f)
RenderSystem.applyModelViewMatrix()
// RenderSystem.applyModelViewMatrix()
val matrixStack2 = MatrixStack()
matrixStack2.translate(0.0, 0.0, 1000.0)
matrixStack2.scale(size.toFloat(), size.toFloat(), size.toFloat())
Expand All @@ -85,23 +88,22 @@ class SelectorMenu(parent: Screen, gameOptions: GameOptions) : MainMenu(parent,
val entityRenderDispatcher = MinecraftClient.getInstance().entityRenderDispatcher
entityRenderDispatcher.setRenderShadows(false)
val immediate = MinecraftClient.getInstance().bufferBuilders.entityVertexConsumers
RenderSystem.runAsFancy {
val ctx = EntityRendererFactory.Context(
MinecraftClient.getInstance().entityRenderDispatcher,
MinecraftClient.getInstance().itemRenderer,
MinecraftClient.getInstance().blockRenderManager,
MinecraftClient.getInstance().entityRenderDispatcher.heldItemRenderer,
MinecraftClient.getInstance().resourceManager,
MinecraftClient.getInstance().entityModelLoader,
MinecraftClient.getInstance().textRenderer
)
val displayPlayerEntityRenderer = DisplayPlayerEntityRenderer(ctx, entity.slim)
displayPlayerEntityRenderer.render(entity, 1.0f, matrixStack2, immediate, 0xF000F0)
}
val ctx = EntityRendererFactory.Context(
MinecraftClient.getInstance().entityRenderDispatcher,
MinecraftClient.getInstance().itemRenderer,
MinecraftClient.getInstance().mapRenderer,
MinecraftClient.getInstance().blockRenderManager,
MinecraftClient.getInstance().resourceManager,
MinecraftClient.getInstance().entityModelLoader,
MinecraftClient.getInstance().equipmentModelLoader,
MinecraftClient.getInstance().textRenderer
)
val displayPlayerEntityRenderer = DisplayPlayerEntityRenderer(ctx, entity.slim)
displayPlayerEntityRenderer.render(entity, 1.0f, matrixStack2, immediate, 0xF000F0)
immediate.draw()
entityRenderDispatcher.setRenderShadows(true)
matrixStack.popMatrix()
RenderSystem.applyModelViewMatrix()
// RenderSystem.applyModelViewMatrix()
DiffuseLighting.enableGuiDepthLighting()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import net.minecraft.client.render.entity.LivingEntityRenderer
import net.minecraft.client.render.entity.model.ElytraEntityModel
import net.minecraft.client.render.entity.model.EntityModelLayers
import net.minecraft.client.render.entity.model.PlayerEntityModel
import net.minecraft.client.render.entity.state.PlayerEntityRenderState
import net.minecraft.client.render.item.ItemRenderer
import net.minecraft.client.util.DefaultSkinHelper
import net.minecraft.client.util.math.MatrixStack
Expand All @@ -19,23 +20,21 @@ import net.minecraft.util.math.MathHelper
import net.minecraft.util.math.RotationAxis

class DisplayPlayerEntityRenderer(val ctx: EntityRendererFactory.Context, slim: Boolean) :
LivingEntityRenderer<LivingEntity, PlayerEntityModel<LivingEntity>> (
LivingEntityRenderer<LivingEntity, PlayerEntityRenderState, PlayerEntityModel> (
ctx,
PlayerEntityModel<LivingEntity>(
PlayerEntityModel(
ctx.getPart(if (slim) EntityModelLayers.PLAYER_SLIM else EntityModelLayers.PLAYER),
slim
),
0.5f
) {

val elytra = ElytraEntityModel<LivingEntity>(ctx.modelLoader.getModelPart(EntityModelLayers.ELYTRA))
val elytra = ElytraEntityModel(ctx.modelLoader.getModelPart(EntityModelLayers.ELYTRA))

fun render(livingEntity : PlaceholderEntity, tickDelta: Float, matrixStack: MatrixStack, vertexConsumerProvider: VertexConsumerProvider, light: Int) {
setModelPose()
matrixStack.push()

model.child = false

matrixStack.scale(0.9375f, 0.9375f, 0.9375f)
matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0f - livingEntity.yaw))
matrixStack.scale(-1.0f, -1.0f, 1.0f)
Expand All @@ -60,22 +59,17 @@ class DisplayPlayerEntityRenderer(val ctx: EntityRendererFactory.Context, slim:
if (!PlaceholderEntity.showElytra) {
if (PlaceholderEntity.getCapeTexture() == null) return
matrixStack.push()
matrixStack.translate(0.0f, 0.0f, 0.125f)

matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(3.0f))
matrixStack.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0f))

matrixStack.multiply(RotationAxis.POSITIVE_X.rotationDegrees(6.0f))
val vertexConsumer = vertexConsumerProvider.getBuffer(RenderLayer.getArmorCutoutNoCull(PlaceholderEntity.getCapeTexture()))
ctx.getPart(EntityModelLayers.PLAYER).getChild("cloak")
ctx.getPart(EntityModelLayers.PLAYER_CAPE).getChild("body").getChild("cape")
.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV)
matrixStack.pop()
} else {
val identifier = PlaceholderEntity.getElytraTexture()
matrixStack.push()
matrixStack.translate(0.0f, 0.0f, 0.125f)

this.model.copyStateTo(this.elytra)

val vertexConsumer = ItemRenderer.getArmorGlintConsumer(vertexConsumerProvider, RenderLayer.getArmorCutoutNoCull(identifier), false)
this.elytra.render(matrixStack, vertexConsumer, light, OverlayTexture.DEFAULT_UV)
matrixStack.pop()
Expand Down Expand Up @@ -115,13 +109,6 @@ class DisplayPlayerEntityRenderer(val ctx: EntityRendererFactory.Context, slim:
model.body.pivotY = 0.0f
model.leftArm.pivotY = 2.0f
model.rightArm.pivotY = 2.0f

model.hat.copyTransform(model.head)
model.leftPants.copyTransform(model.leftLeg)
model.rightPants.copyTransform(model.rightLeg)
model.leftSleeve.copyTransform(model.leftArm)
model.rightSleeve.copyTransform(model.rightArm)
model.jacket.copyTransform(model.body)
}

private fun setModelPose() {
Expand All @@ -136,5 +123,7 @@ class DisplayPlayerEntityRenderer(val ctx: EntityRendererFactory.Context, slim:
playerEntityModel.rightSleeve.visible = options.isPlayerModelPartEnabled(PlayerModelPart.RIGHT_SLEEVE)
}

override fun getTexture(entity: LivingEntity?): Identifier = DefaultSkinHelper.getTexture()
override fun getTexture(state: PlayerEntityRenderState?): Identifier = DefaultSkinHelper.getTexture()

override fun createRenderState(): PlayerEntityRenderState = PlayerEntityRenderState()
}
4 changes: 2 additions & 2 deletions fabric/src/main/kotlin/me/cael/capes/fabric/FabricCapes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ object FabricCapes : ClientModInitializer {
)
} ?: throw EntityArgumentType.PLAYER_NOT_FOUND_EXCEPTION.create()
val debugInfo = getDebugInfoForPlayer(target.gameProfile)
context.source.player.sendMessage(debugInfo)
context.source.player.sendMessage(debugInfo, false)
return@executes 1
}
)
.executes { context ->
val debugInfo = getDebugInfoForPlayer(context.source.player.gameProfile)
context.source.player.sendMessage(debugInfo)
context.source.player.sendMessage(debugInfo, false)
return@executes 1
}
)
Expand Down
5 changes: 1 addition & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
"value": "me.cael.capes.fabric.FabricCapes"
}
],
"preLaunch": [
"com.llamalad7.mixinextras.MixinExtrasBootstrap::init"
],
"modmenu": [
"me.cael.capes.fabric.compatibility.ModMenuCompatibility"
]
Expand All @@ -40,7 +37,7 @@
"fabricloader": ">=0.14.21",
"fabric": "*",
"fabric-language-kotlin": "*",
"minecraft": ">=1.20.5",
"minecraft": ">=1.21",
"java": ">=21"
}
}

This file was deleted.

1 change: 0 additions & 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,6 @@
"minVersion": "0.8",
"package": "me.cael.capes.forge.mixins",
"compatibilityLevel": "JAVA_17",
"plugin": "me.cael.capes.forge.mixins.ForgedCapesPlugin",
"mixins": [
],
"client": [
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
org.gradle.jvmargs=-Xmx8G

minecraft_version=1.21
yarn_mappings=1.21+build.2
minecraft_version=1.21.2
yarn_mappings=1.21.2+build.1
neoforge_yarn_mappings=1.21+build.4
enabled_platforms=fabric

archives_base_name=capes
mod_version=1.5.4+1.21
mod_version=1.5.4+1.21.2
maven_group=me.capes

fabric_loader_version=0.15.11
fabric_api_version=0.100.1+1.21
fabric_loader_version=0.16.7
fabric_api_version=0.106.1+1.21.2

forge_version=21.0.8-beta
forge_version=21.2.0-beta

# Other APIs
fabric_kotlin_version=1.11.0+kotlin.2.0.0
fabric_kotlin_version=1.12.3+kotlin.2.0.21
forge_kotlin_version=5.+
modmenu_version=11.+
modmenu_version=12.+

# Publishing
curseforge_id=408481
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ pluginManagement {

include("common")
include("fabric")
include("forge")
//include("forge")

rootProject.name = "Capes"

0 comments on commit 595bdbe

Please sign in to comment.