use of net.minecraft.client.renderer.block.model.IBakedModel in project BuildCraft by BuildCraft.
the class ComplexRefiningManager method registerModels.
@SideOnly(Side.CLIENT)
public static void registerModels(ModelBakeEvent event) {
for (FluidDefinition def : allFluids) {
IModel model = new ModelFluid(def.fluid);
IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
ModelResourceLocation loc = ModelHelper.getBlockResourceLocation(def.block);
event.getModelRegistry().putObject(loc, baked);
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel 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.IBakedModel in project BuildCraft by BuildCraft.
the class BuildCraftBakedModel method createQuadsItemLayer.
public static List<MutableQuad> createQuadsItemLayer(final List<TextureAtlasSprite> sprites) {
ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
for (int i = 0; i < sprites.size(); i++) {
builder.add(new ResourceLocation("buildcraftbakedmodel:spriteindex" + i));
}
final ImmutableList<ResourceLocation> locations = builder.build();
ItemLayerModel model = new ItemLayerModel(locations);
IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, new Function<ResourceLocation, TextureAtlasSprite>() {
@Override
public TextureAtlasSprite apply(ResourceLocation input) {
return sprites.get(locations.indexOf(input));
}
});
Matrix4f itemToEdge = new Matrix4f();
itemToEdge.setIdentity();
itemToEdge.setRotation(new AxisAngle4f(0, 1, 0, (float) (Math.PI / 2)));
Matrix4f translation = new Matrix4f();
translation.setIdentity();
translation.setTranslation(new Vector3f(-15 / 32f, 0, 1));
translation.mul(itemToEdge);
List<MutableQuad> mutableQuads = ModelUtil.toMutableQuadList(baked, false);
for (MutableQuad mutable : mutableQuads) {
mutable.transform(translation);
mutable.setTint(-1);
}
return mutableQuads;
}
use of net.minecraft.client.renderer.block.model.IBakedModel 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.IBakedModel 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