Skip to content

Commit

Permalink
Hacky update to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Oct 30, 2024
1 parent ce65149 commit af6ea24
Show file tree
Hide file tree
Showing 13 changed files with 460 additions and 320 deletions.
88 changes: 72 additions & 16 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,44 @@ jobs:
name: ${{github.ref_name}}-1.20.6 - Fabric
files: 'versions/1.20.6-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.20.6
- name: Publish-1.21-forge-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 521480
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21(.1) - Forge
version-type: beta
files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc)).jar'
game-versions: 1.21.x
- name: Publish-1.21-forge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: zV5r3pPn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21(.1) - Forge
files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc)).jar'
game-versions: 1.21.x
- name: Publish-1.21-neoforge-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 521480
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21(.1) - NeoForge
version-type: beta
files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
- name: Publish-1.21-neoforge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: zV5r3pPn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21(.1) - NeoForge
files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
- name: Publish-1.21-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
Expand All @@ -465,41 +503,59 @@ jobs:
name: ${{github.ref_name}}-1.21(.1) - Fabric
files: 'versions/1.21-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
- name: Publish-1.21-forge-Curseforge
- name: Publish-1.21.3-forge-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 521480
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21(.1) - Forge
name: ${{github.ref_name}}-1.21.3 - Forge
version-type: beta
files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc)).jar'
game-versions: 1.21.x
- name: Publish-1.21-forge-Modrinth
files: 'versions/1.21.3-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-forge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: zV5r3pPn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: forge
name: ${{github.ref_name}}-1.21(.1) - Forge
files: 'versions/1.21-forge/build/libs/!(*-@(dev|sources|javadoc)).jar'
game-versions: 1.21.x
- name: Publish-1.21-neoforge-Curseforge
name: ${{github.ref_name}}-1.21.3 - Forge
files: 'versions/1.21.3-forge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-neoforge-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 521480
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21(.1) - NeoForge
name: ${{github.ref_name}}-1.21.3 - NeoForge
version-type: beta
files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
- name: Publish-1.21-neoforge-Modrinth
files: 'versions/1.21.3-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-neoforge-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: zV5r3pPn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: neoforge
name: ${{github.ref_name}}-1.21(.1) - NeoForge
files: 'versions/1.21-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.x
name: ${{github.ref_name}}-1.21.3 - NeoForge
files: 'versions/1.21.3-neoforge/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-fabric-Curseforge
uses: Kir-Antipov/[email protected]
with:
curseforge-id: 521480
curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
- name: Publish-1.21.3-fabric-Modrinth
uses: Kir-Antipov/[email protected]
with:
modrinth-id: zV5r3pPn
modrinth-token: ${{ secrets.MODRINTH_TOKEN }}
loaders: fabric
name: ${{github.ref_name}}-1.21.3 - Fabric
files: 'versions/1.21.3-fabric/build/libs/!(*-@(dev|sources|javadoc|all)).jar'
game-versions: 1.21.3
2 changes: 1 addition & 1 deletion gradle-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source: "https://github.com/tr7zw/ProcessedModTemplate/tree/master"
replacements:
name: "3d-Skin-Layers"
id: "skinlayers3d"
version: "1.6.7"
version: "1.7.0"
description: "Renders the player skin layer in 3d"
homepageUrl: "https://modrinth.com/mod/3dskinlayers"
sourcesUrl: "https://github.com/tr7zw/3d-skin-layers"
Expand Down
7 changes: 5 additions & 2 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"1.20.6-forge",
"1.20.6-neoforge",
"1.20.6-fabric",
"1.21-fabric",
"1.21-forge",
"1.21-neoforge"
"1.21-neoforge",
"1.21-fabric",
"1.21.3-forge",
"1.21.3-neoforge",
"1.21.3-fabric"
]
}
9 changes: 9 additions & 0 deletions src/main/java/dev/tr7zw/skinlayers/SkinLayersModBase.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
package dev.tr7zw.skinlayers;

import java.util.Set;

import com.google.common.collect.Sets;

import dev.tr7zw.skinlayers.accessor.PlayerSettings;
import dev.tr7zw.skinlayers.config.ConfigScreenProvider;
import dev.tr7zw.skinlayers.versionless.ModBase;
import dev.tr7zw.util.ModLoaderUtil;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;

