2020-09-09 16:49:01 +02:00
|
|
|
package de.ellpeck.actuallyadditions.common.blocks.render;
|
2018-06-24 02:44:47 +02:00
|
|
|
|
2020-09-09 16:49:01 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.blocks.BlockCompost;
|
2020-09-07 20:33:27 +02:00
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.client.renderer.model.BakedQuad;
|
|
|
|
import net.minecraft.client.renderer.model.IBakedModel;
|
|
|
|
import net.minecraft.client.renderer.model.ItemOverrideList;
|
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
|
|
|
import net.minecraft.util.Direction;
|
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
2018-06-24 02:44:47 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2020-09-07 20:33:27 +02:00
|
|
|
import java.util.Random;
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
public class ActualCompostModel implements IBakedModel {
|
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
public static final Map<Pair<BlockState, Float>, IBakedModel> MODELS = new HashMap<>();
|
2018-06-24 02:44:47 +02:00
|
|
|
|
|
|
|
@Override
|
2020-09-07 20:33:27 +02:00
|
|
|
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
|
|
|
|
// if (state instanceof BlockState) {
|
|
|
|
if (state != null) {
|
|
|
|
Pair<BlockState, Float> data = state.get(BlockCompost.COMPOST_PROP);
|
2018-06-24 02:44:47 +02:00
|
|
|
if (data == null || data.getRight() <= 0) return CompostModel.compostBase.getQuads(state, side, rand);
|
|
|
|
IBakedModel model = MODELS.get(data);
|
|
|
|
if (model == null) {
|
|
|
|
model = new CompostModel(data.getLeft(), data.getRight());
|
|
|
|
MODELS.put(data, model);
|
|
|
|
}
|
|
|
|
return model.getQuads(state, side, rand);
|
|
|
|
}
|
2020-09-07 20:33:27 +02:00
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
return CompostModel.compostBase.getQuads(state, side, rand);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isAmbientOcclusion() {
|
|
|
|
return CompostModel.compostBase.isAmbientOcclusion();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isGui3d() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-07 20:33:27 +02:00
|
|
|
// No clue what this one is.
|
|
|
|
@Override
|
|
|
|
public boolean func_230044_c_() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-06-24 02:44:47 +02:00
|
|
|
@Override
|
|
|
|
public boolean isBuiltInRenderer() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TextureAtlasSprite getParticleTexture() {
|
|
|
|
return CompostModel.compostBase.getParticleTexture();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemOverrideList getOverrides() {
|
2020-09-07 20:33:27 +02:00
|
|
|
return ItemOverrideList.EMPTY;
|
2018-06-24 02:44:47 +02:00
|
|
|
}
|
|
|
|
}
|