use of net.minecraft.client.renderer.block.model.BakedQuad in project Adventurers-Toolbox by the-realest-stu.
the class SwordModel method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, java.util.function.Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
ImmutableMap<TransformType, TRSRTransformation> transformMap = PerspectiveMapWrapper.getTransforms(state);
TRSRTransformation transform = (TRSRTransformation.identity());
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
if (bladeTexture != null && crossguardTexture != null && handleTexture != null) {
ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
if (bladeTexture != null) {
texBuilder.add(bladeTexture);
}
if (handleTexture != null) {
texBuilder.add(handleTexture);
}
if (crossguardTexture != null) {
texBuilder.add(crossguardTexture);
}
if (adornmentTexture != null) {
texBuilder.add(adornmentTexture);
}
ImmutableList<ResourceLocation> textures = texBuilder.build();
IBakedModel model = (new ItemLayerModel(textures)).bake(state, format, bakedTextureGetter);
builder.addAll(model.getQuads(null, null, 0));
}
return new BakedSwordModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project EnderIO by SleepyTrousers.
the class QuadCollector method addFriendlybakedModel.
/**
* Adds a baked model that is expected to behave to the quad lists for the given block layer. The block layer will be set when the model is asked for its
* quads.
*/
public void addFriendlybakedModel(BlockRenderLayer pass, IBakedModel model, @Nullable IBlockState state, long rand) {
if (model != null) {
BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
ForgeHooksClient.setRenderLayer(pass);
List<BakedQuad> generalQuads = model.getQuads(state, null, rand);
if (!generalQuads.isEmpty()) {
addQuads(null, pass, generalQuads);
}
for (EnumFacing face : EnumFacing.values()) {
List<BakedQuad> faceQuads = model.getQuads(state, face, rand);
if (!faceQuads.isEmpty()) {
addQuads(face, pass, faceQuads);
}
}
ForgeHooksClient.setRenderLayer(oldRenderLayer);
}
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project EnderIO by SleepyTrousers.
the class QuadCollector method addFriendlyBlockStates.
/**
* Adds the baked model(s) of the given block states to the quad lists for the given block layer. The models are expected to behave. The block layer will be
* NOT set when the models are asked for their quads.
*/
public void addFriendlyBlockStates(BlockRenderLayer pass, List<IBlockState> states) {
if (states == null || states.isEmpty()) {
return;
}
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
for (IBlockState state : states) {
if (state != null) {
IBakedModel model = modelShapes.getModelForState(state);
List<BakedQuad> generalQuads = model.getQuads(state, null, 0);
if (!generalQuads.isEmpty()) {
addQuads(null, pass, generalQuads);
}
for (EnumFacing face : EnumFacing.values()) {
List<BakedQuad> faceQuads = model.getQuads(state, face, 0);
if (!faceQuads.isEmpty()) {
addQuads(face, pass, faceQuads);
}
}
}
}
}
use of net.minecraft.client.renderer.block.model.BakedQuad 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;
}
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project EnderIO by SleepyTrousers.
the class ObeliskBakery method bake.
public static List<BakedQuad> bake(TextureSupplier[] texs) {
// Icons for block
TextureAtlasSprite[] icons = new TextureAtlasSprite[6];
for (int i = 0; i < icons.length; i++) {
icons[i] = texs[i].get(TextureAtlasSprite.class);
}
HalfBakedList buffer1 = new HalfBakedList();
HalfBakedList buffer2 = new HalfBakedList();
HalfBakedList buffer3 = new HalfBakedList();
buffer1.add(bb1, EnumFacing.UP, 0f, 1f, 0f, 1f, icons[EnumFacing.UP.ordinal()], null);
for (EnumFacing face : EnumFacing.Plane.HORIZONTAL) {
buffer1.add(bb1, face, 0f, 1f, 0f, 1f, icons[face.ordinal()], null);
buffer2.add(bb2, face, 0f, 1f, 0f, 1f, icons[face.ordinal()], null);
}
buffer3.add(BoundingBox.UNIT_CUBE, EnumFacing.DOWN, 0f, 1f, 0f, 1f, icons[EnumFacing.DOWN.ordinal()], null);
List<BakedQuad> quads = new ArrayList<BakedQuad>();
buffer1.bake(quads, xform2z);
buffer2.bake(quads, xform2x);
buffer3.bake(quads, xform3);
return quads;
}
Aggregations