Java 类net.minecraftforge.client.model.ItemLayerModel 实例源码

项目:Adventurers-Toolbox    文件:MaceModel.java   
@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 BakedMaceModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:DaggerModel.java   
@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 && handleTexture != null) {

        ImmutableList.Builder<ResourceLocation> texBuilder = ImmutableList.builder();
        if (bladeTexture != null) {
            texBuilder.add(bladeTexture);
        }
        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 BakedDaggerModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:HoeModel.java   
@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 BakedHoeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:PickaxeModel.java   
@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 BakedPickaxeModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:AxeModel.java   
@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());
}
项目:Adventurers-Toolbox    文件:HammerModel.java   
@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 BakedHammerModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:ShovelModel.java   
@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 BakedShovelModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:ToolHeadModel.java   
@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();
    ImmutableList<ResourceLocation> textures = ImmutableList.<ResourceLocation>of(new ResourceLocation(modid, "items/" + toolName + "/" + partName + "_" + matName));
    builder.addAll(new ItemLayerModel(textures).bake(state, format, bakedTextureGetter).getQuads(null, null, 0));
    return new BakedToolHeadModel(this, builder.build(), format, Maps.immutableEnumMap(transformMap),
            Maps.<String, IBakedModel>newHashMap());
}
项目:Adventurers-Toolbox    文件:SwordModel.java   
@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());
}
项目:Clef    文件:EventHandlerClient.java   
@SubscribeEvent
public void onModelBake(ModelBakeEvent event)
{
    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    builder.addAll(ItemLayerModel.getQuadsForSprite(0, txInstrument, DefaultVertexFormats.ITEM, Optional.empty()));
    event.getModelRegistry().putObject(new ModelResourceLocation("clef:instrument", "inventory"), new BakedModelInstrument(builder.build(), txInstrument, ImmutableMap.copyOf(new HashMap<>()), null, null));
}
项目:Clef    文件:Instrument.java   
@Override
public void loadTexture(IResourceManager resourceManager) throws IOException
{
    TextureUtil.uploadTextureImageAllocate(this.getGlTextureId(), image, false, false);

    ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
    tasi = new TextureAtlasSpriteBufferedImage(this.rl, this.image);
    tasi.load(Minecraft.getMinecraft().getResourceManager(), rl);
    builder.addAll(ItemLayerModel.getQuadsForSprite(0, tasi, DefaultVertexFormats.ITEM, Optional.empty()));
    quads = builder.build();
}
项目:CodeChickenLib    文件:ItemQuadBakery.java   
public static List<BakedQuad> bakeItem(VertexFormat format, IModelState state, TextureAtlasSprite... sprites) {

        LambdaUtils.checkArgument(sprites, "Sprites must not be Null or empty!", ArrayUtils::isNullOrContainsNull);

        List<BakedQuad> quads = new LinkedList<>();
        Optional<TRSRTransformation> transform = state.apply(Optional.empty());
        for (int i = 0; i < sprites.length; i++) {
            TextureAtlasSprite sprite = sprites[i];
            quads.addAll(ItemLayerModel.getQuadsForSprite(i, sprite, format, transform));
        }
        return quads;
    }
项目:Adventurers-Toolbox    文件:HandpickModel.java   
@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());
}
项目:Alchemy    文件:WardrobeModelLoader.java   
@Alpha
@Override
public IModel loadModel(ResourceLocation resourceLocation) throws Exception {
    try {
        ModelResourceLocation modelLocation;
        if (resourceLocation instanceof ModelResourceLocation)
            modelLocation = (ModelResourceLocation) resourceLocation;
        else
            return null;
        if (!modelLocation.getVariant().equals("inventory") && !modelLocation.getResourcePath().endsWith("_loc")) {
            List<Variant> list = Lists.newLinkedList();
            ModelRotation rotation = ModelRotation.X0_Y0;
            switch (Tool.get(modelLocation.getVariant(), "facing=([a-z]*)")) {
                case "east":
                    rotation = ModelRotation.X0_Y270;
                    break;
                case "north":
                    rotation = ModelRotation.X0_Y180;
                    break;
                case "west":
                    rotation = ModelRotation.X0_Y90;
                    break;
            }
            list.add(new Variant(new ModelResourceLocation(modelLocation.getResourceDomain() + ":" +
                    modelLocation.getResourcePath() + "_loc", modelLocation.getVariant()),
                    rotation, false, 1));
            VariantList variantList = new VariantList(list);
            return new ModelLoader.WeightedRandomModel(modelLocation, variantList);
        }
        modelLocation = new ModelResourceLocation(modelLocation.getResourceDomain() + 
                modelLocation.getResourcePath().replace("_loc", ""), modelLocation.getVariant());
        String name = modelLocation.getVariant().contains("part=head") ? "head" : "foot";
        String rely = Tool.isEmptyOr(Tool.get(modelLocation.getVariant(), "rely=([a-z]*)"), "null");
        try (IResource resource = Minecraft.getMinecraft().getResourceManager()
                    .getResource(new ResourceLocation("skin:models/wardrobe_" + rely + "_" + name + ".json"))) {
            String json = Joiner.on('\n').join(IOUtils.readLines(resource.getInputStream(), Charsets.UTF_8));
            try (Reader reader = new StringReader(WoodType.conversion.apply(json, Tool.get(
                    modelLocation.getResourcePath(), "_(.*?_T_.*?_T_[0-9]*_T_.*?_T_.*?_T_[0-9]*)")))) {
                ModelBlock modelBlock = ModelBlock.deserialize(reader);
                return modelLocation.getVariant().equals("inventory") ? new ItemLayerModel(modelBlock) :
                    ModelLoader.VanillaLoader.INSTANCE.getLoader().new VanillaModelWrapper(modelLocation,
                            modelBlock, false, ModelBlockAnimation.defaultModelBlockAnimation);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
项目:InfinityLib    文件:ItemQuadGenerator.java   
public static List<BakedQuad> generateItemQuads(VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter, String base, List<ItemModelTexture> textures) {

        List<BakedQuad> quads = new ArrayList<>();

        TRSRTransformation transform = TRSRTransformation.identity();
        TextureAtlasSprite base_icon = bakedTextureGetter.apply(new ResourceLocation(base));

        quads.addAll(ItemLayerModel.getQuadsForSprite(0, base_icon, format, Optional.of(transform)));

        for (ItemModelTexture tex : textures) {
            TextureAtlasSprite icon = bakedTextureGetter.apply(tex.texture);
            quads.add(genQuad(format, transform, tex.x1, tex.y1, tex.x2, tex.y2, tex.u1, tex.v1, tex.u2, tex.v2, NORTH_Z_BASE, icon, EnumFacing.NORTH, 0xffffffff));
            quads.add(genQuad(format, transform, tex.x1, tex.y1, tex.x2, tex.y2, tex.u1, tex.v1, tex.u2, tex.v2, SOUTH_Z_BASE, icon, EnumFacing.SOUTH, 0xffffffff));
        }

        return quads;

    }
项目:multishot    文件:RenderEventHandler.java   
private IBakedModel bakeMarkerModel(ModelResourceLocation key)
{
    ResourceLocation texture = getMarkerTexture(key);
    IModel model = new ItemLayerModel(ImmutableList.<ResourceLocation>of(texture));
    return model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter());
}
项目:OpenBlocks    文件:StencilItemOverride.java   
private IBakedModel createItemModel(ResourceLocation texture) {
    return new ItemLayerModel(ImmutableList.of(texture), this).bake(state, format, bakedTextureGetter);
}