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();

View file

@ -1011,4 +1011,8 @@ public class Block {
public final int getEncouragement() {
return this.encouragement;
}
public String getFallbackTexture() {
return null;
}
}

View file

@ -152,6 +152,10 @@ public class BlockFloorPortal extends Block
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/floor_portal", 5);
map.put("floor_portal", 5);
}
public String getFallbackTexture() {
return "obsidian";
}
}

View file

@ -293,7 +293,7 @@ public class BlockPortal extends Block
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/portal", 1);
map.put("portal", 1);
}
// public BlockPattern.PatternHelper func_181089_f(World p_181089_1_, BlockPos p_181089_2_)

View file

@ -315,6 +315,12 @@ public class BlockDynamicLiquid extends BlockLiquid
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/" + BlockRegistry.getNameFromBlock(this.staticBlock) + "_flow", this.animation);
map.put(BlockRegistry.getNameFromBlock(this.staticBlock) + "_flow", this.animation);
}
public String getFallbackTexture() {
if(this.cachedTexture == null)
this.cachedTexture = BlockRegistry.getNameFromBlock(this.staticBlock) + "_still";
return this.cachedTexture;
}
}

View file

@ -37,6 +37,8 @@ public abstract class BlockLiquid extends Block
protected final boolean opaque;
protected final int flowRate;
protected final Object animation;
protected String cachedTexture;
public BlockLiquid(Material materialIn, boolean tick, boolean opaque, int rate, Object animation)
{

View file

@ -114,6 +114,12 @@ public class BlockStaticLiquid extends BlockLiquid
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/" + BlockRegistry.getNameFromBlock(this) + "_still", this.animation);
map.put(BlockRegistry.getNameFromBlock(this) + "_still", this.animation);
}
public String getFallbackTexture() {
if(this.cachedTexture == null)
this.cachedTexture = BlockRegistry.getNameFromBlock(this) + "_still";
return this.cachedTexture;
}
}

View file

@ -1144,8 +1144,8 @@ public class BlockFire extends Block
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/fire_layer_0", TextureAnimation.FIRE1);
map.put("blocks/fire_layer_1", TextureAnimation.FIRE2);
map.put("fire_layer_0", TextureAnimation.FIRE1);
map.put("fire_layer_1", TextureAnimation.FIRE2);
}
public boolean canExtinguish() {

View file

@ -30,7 +30,7 @@ public class BlockTintedFire extends BlockFire {
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/flame_layer_0", TextureAnimation.FLAME1);
map.put("blocks/flame_layer_1", TextureAnimation.FLAME2);
map.put("flame_layer_0", TextureAnimation.FLAME1);
map.put("flame_layer_1", TextureAnimation.FLAME2);
}
}

View file

@ -634,4 +634,8 @@ public class BlockChest extends BlockContainer implements Rotatable
{
return true;
}
public String getFallbackTexture() {
return "oak_planks";
}
}

View file

@ -21,6 +21,6 @@ public class BlockTianReactor extends BlockMachine {
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/tian_reactor_front", 5);
map.put("tian_reactor_front", 5);
}
}

View file

@ -144,4 +144,8 @@ public class BlockBanner extends BlockContainer implements Rotatable
public Transforms getTransform() {
return Transforms.BANNER;
}
public String getFallbackTexture() {
return "oak_planks";
}
}

View file

@ -131,4 +131,8 @@ public class BlockSign extends BlockContainer
{
return true;
}
public String getFallbackTexture() {
return "oak_planks";
}
}