public abstract class SkinLayersModBase extends ModBase {

public static SkinLayersModBase instance;
// TODO: Move somewhere else
public static final Set<Item> hideHeadLayers = Sets.newHashSet(Items.ZOMBIE_HEAD, Items.CREEPER_HEAD,
Items.DRAGON_HEAD, Items.SKELETON_SKULL, Items.WITHER_SKELETON_SKULL);

protected SkinLayersModBase() {
instance = this;
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/dev/tr7zw/skinlayers/SkinUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import dev.tr7zw.skinlayers.api.SkinLayersAPI;
import dev.tr7zw.util.NMSHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.texture.AbstractTexture;
import net.minecraft.client.renderer.texture.DynamicTexture;
Expand Down Expand Up @@ -66,7 +65,7 @@ private static NativeImage getTexture(ResourceLocation resourceLocation, SkullSe
NativeImage cachedImage = cache.getIfPresent(texture);
if (cachedImage != null) {
try {
cachedImage.getPixelRGBA(0, 0); // check that it's allocated
checkAllocation(cachedImage);
return cachedImage;
} catch (Exception ex) {
// got invalidated, remove from cache
Expand All @@ -90,10 +89,7 @@ private static NativeImage getTexture(ResourceLocation resourceLocation, SkullSe
try {
NativeImage img = ((DynamicTexture) texture).getPixels();
if (img != null) {
img.getPixelRGBA(0, 0); // check that it's allocated
// Do not cache dynamic textures. It's a O(1) call to get them, and the cache
// would close them after 60 seconds
// cache.put(texture, img);
checkAllocation(img);
return img;
}
} catch (Exception ex) {
Expand All @@ -119,8 +115,18 @@ private static NativeImage getTexture(ResourceLocation resourceLocation, SkullSe
}
}

private static void checkAllocation(NativeImage image) throws Exception {
// spotless:off
//#if MC >= 12102
image.getPixelsABGR(); // check that it's allocated
//#else
//$$ image.getPixelRGBA(0, 0); // check that it's allocated
//#endif
//spotless:on
}

public static boolean setup3dLayers(AbstractClientPlayer abstractClientPlayerEntity, PlayerSettings settings,
boolean thinArms, PlayerModel<AbstractClientPlayer> model) {
boolean thinArms) {
ResourceLocation skinLocation = NMSHelper.getPlayerSkin(abstractClientPlayerEntity);
if (skinLocation == null) {
return false;// this *should* never happen, but just to be sure
Expand Down
38 changes: 28 additions & 10 deletions src/main/java/dev/tr7zw/skinlayers/mixin/CustomHeadLayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,47 @@
import net.minecraft.client.model.HeadedModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.AbstractSkullBlock;

@Mixin(CustomHeadLayer.class)
public class CustomHeadLayerMixin<T extends LivingEntity, M extends EntityModel<T> & HeadedModel> {
public class CustomHeadLayerMixin<T extends LivingEntity, M extends EntityModel & HeadedModel> {

// spotless:off
//#if MC >= 12102
@SuppressWarnings("resource")
@Inject(method = "render", at = @At("HEAD"))
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T livingEntity, float f,
float g, float h, float j, float k, float l, CallbackInfo info) {
if (!SkinLayersModBase.config.enableSkulls)
return;
if (Minecraft.getInstance().player != null && livingEntity.distanceToSqr(Minecraft.getInstance().gameRenderer
.getMainCamera().getPosition()) > SkinLayersModBase.config.renderDistanceLOD
public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i,
net.minecraft.client.renderer.entity.state.LivingEntityRenderState livingEntityRenderState, float f,
float g, CallbackInfo info) {

if (Minecraft.getInstance().player != null && Minecraft.getInstance().gameRenderer
.getMainCamera().getPosition().distanceToSqr(livingEntityRenderState.x, livingEntityRenderState.y, livingEntityRenderState.z) > SkinLayersModBase.config.renderDistanceLOD
* SkinLayersModBase.config.renderDistanceLOD) {
return; // too far away
}
ItemStack itemStack = livingEntity.getItemBySlot(EquipmentSlot.HEAD);
if (itemStack.isEmpty())
setupHeadRendering(livingEntityRenderState.headItem);
}
//#else
//$$ @SuppressWarnings("resource")
//$$ @Inject(method = "render", at = @At("HEAD"))
//$$ public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int i, T livingEntity, float f,
//$$ float g, float h, float j, float k, float l, CallbackInfo info) {
//$$ if (Minecraft.getInstance().player != null && livingEntity.distanceToSqr(Minecraft.getInstance().gameRenderer
//$$ .getMainCamera().getPosition()) > SkinLayersModBase.config.renderDistanceLOD
//$$ * SkinLayersModBase.config.renderDistanceLOD) {
//$$ return; // too far away
//$$ }
//$$ setupHeadRendering(livingEntity.getItemBySlot(net.minecraft.world.entity.EquipmentSlot.HEAD));
//$$ }
//#endif
//spotless:on

private void setupHeadRendering(ItemStack itemStack) {
if (!SkinLayersModBase.config.enableSkulls || itemStack.isEmpty())
return;
Item item = itemStack.getItem();
if (item instanceof BlockItem && ((BlockItem) item).getBlock() instanceof AbstractSkullBlock) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/tr7zw/skinlayers/mixin/ModelPartMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ModelPartMixin implements ModelPartInjector {

@Shadow
boolean visible;

private Mesh injectedMesh = null;
private OffsetProvider offsetProvider = null;

Expand Down Expand Up @@ -59,10 +59,10 @@ public void setInjectedMesh(Mesh mesh, OffsetProvider offsetProvider) {
injectedMesh = mesh;
this.offsetProvider = offsetProvider;
}

@Shadow
public void translateAndRotate(PoseStack poseStack) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import net.minecraft.world.entity.LivingEntity;

@Mixin(PlayerModel.class)
public class PlayerModelMixin<T extends LivingEntity> extends HumanoidModel<T> implements PlayerEntityModelAccessor {
public class PlayerModelMixin<T extends LivingEntity> extends HumanoidModel implements PlayerEntityModelAccessor {

// spotless:off
//#if MC >= 11700
Expand All @@ -22,7 +22,7 @@ public PlayerModelMixin(ModelPart modelPart) {
//$$ super(f);
//$$ }
//#endif
//spotless:on
//spotless:on

@Shadow
private boolean slim;
Expand Down
Loading

0 comments on commit af6ea24

Please sign in to comment.