net.minecraft.client.texture.Sprite Java Examples

The following examples show how to use net.minecraft.client.texture.Sprite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 7 votes vote down vote up
public BakedModel bakeModel(JsonUnbakedModel model, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings settings, Identifier id, boolean hasDepth) {
    Sprite sprite = textureGetter.apply(model.resolveSprite("particle"));
    if (model.getRootModel() == ModelLoader.BLOCK_ENTITY_MARKER) {
        return new BuiltinBakedModel(model.getTransformations(), ModelOverrideList.EMPTY, sprite, model.getGuiLight().isSide());
    } else {
        BasicBakedModel.Builder builder = (new BasicBakedModel.Builder(model, ModelOverrideList.EMPTY, hasDepth)).setParticle(sprite);

        for (ModelElement modelElement : model.getElements()) {
            for (Direction direction : modelElement.faces.keySet()) {
                ModelElementFace modelElementFace = modelElement.faces.get(direction);
                Sprite sprite2 = textureGetter.apply(model.resolveSprite(modelElementFace.textureId));
                if (modelElementFace.cullFace == null) {
                    builder.addQuad(createQuad(modelElement, modelElementFace, sprite2, direction, settings, id));
                } else {
                    builder.addQuad(Direction.transform(settings.getRotation().getMatrix(), modelElementFace.cullFace), createQuad(modelElement, modelElementFace, sprite2, direction, settings, id));
                }
            }
        }

        return builder.build();
    }
}
 
Example #2
Source File: MixinFluidRenderer.java    From Sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Inject(at = @At("RETURN"), method = "onResourceReload")
public void reload(CallbackInfo info) {
    SpriteAtlasTexture spriteAtlasTexture_1 = (SpriteAtlasTexture) MinecraftClient.getInstance().getTextureManager().getTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
    spriteMap.clear();
    Registry.FLUID.forEach(fluid -> {
        if (fluid instanceof FluidWrapper) {
            Sprite[] sprites = new Sprite[2];
            sprites[0] = spriteAtlasTexture_1.getSprite(WrappingUtil.convert(((FluidWrapper) fluid).fluid.getTexturePath(false)));
            sprites[1] = spriteAtlasTexture_1.getSprite(WrappingUtil.convert(((FluidWrapper) fluid).fluid.getTexturePath(true)));
            spriteMap.put(((FluidWrapper) fluid).fluid, sprites);
        }
    });
}
 
Example #3
Source File: ConfigurableElectricMachineBlockEntityRenderer.java    From Galacticraft-Rewoven with MIT License 4 votes vote down vote up
private static BakedQuad createQuad(ModelElement element, ModelElementFace elementFace, Sprite sprite, Direction side, ModelBakeSettings settings, Identifier id) {
    return QUAD_FACTORY.bake(element.from, element.to, elementFace, sprite, side, settings, element.rotation, element.shade, id);
}