mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 04:42:17 +00:00
Various Mixin-related Fixes (#890)
* Update deps * Remove dead code * Add missing `@Override` annotations * Fix generics * Add `serialVersionUID`s * Address deprecation warnings * Use `@WrapWithCondition` v2 * Misc cleanup * Use AccessTransformers if possible * Fix mixin conflicts * Add `@Mutable` annotations * Fix injection targets * Update deps
This commit is contained in:
1 parent
611bbf02c8
commit
bb5526598e
158 files changed
+252
-619
No files matched your search
@@ -2,8 +2,6 @@ package net.coderbot.iris.texture.pbr;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.AutoClosableAbstractTexture;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureAtlasSpriteAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.texture.util.TextureExporter;
|
||||
@@ -36,7 +34,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
|
||||
public PBRAtlasTexture(TextureMap textureMap, PBRType type) {
|
||||
this.texMap = textureMap;
|
||||
this.type = type;
|
||||
id = type.appendToFileLocation(((TextureMapAccessor)textureMap).getLocationBlocksTexture());
|
||||
id = type.appendToFileLocation(TextureMap.locationBlocksTexture);
|
||||
|
||||
}
|
||||
|
||||
@@ -112,11 +110,10 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
|
||||
|
||||
protected void uploadSprite(TextureAtlasSprite sprite) {
|
||||
|
||||
final TextureAtlasSpriteAccessor accessor = (TextureAtlasSpriteAccessor) sprite;
|
||||
if (accessor.getMetadata().getFrameCount() > 1) {
|
||||
final AnimationMetadataSection metadata = accessor.getMetadata();
|
||||
if (sprite.animationMetadata.getFrameCount() > 1) {
|
||||
final AnimationMetadataSection metadata = sprite.animationMetadata;
|
||||
final int frameCount = sprite.getFrameCount();
|
||||
for (int frame = accessor.getFrame(); frame >= 0; frame--) {
|
||||
for (int frame = sprite.frameCounter; frame >= 0; frame--) {
|
||||
final int frameIndex = metadata.getFrameIndex(frame);
|
||||
if (frameIndex >= 0 && frameIndex < frameCount) {
|
||||
TextureUtil.uploadTextureMipmap(sprite.getFrameTextureData(frameIndex), sprite.getIconWidth(), sprite.getIconHeight(), sprite.getOriginX(), sprite.getOriginY(), false, false);
|
||||
|
||||
@@ -4,10 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfo;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.AnimationMetadataSectionAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureAtlasSpriteAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.texture.format.TextureFormat;
|
||||
import net.coderbot.iris.texture.format.TextureFormatLoader;
|
||||
@@ -32,7 +29,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
public static final ChannelMipmapGenerator LINEAR_MIPMAP_GENERATOR = new ChannelMipmapGenerator(
|
||||
LinearBlendFunction.INSTANCE,
|
||||
@@ -41,6 +37,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
LinearBlendFunction.INSTANCE
|
||||
);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void load(TextureMap texMap, IResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||
final TextureInfo textureInfo = TextureInfoCache.INSTANCE.getInfo(texMap.getGlTextureId());
|
||||
@@ -50,7 +47,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
|
||||
PBRAtlasTexture normalAtlas = null;
|
||||
PBRAtlasTexture specularAtlas = null;
|
||||
for (TextureAtlasSprite sprite : (Collection<TextureAtlasSprite>) ((TextureMapAccessor) texMap).getMapUploadedSprites().values()) {
|
||||
for (TextureAtlasSprite sprite : (Collection<TextureAtlasSprite>) texMap.mapUploadedSprites.values()) {
|
||||
if (!(sprite.getIconName().equals("missingno"))) {
|
||||
TextureAtlasSprite normalSprite = createPBRSprite(sprite, resourceManager, texMap, atlasWidth, atlasHeight, mipLevel, PBRType.NORMAL);
|
||||
TextureAtlasSprite specularSprite = createPBRSprite(sprite, resourceManager, texMap, atlasWidth, atlasHeight, mipLevel, PBRType.SPECULAR);
|
||||
@@ -77,19 +74,19 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
if (normalAtlas.tryUpload(atlasWidth,
|
||||
atlasHeight,
|
||||
mipLevel,
|
||||
((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
texMap.anisotropicFiltering)) {
|
||||
pbrTextureConsumer.acceptNormalTexture(normalAtlas);
|
||||
}
|
||||
}
|
||||
if (specularAtlas != null) {
|
||||
if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel, ((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel, texMap.anisotropicFiltering)) {
|
||||
pbrTextureConsumer.acceptSpecularTexture(specularAtlas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static int fetchAtlasMipLevel(TextureMap texMap) {
|
||||
return ((TextureMapAccessor) texMap).getMipmapLevels();
|
||||
return texMap.mipmapLevels;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -138,20 +135,19 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
frameHeight = targetFrameHeight;
|
||||
|
||||
if (!animationMetadata.equals(new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1))) {
|
||||
final AnimationMetadataSectionAccessor animationAccessor = (AnimationMetadataSectionAccessor) animationMetadata;
|
||||
final int internalFrameWidth = animationAccessor.getFrameHeight();
|
||||
final int internalFrameHeight = animationAccessor.getFrameHeight();
|
||||
final int internalFrameWidth = animationMetadata.frameHeight;
|
||||
final int internalFrameHeight = animationMetadata.frameWidth;
|
||||
if (internalFrameWidth != -1) {
|
||||
animationAccessor.setFrameWidth(frameWidth);
|
||||
animationMetadata.frameWidth = frameWidth;
|
||||
}
|
||||
if (internalFrameHeight != -1) {
|
||||
animationAccessor.setFrameHeight(frameHeight);
|
||||
animationMetadata.frameHeight = frameHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ResourceLocation pbrSpriteName = new ResourceLocation(spriteName.getResourceDomain(), spriteName.getResourcePath() + pbrType.getSuffix());
|
||||
final TextureAtlasSpriteInfo pbrSpriteInfo = new PBRTextureAtlasSpriteInfo(pbrSpriteName, frameWidth, frameHeight, animationMetadata, pbrType);
|
||||
final TextureAtlasSpriteInfo pbrSpriteInfo = new PBRTextureAtlasSpriteInfo(pbrSpriteName, frameWidth, frameHeight, pbrType);
|
||||
|
||||
final int x = sprite.getOriginX();
|
||||
final int y = sprite.getOriginY();
|
||||
@@ -174,16 +170,14 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
return;
|
||||
}
|
||||
|
||||
final TextureAtlasSpriteAccessor sourceAccessor = ((TextureAtlasSpriteAccessor) source);
|
||||
final AnimationMetadataSection sourceMetadata = sourceAccessor.getMetadata();
|
||||
final AnimationMetadataSection sourceMetadata = source.animationMetadata;
|
||||
|
||||
int ticks = 0;
|
||||
for (int f = 0; f < sourceAccessor.getFrame(); f++) {
|
||||
for (int f = 0; f < source.frameCounter; f++) {
|
||||
ticks += sourceMetadata.getFrameTimeSingle(f);
|
||||
}
|
||||
|
||||
final TextureAtlasSpriteAccessor targetAccessor = ((TextureAtlasSpriteAccessor) target);
|
||||
final AnimationMetadataSection targetMetadata = targetAccessor.getMetadata();
|
||||
final AnimationMetadataSection targetMetadata = target.animationMetadata;
|
||||
|
||||
int cycleTime = 0;
|
||||
final int frameCount = targetMetadata.getFrameCount();
|
||||
@@ -203,15 +197,15 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
}
|
||||
}
|
||||
|
||||
targetAccessor.setFrame(targetFrame);
|
||||
targetAccessor.setSubFrame(ticks + sourceAccessor.getSubFrame());
|
||||
target.frameCounter = targetFrame;
|
||||
target.tickCounter = ticks + source.tickCounter;
|
||||
}
|
||||
|
||||
protected static class PBRTextureAtlasSpriteInfo extends TextureAtlasSpriteInfo {
|
||||
protected final PBRType pbrType;
|
||||
|
||||
public PBRTextureAtlasSpriteInfo(ResourceLocation name, int width, int height, AnimationMetadataSection metadata, PBRType pbrType) {
|
||||
super(name, width, height, metadata);
|
||||
public PBRTextureAtlasSpriteInfo(ResourceLocation name, int width, int height, PBRType pbrType) {
|
||||
super(name, width, height);
|
||||
this.pbrType = pbrType;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +215,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
protected PBRTextureAtlasSprite(TextureAtlasSpriteInfo info, AnimationMetadataSection animationMetaDataSection, int atlasWidth, int atlasHeight, int x, int y, NativeImage nativeImage, TextureMap texMap, int miplevel) {
|
||||
super(info.name().toString());
|
||||
super.initSprite(atlasWidth, atlasHeight, x, y, false);
|
||||
super.loadSprite(getMipmapGenerator(info, atlasWidth, atlasHeight).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, (float)((TextureMapAccessor) texMap).getAnisotropicFiltering() > 1.0F);
|
||||
super.loadSprite(getMipmapGenerator(info, atlasWidth, atlasHeight).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, texMap.anisotropicFiltering > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.coderbot.iris.texture.pbr.loader;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.SimpleTextureAccessor;
|
||||
import net.coderbot.iris.texture.pbr.PBRType;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
@@ -13,7 +12,7 @@ import java.io.IOException;
|
||||
public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
|
||||
@Override
|
||||
public void load(SimpleTexture texture, IResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||
ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation();
|
||||
ResourceLocation location = texture.textureLocation;
|
||||
|
||||
AbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL);
|
||||
AbstractTexture specularTexture = createPBRTexture(location, resourceManager, PBRType.SPECULAR);
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package net.coderbot.iris.texture.pbr.loader;
|
||||
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TextureAtlasSpriteInfo {
|
||||
private final ResourceLocation name;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final AnimationMetadataSection metadata;
|
||||
|
||||
public TextureAtlasSpriteInfo(ResourceLocation arg, int i, int j, AnimationMetadataSection arg2) {
|
||||
public TextureAtlasSpriteInfo(ResourceLocation arg, int i, int j) {
|
||||
this.name = arg;
|
||||
this.width = i;
|
||||
this.height = j;
|
||||
this.metadata = arg2;
|
||||
}
|
||||
|
||||
public ResourceLocation name() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
|
||||
Reference in new issue
Block a user