mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 23:47:09 +01:00
Fix potential nullpointer rendering breaking overlay
- Should backport for #52
This commit is contained in:
parent
ef5de609a2
commit
b4fe00a314
3 changed files with 9 additions and 5 deletions
|
@ -3,6 +3,8 @@ package com.jozufozu.flywheel.core.atlas;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.jozufozu.flywheel.mixin.atlas.SheetDataAccessor;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -24,15 +26,18 @@ public class AtlasInfo {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SheetData getAtlasData(TextureAtlasSprite texture) {
|
||||
return getAtlasData(texture.atlas());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static SheetData getAtlasData(TextureAtlas atlas) {
|
||||
return getAtlasData(atlas.location());
|
||||
}
|
||||
|
||||
public static SheetData getAtlasData(ResourceLocation loc) {
|
||||
@Nullable
|
||||
public static SheetData getAtlasData(@Nullable ResourceLocation loc) {
|
||||
return sheetData.get(loc);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,10 @@ public class CrumblingGroup<P extends CrumblingProgram> extends InstancedMateria
|
|||
}
|
||||
|
||||
private void updateAtlasSize() {
|
||||
ResourceLocation texture = RenderTextures.getShaderTexture(0);
|
||||
|
||||
if (texture != null) {
|
||||
SheetData atlasData = AtlasInfo.getAtlasData(texture);
|
||||
SheetData atlasData = AtlasInfo.getAtlasData(RenderTextures.getShaderTexture(0));
|
||||
|
||||
if (atlasData != null) {
|
||||
width = atlasData.width;
|
||||
height = atlasData.height;
|
||||
} else {
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraft.resources.ResourceLocation;
|
|||
@Mixin(RenderSystem.class)
|
||||
public class RenderTexturesMixin {
|
||||
|
||||
@Inject(method = "_setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureManager;getTexture(Lnet/minecraft/resources/ResourceLocation;)Lnet/minecraft/client/renderer/texture/AbstractTexture;"))
|
||||
@Inject(method = "_setShaderTexture(ILnet/minecraft/resources/ResourceLocation;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/AbstractTexture;getId()I"))
|
||||
private static void storeTextureLoc(int pShaderTexture, ResourceLocation pTextureId, CallbackInfo ci) {
|
||||
RenderTextures._setShaderTexture(pShaderTexture, pTextureId);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue