use of gregtech.client.model.ModelFactory in project GregTech by GregTechCEu.
the class OreBakedModel method getQuads.
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (state != null) {
BlockOre ore = (BlockOre) state.getBlock();
StoneType stoneType = state.getValue(ore.STONE_TYPE);
MaterialIconSet materialIconSet = ore.material.getMaterialIconSet();
TextureAtlasSprite textureAtlasSprite = stoneTypeModels.computeIfAbsent(stoneType, type -> Minecraft.getMinecraft().blockRenderDispatcher.getModelForState(type.stone.get()).getParticleTexture());
particle.set(textureAtlasSprite);
if (model == null) {
model = new ModelFactory(ModelFactory.ModelTemplate.CUBE_2_LAYER_ALL_TINT_INDEX).bake();
}
BakedQuad bakedQuad = cacheBottom.get(stoneType, side);
if (side == null)
return Collections.emptyList();
if (bakedQuad == null) {
cacheBottom.put(stoneType, side, bakedQuad = new BakedQuadRetextured(model.getQuads(state, side, rand).get(0), textureAtlasSprite));
}
BakedQuad[] bakedQuads = cacheTop.get(materialIconSet, side);
if (bakedQuads == null) {
bakedQuads = new BakedQuad[2];
bakedQuads[0] = new BakedQuadRetextured(model.getQuads(state, side, rand).get(1), ModelLoader.defaultTextureGetter().apply(MaterialIconType.ore.getBlockPath(materialIconSet)));
bakedQuads[1] = CustomTexture.rebake(15, 15, bakedQuads[0]);
cacheTop.put(materialIconSet, side, bakedQuads);
}
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
boolean hasEmissive = ore.material.getProperty(PropertyKey.ORE).isEmissive();
boolean isEmissiveLayer = hasEmissive && (layer == BloomEffectUtil.getRealBloomLayer() || layer == null);
List<BakedQuad> quads = new ArrayList<>();
if (!hasEmissive || !isEmissiveLayer || layer == null) {
quads.add(bakedQuad);
}
if (hasEmissive && isEmissiveLayer) {
quads.add(bakedQuads[1]);
} else {
quads.add(bakedQuads[0]);
}
return quads;
} else {
List<BakedQuad> quads = new ArrayList<>();
ItemStack stack = OreItemOverride.INSTANCE.stack.get();
if (!stack.isEmpty()) {
BlockOre ore = (BlockOre) ((ItemBlock) stack.getItem()).getBlock();
IBlockState oreState = ore.getDefaultState().withProperty(ore.STONE_TYPE, ore.STONE_TYPE.getAllowedValues().get(stack.getMetadata()));
for (EnumFacing face : EnumFacing.VALUES) {
quads.addAll(getQuads(oreState, face, rand));
}
}
return quads;
}
}
Aggregations