use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class CompoundPartModelOverrideList method addWithBlendedColor.
@SuppressWarnings("TypeMayBeWeakened")
private void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
IMaterialDisplay materialModel = material.getDisplayProperties();
List<MaterialLayer> layers = materialModel.getLayerList(this.model.gearType, part, material).getLayers();
for (int i = 0; i < layers.size(); i++) {
MaterialLayer layer = layers.get(i);
if ((layer.getColor() & 0xFFFFFF) < 0xFFFFFF) {
int blendedColor = part.getColor(stack, i, 0);
list.add(new MaterialLayer(layer.getTextureId(), part.getType(), blendedColor, false));
} else {
list.add(layer);
}
}
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class FragmentModelOverrideList method getOverrideModel.
private BakedModel getOverrideModel(ItemStack stack, @Nullable ClientLevel worldIn, @Nullable LivingEntity entityIn) {
List<MaterialLayer> layers = new ArrayList<>();
IMaterialInstance material = FragmentItem.getMaterial(stack);
if (material != null) {
IMaterialDisplay model = material.getDisplayProperties();
int layerLevel = 0;
for (MaterialLayer layer : model.getLayerList(GearType.FRAGMENT, PartType.MAIN, material)) {
int blendedColor = model.getLayerColor(GearType.FRAGMENT, PartType.MAIN, material, layerLevel);
layers.add(new MaterialLayer(layer.getTextureId(), blendedColor));
++layerLevel;
}
}
return model.bake(layers, owner, bakery, spriteGetter, modelTransform, this, modelLocation);
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class GearModel method bake.
@SuppressWarnings("MethodWithTooManyParameters")
public BakedModel bake(ItemStack stack, List<MaterialLayer> layers, int animationFrame, String transformVariant, IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrideList, ResourceLocation modelLocation) {
ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder();
Transformation rotation = modelTransform.getRotation();
ImmutableMap<ItemTransforms.TransformType, Transformation> transforms = PerspectiveMapWrapper.getTransforms(modelTransform);
boolean broken = GearHelper.isBroken(stack);
for (int i = 0; i < layers.size(); i++) {
MaterialLayer layer = layers.get(i);
Material renderMaterial = getTexture(layer, animationFrame, broken);
TextureAtlasSprite texture = spriteGetter.apply(renderMaterial);
builder.addAll(getQuadsForSprite(i, texture, rotation, layer.getColor()));
if (GearModelOverrideList.isDebugLoggingEnabled()) {
SilentGear.LOGGER.info(" - {} -> {}", layer.getTextureId(), renderMaterial.texture());
}
}
// No layers?
if (layers.isEmpty()) {
if (Const.Materials.EXAMPLE.isPresent()) {
buildFakeModel(spriteGetter, builder, rotation, Const.Materials.EXAMPLE.get());
} else {
// Shouldn't happen, but...
SilentGear.LOGGER.error("Example material is missing?");
TextureAtlasSprite texture = spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
builder.addAll(getQuadsForSprite(0, texture, rotation, 0xFFFFFF));
}
}
TextureAtlasSprite particle = spriteGetter.apply(owner.resolveTexture("particle"));
return new BakedPerspectiveModel(builder.build(), particle, transforms, overrideList, rotation.isIdentity(), owner.isSideLit(), getCameraTransforms(transformVariant));
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class GearModel method buildFakeModel.
private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
// This method will display an example tool for items with no data (ie, for advancements)
MaterialInstance mat = MaterialInstance.of(material);
IMaterialDisplay model = mat.getDisplayProperties();
if (!gearType.isArmor()) {
MaterialLayer exampleRod = model.getLayerList(this.gearType, PartType.ROD, mat).getFirstLayer();
if (exampleRod != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleRod.getTexture(gearType, 0))), rotation, exampleRod.getColor()));
}
}
MaterialLayer exampleMain = model.getLayerList(this.gearType, PartType.MAIN, mat).getFirstLayer();
if (exampleMain != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(gearType, 0))), rotation, exampleMain.getColor()));
}
if (gearType.matches(GearType.RANGED_WEAPON)) {
MaterialLayer exampleBowstring = model.getLayerList(this.gearType, PartType.CORD, mat).getFirstLayer();
if (exampleBowstring != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleBowstring.getTexture(gearType, 0))), rotation, exampleBowstring.getColor()));
}
}
}
Aggregations