use of crazypants.enderio.base.render.util.QuadCollector in project EnderIO by SleepyTrousers.
the class BlockStateWrapperBase method bakeModel.
@Override
public void bakeModel() {
long start = Profiler.instance.start();
QuadCollector quads = null;
QuadCollector overlayQuads = null;
@Nonnull QuadCollector paintQuads = new QuadCollector();
boolean hasPaintRendered = false;
String cacheResult;
if (block instanceof IBlockPaintableBlock && (!(block instanceof IWrenchHideablePaint) || !getYetaDisplayMode().isHideFacades())) {
hasPaintRendered = PaintWrangler.wrangleBakedModel(world, pos, ((IBlockPaintableBlock) block).getPaintSource(state, world, pos), paintQuads);
}
boolean fromCache = doCaching && MinecraftForgeClient.getRenderLayer() != null;
if (!hasPaintRendered || renderMapper instanceof IRenderMapper.IBlockRenderMapper.IRenderLayerAware.IPaintAware) {
if (fromCache) {
quads = getFromCache();
cacheResult = quads == null ? "miss" : "hit";
} else {
cacheResult = "not cachable";
}
if (quads == null) {
quads = new QuadCollector();
bakeBlockLayer(quads);
if (fromCache) {
putIntoCache(quads);
}
}
} else {
cacheResult = "paint only";
}
overlayQuads = OverlayHolder.getOverlay(renderMapper.mapOverlayLayer(this, world, pos, hasPaintRendered));
model = new CollectedQuadBakedBlockModel(paintQuads.combine(overlayQuads).combine(quads));
Profiler.instance.stop(start, state.getBlock().getLocalizedName() + " (bake, cache=" + cacheResult + ")");
}
use of crazypants.enderio.base.render.util.QuadCollector in project EnderIO by SleepyTrousers.
the class BlockStateWrapperRelay method bakeModel.
@Override
public void bakeModel() {
long start = Profiler.instance.start();
@Nonnull QuadCollector paintQuads = new QuadCollector();
boolean hasPaintRendered = false;
String cacheResult;
if (block instanceof IBlockPaintableBlock && (!(block instanceof IWrenchHideablePaint) || !getYetaDisplayMode().isHideFacades())) {
hasPaintRendered = PaintWrangler.wrangleBakedModel(world, pos, ((IBlockPaintableBlock) block).getPaintSource(state, world, pos), paintQuads);
}
if (!hasPaintRendered) {
if (MinecraftForgeClient.getRenderLayer() == null || MinecraftForgeClient.getRenderLayer() == block.getBlockLayer()) {
model = null;
cacheResult = "relaying";
} else {
model = NULL;
cacheResult = "none";
}
} else {
model = new CollectedQuadBakedBlockModel(paintQuads);
cacheResult = "paint only";
}
Profiler.instance.stop(start, state.getBlock().getLocalizedName() + " (bake, cache=" + cacheResult + ")");
}
use of crazypants.enderio.base.render.util.QuadCollector in project EnderIO by SleepyTrousers.
the class OverlayHolder method collectOverlayQuads.
public static void collectOverlayQuads(@Nonnull ModelBakeEvent event) {
final Block block = ModObject.block_machine_io.getBlockNN();
Map<IBlockState, ModelResourceLocation> locations = event.getModelManager().getBlockModelShapes().getBlockStateMapper().getVariants(block);
NNIterator<IOMode> modes = crazypants.enderio.base.render.property.IOMode.MODES.iterator();
while (modes.hasNext()) {
IOMode mode = modes.next();
IBlockState state = block.getDefaultState().withProperty(IOMode.IO, mode);
ModelResourceLocation mrl = locations.get(state);
if (mrl == null) {
throw new RuntimeException("Model for state " + state + " failed to load from " + mrl + ". ");
}
IBakedModel model = event.getModelRegistry().getObject(mrl);
if (model == null) {
Log.warn("Model for state " + state + " failed to load from " + mrl + ".");
continue;
}
QuadCollector quads = new QuadCollector();
BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
BlockRenderLayer layer = block.getBlockLayer();
ForgeHooksClient.setRenderLayer(layer);
List<BakedQuad> generalQuads = model.getQuads(state, null, 0);
if (!generalQuads.isEmpty()) {
quads.addQuads(null, layer, generalQuads);
}
for (EnumFacing face1 : EnumFacing.values()) {
List<BakedQuad> faceQuads = model.getQuads(state, mode.getDirection(), 0);
if (!faceQuads.isEmpty()) {
quads.addQuads(face1, layer, faceQuads);
}
}
ForgeHooksClient.setRenderLayer(oldRenderLayer);
data[mode.getDirection().ordinal()][mode.getIomode().ordinal()] = quads;
}
}
Aggregations