fix fallback textures

This commit is contained in:
Sen 2025-06-22 18:21:07 +02:00
parent eb5c03dda3
commit e85166666f
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
14 changed files with 53 additions and 36 deletions

View file

@ -8,10 +8,8 @@ import java.util.Set;
import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureMap;
import common.block.Block;
import common.block.liquid.BlockLiquid;
import common.collect.Maps;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.properties.Property;
import common.util.IRegistry;
import common.world.State;
@ -21,7 +19,6 @@ public class ModelManager
private IRegistry<String, IBakedModel> modelRegistry;
private final TextureMap texMap;
private final Map<State, IBakedModel> bakedModelStore = Maps.<State, IBakedModel>newIdentityHashMap();
private final Map<Block, String> liquidMap = Maps.<Block, String>newIdentityHashMap();
private final Map<Block, StateMap> mappers = Maps.<Block, StateMap>newIdentityHashMap();
private final Set<Block> builtin = Collections.newSetFromMap(Maps.<Block, Boolean>newIdentityHashMap());
private IBakedModel defaultModel;
@ -75,35 +72,21 @@ public class ModelManager
public TextureAtlasSprite getTexture(State state)
{
Block block = state.getBlock();
IBakedModel ibakedmodel = this.getModelForState(state);
IBakedModel model = this.getModelForState(state);
if (ibakedmodel == null || ibakedmodel == this.defaultModel)
if (model == null || model == this.defaultModel)
{
if (block == Blocks.wall_sign || block == Blocks.sign || block == Blocks.chest || block == Blocks.trapped_chest || block == Blocks.banner || block == Blocks.wall_banner)
{
return this.texMap.getAtlasSprite("blocks/oak_planks");
}
if (block == Blocks.floor_portal)
{
return this.texMap.getAtlasSprite("blocks/obsidian");
}
if (block.getMaterial().isLiquid())
{
String texture = this.liquidMap.get(block);
if(texture == null)
this.liquidMap.put(block, texture = "blocks/" + BlockRegistry.getNameFromFluid((BlockLiquid)block) + "_still");
return this.texMap.getAtlasSprite(texture);
}
String tex = block.getFallbackTexture();
if(tex != null)
return this.texMap.getAtlasSprite("blocks/" + tex);
}
if (ibakedmodel == null)
if (model == null)
{
ibakedmodel = this.defaultModel;
model = this.defaultModel;
}
return ibakedmodel.getBaseTexture();
return model.getBaseTexture();
}
public IBakedModel getModelForState(State state)

View file

@ -46,13 +46,13 @@ public class TextureMap extends Texture
}
for(Entry<String, Object> entry : map.entrySet()) {
if(entry.getValue() instanceof Integer) {
this.animTextures.put(entry.getKey(), (Integer)entry.getValue());
this.animTextures.put("blocks/" + entry.getKey(), (Integer)entry.getValue());
}
else {
Class<? extends TextureTicked> clazz = anim.get((TextureAnimation)entry.getValue());
if(clazz == null)
throw new RuntimeException("Animation '" + entry.getValue() + "' existiert nicht");
this.tickedTextures.put(entry.getKey(), clazz);
this.tickedTextures.put("blocks/" + entry.getKey(), clazz);
}
}
map.clear();