Texture streaming Android compat fix

This commit is contained in:
Anuken
2026-09-06 17:03:39 -04:00
parent 58ed13fc96
commit 5a0c4bfc41
3 changed files with 10 additions and 4 deletions
+8 -3
View File
@@ -168,11 +168,16 @@ public class NetClient implements ApplicationListener{
net.handleClient(TextureStream.class, data -> {
try(DataInputStream in = new DataInputStream(data.stream)){
String name = in.readUTF();
byte[] pngData = in.readAllBytes();
int length = in.readInt();
byte[] pngData = new byte[length];
in.readFully(pngData);
if(!headless){
//empty image data means we're removing the texture instead. see NetServer.removeTexture()
if(pngData.length == 0) state.data.removeTexture(name);
else state.data.addTexture(name, pngData);
if(pngData.length == 0){
state.data.removeTexture(name);
}else{
state.data.addTexture(name, pngData);
}
}
}catch(IOException e){
Log.err("Failed to read server texture stream", e);
@@ -87,7 +87,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
}else if(mining() && item != null){
mineTimer += Time.delta * type.mineSpeed * state.rules.unitMineSpeed(team());
if(Mathf.chance(0.07 * Time.delta)){
if(Mathf.chance(0.08 * Time.delta)){
Fx.unitMine.at(mineTile.worldx() + Mathf.range(tilesize / 2f), mineTile.worldy() + Mathf.range(tilesize / 2f), 0f, item.color);
}
+1
View File
@@ -178,6 +178,7 @@ public class NetworkIO{
public static void packTexture(OutputStream os, String name, byte[] pngData){
try(DataOutputStream stream = new DataOutputStream(os)){
stream.writeUTF(name);
stream.writeInt(pngData.length);
stream.write(pngData);
}catch(IOException e){
throw new RuntimeException(e);