mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-14 01:04:24 +00:00
Made it so it will attempt to scale any Texture Effects that return data for smaller texture resolutions. Made the size descrepancy only a error for ITextureFX texture effects.
This commit is contained in:
1 parent
201edc0249
commit
1af7d7970a
2 files changed
+72
-18
No files matched your search
@@ -22,6 +22,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -1012,20 +1013,59 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return false;
|
||||
}
|
||||
Profiler.func_40662_b();
|
||||
|
||||
Dimension dim = getTextureDimensions(effect);
|
||||
int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
|
||||
if (effect.field_1127_a.length != target)
|
||||
|
||||
if (ifx != null)
|
||||
{
|
||||
log.warning(String.format("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_1127_a.length, target));
|
||||
if (ifx != null)
|
||||
Dimension dim = getTextureDimensions(effect);
|
||||
int target = ((dim.width >> 4) * (dim.height >> 4)) << 2;
|
||||
if (effect.field_1127_a.length != target)
|
||||
{
|
||||
log.warning(String.format("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_1127_a.length, target));
|
||||
ifx.setErrored(true);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Quick and dirty image scaling, no smoothing or fanciness, meant for speed as it will be called every tick.
|
||||
public void scaleTextureFXData(byte[] data, ByteBuffer buf, int target, int length)
|
||||
{
|
||||
int sWidth = (int)Math.sqrt(data.length / 4);
|
||||
int factor = target / sWidth;
|
||||
byte[] tmp = new byte[4];
|
||||
|
||||
buf.clear();
|
||||
|
||||
if (factor > 1)
|
||||
{
|
||||
for (int y = 0; y < sWidth; y++)
|
||||
{
|
||||
int sRowOff = sWidth * y;
|
||||
int tRowOff = target * y * factor;
|
||||
for (int x = 0; x < sWidth; x++)
|
||||
{
|
||||
int sPos = (x + sRowOff) * 4;
|
||||
tmp[0] = data[sPos + 0];
|
||||
tmp[1] = data[sPos + 1];
|
||||
tmp[2] = data[sPos + 2];
|
||||
tmp[3] = data[sPos + 3];
|
||||
|
||||
int tPosTop = (x * factor) + tRowOff;
|
||||
for (int y2 = 0; y2 < factor; y2++)
|
||||
{
|
||||
buf.position((tPosTop + (y2 * target)) * 4);
|
||||
for (int x2 = 0; x2 < factor; x2++)
|
||||
{
|
||||
buf.put(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buf.position(0).limit(length);
|
||||
}
|
||||
|
||||
public void onPreRegisterEffect(TextureFX effect)
|
||||
{
|
||||
|
||||
@@ -72,25 +72,39 @@
|
||||
this.field_1604_f.add(p_1066_1_);
|
||||
p_1066_1_.func_783_a();
|
||||
}
|
||||
@@ -460,7 +475,10 @@
|
||||
@@ -460,10 +475,26 @@
|
||||
{
|
||||
TextureFX var3 = (TextureFX)this.field_1604_f.get(var2);
|
||||
var3.field_1131_c = this.field_1602_h.field_1578_g;
|
||||
- var3.func_783_a();
|
||||
- this.field_1605_e.clear();
|
||||
- this.field_1605_e.put(var3.field_1127_a);
|
||||
- this.field_1605_e.position(0).limit(var3.field_1127_a.length);
|
||||
+ if (!FMLClientHandler.instance().onUpdateTextureEffect(var3))
|
||||
+ {
|
||||
+ continue;
|
||||
+ }
|
||||
this.field_1605_e.clear();
|
||||
this.field_1605_e.put(var3.field_1127_a);
|
||||
this.field_1605_e.position(0).limit(var3.field_1127_a.length);
|
||||
@@ -471,11 +489,16 @@
|
||||
var1 = var3.field_1126_b;
|
||||
}
|
||||
|
||||
+
|
||||
+ Dimension dim = FMLClientHandler.instance().getTextureDimensions(var3);
|
||||
+ int tWidth = dim.width / 16;
|
||||
+ int tHeight = dim.height / 16;
|
||||
+ int tHeight = dim.height / 16;
|
||||
+ int tLen = tWidth * tHeight * 4;
|
||||
+
|
||||
+ if (var3.field_1127_a.length == tLen)
|
||||
+ {
|
||||
+ this.field_1605_e.clear();
|
||||
+ this.field_1605_e.put(var3.field_1127_a);
|
||||
+ this.field_1605_e.position(0).limit(var3.field_1127_a.length);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ FMLClientHandler.instance().scaleTextureFXData(var3.field_1127_a, field_1605_e, tWidth, tLen);
|
||||
+ }
|
||||
|
||||
if (var3.field_1126_b != var1)
|
||||
{
|
||||
@@ -473,9 +504,11 @@
|
||||
|
||||
for (int var4 = 0; var4 < var3.field_1129_e; ++var4)
|
||||
{
|
||||
+ int xOffset = var3.field_1126_b % 16 * tWidth + var4 * tWidth;
|
||||
@@ -102,7 +116,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -577,8 +600,9 @@
|
||||
@@ -577,8 +610,9 @@
|
||||
this.field_4280_j = false;
|
||||
this.field_4281_i = false;
|
||||
}
|
||||
@@ -113,7 +127,7 @@
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -614,11 +638,13 @@
|
||||
@@ -614,11 +648,13 @@
|
||||
this.field_4280_j = false;
|
||||
this.field_4281_i = false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user