use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.
the class ItemRenderUtil method renderItemStack.
/**
* Used to render a lot of items in sequential order. Assumes that you don't change the glstate inbetween calls.
* You must call {@link #endItemBatch()} after your have rendered all of the items.
*/
public static void renderItemStack(double x, double y, double z, ItemStack stack, int lightc, EnumFacing dir, BufferBuilder bb) {
if (stack.isEmpty()) {
return;
}
if (dir == null) {
dir = EnumFacing.EAST;
}
dir = BCLibConfig.rotateTravelingItems.changeFacing(dir);
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(stack);
model = model.getOverrides().handleItemState(model, stack, null, null);
boolean requireGl = stack.hasEffect() || model.isBuiltInRenderer();
if (bb != null && !requireGl) {
bb.setTranslation(x, y, z);
float scale = 0.30f;
MutableQuad q = new MutableQuad(-1, null);
for (EnumPipePart part : EnumPipePart.VALUES) {
for (BakedQuad quad : model.getQuads(null, part.face, 0)) {
q.fromBakedItem(quad);
q.translated(-0.5, -0.5, -0.5);
q.scaled(scale);
q.rotate(EnumFacing.SOUTH, dir, 0, 0, 0);
if (quad.hasTintIndex()) {
int colour = Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, quad.getTintIndex());
if (EntityRenderer.anaglyphEnable) {
colour = TextureUtil.anaglyphColor(colour);
}
q.multColouri(colour, colour >> 8, colour >> 16, 0xFF);
}
q.lighti(lightc);
Vector3f normal = q.getCalculatedNormal();
q.normalvf(normal);
q.multShade();
q.render(bb);
}
}
bb.setTranslation(0, 0, 0);
return;
}
if (!inBatch) {
inBatch = true;
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
GL11.glScaled(0.3, 0.3, 0.3);
RenderHelper.disableStandardItemLighting();
}
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightc % (float) 0x1_00_00, lightc / (float) 0x1_00_00);
Minecraft.getMinecraft().getRenderItem().renderItem(stack, model);
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.
the class RobotStationModel method createItemModel.
public PerspAwareModelBase createItemModel() {
ImmutableList.Builder<BakedQuad> quads = ImmutableList.builder();
VertexFormat format = DefaultVertexFormats.ITEM;
quads.addAll(INSTANCE.bakeCutout(EnumRobotStationState.Available, EnumFacing.SOUTH, format));
return new PerspAwareModelBase(format, quads.build(), baseSprite, getPluggableTransforms());
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project BuildCraft by BuildCraft.
the class RobotStationModel method bakeCutout.
private List<BakedQuad> bakeCutout(EnumRobotStationState state, EnumFacing face, VertexFormat format) {
IModel base = modelBase();
List<MutableQuad> stateQuads = this.stateQuads.get(state);
List<BakedQuad> quads = Lists.newArrayList();
if (base != null) {
Matrix4f matrix = MatrixUtil.rotateTowardsFace(face);
for (MutableQuad mutable : baseQuads()) {
mutable = new MutableQuad(mutable);
mutable.transform(matrix);
Vector3f normal = mutable.getCalculatedNormal();
mutable.normalv(normal);
float diffuse = MutableQuad.diffuseLight(normal);
mutable.colourf(diffuse, diffuse, diffuse, 1);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
if (stateQuads != null) {
for (MutableQuad mutable : stateQuads) {
mutable = new MutableQuad(mutable);
mutable.transform(matrix);
Vector3f normal = mutable.getCalculatedNormal();
mutable.normalv(normal);
float diffuse = MutableQuad.diffuseLight(normal);
mutable.colourf(diffuse, diffuse, diffuse, 1);
ModelUtil.appendBakeQuads(quads, format, mutable);
}
}
}
return quads;
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project Adventurers-Toolbox by the-realest-stu.
the class AxeModel 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 (headTexture != null && haftTexture != null && handleTexture != null) {
ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
if (haftTexture != null) {
texBuilder.add(haftTexture);
}
if (headTexture != null) {
texBuilder.add(headTexture);
}
if (handleTexture != null) {
texBuilder.add(handleTexture);
}
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 BakedAxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
use of net.minecraft.client.renderer.block.model.BakedQuad in project Adventurers-Toolbox by the-realest-stu.
the class HandpickModel 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 (headTexture != null && haftTexture != null && handleTexture != null) {
ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
if (haftTexture != null) {
texBuilder.add(haftTexture);
}
if (headTexture != null) {
texBuilder.add(headTexture);
}
if (handleTexture != null) {
texBuilder.add(handleTexture);
}
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 BakedHandpickModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap), Maps.<String, IBakedModel>newHashMap());
}
Aggregations