use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.
the class FragmentModel method getTextures.
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
Set<Material> ret = new HashSet<>();
ret.add(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
// Generic built-in textures
ret.add(getTexture(PartTextures.CLOTH.getTexture()));
ret.add(getTexture(PartTextures.METAL.getTexture()));
ret.add(getTexture(PartTextures.WOOD.getTexture()));
// Custom textures
for (IMaterialDisplay materialDisplay : GearDisplayManager.getMaterials()) {
for (MaterialLayer layer : materialDisplay.getLayerList(GearType.FRAGMENT, PartType.MAIN, LazyMaterialInstance.of(materialDisplay.getMaterialId()))) {
ret.add(getTexture(layer));
}
}
SilentGear.LOGGER.info("Textures for fragment model");
for (Material mat : ret) {
SilentGear.LOGGER.info("- {}", mat.texture());
}
return ret;
}
use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.
the class GearModel method getTextures.
@SuppressWarnings("OverlyComplexMethod")
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, UnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
Set<Material> ret = new HashSet<>();
ret.add(new Material(InventoryMenu.BLOCK_ATLAS, SilentGear.getId("item/error")));
// Generic built-in textures
for (PartTextures tex : PartTextures.getTextures(this.gearType)) {
int animationFrames = tex.isAnimated() ? item.getAnimationFrames() : 1;
for (int i = 0; i < animationFrames; ++i) {
MaterialLayer layer = new MaterialLayer(tex, Color.VALUE_WHITE);
ret.add(getTexture(layer, i, false));
ret.add(getTexture(layer, 0, true));
}
}
// Custom textures
for (IMaterialDisplay materialDisplay : GearDisplayManager.getMaterials()) {
for (PartType partType : PartType.getValues()) {
if (item.hasTexturesFor(partType)) {
for (MaterialLayer layer : materialDisplay.getLayerList(gearType, partType, LazyMaterialInstance.of(materialDisplay.getMaterialId()))) {
int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
ret.addAll(this.getTexturesForAllFrames(layer, 1, true));
}
}
}
}
for (IPartDisplay partDisplay : GearDisplayManager.getParts()) {
for (MaterialLayer layer : partDisplay.getLayers(gearType, FakePartData.of(PartType.NONE))) {
int animationFrames = layer.isAnimated() ? item.getAnimationFrames() : 1;
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, false));
ret.addAll(this.getTexturesForAllFrames(layer, animationFrames, true));
}
}
if (GearModelOverrideList.isDebugLoggingEnabled()) {
SilentGear.LOGGER.info("Textures for gear model '{}' ({})", getTexturePath(false), this.gearType.getName());
for (Material mat : ret) {
SilentGear.LOGGER.info("- {}", mat.texture());
}
}
return ret;
}
use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.
the class CraftedMaterialItem method getColor.
@Override
public int getColor(ItemStack stack, int layer) {
IMaterialInstance material = getMaterial(stack);
IMaterialDisplay model = material.getDisplayProperties();
return model.getLayerColor(GearType.ALL, PartType.MAIN, material, layer);
}
use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.
the class ColorUtils method getBlendedColor.
public static int getBlendedColor(ICoreItem item, IPartData part, Collection<? extends IMaterialInstance> materials, int layer) {
int[] componentSums = new int[3];
int maxColorSum = 0;
int colorCount = 0;
int i = 0;
for (IMaterialInstance mat : materials) {
IMaterialDisplay model = mat.getDisplayProperties();
int color = model.getLayerColor(item.getGearType(), part, mat, layer);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
int colorWeight = (materials.size() - i) * (materials.size() - i);
for (int j = 0; j < colorWeight; ++j) {
maxColorSum += Math.max(r, Math.max(g, b));
componentSums[0] += r;
componentSums[1] += g;
componentSums[2] += b;
++colorCount;
}
++i;
}
return blendColors(componentSums, maxColorSum, colorCount);
}
use of net.silentchaos512.gear.api.material.IMaterialDisplay in project Silent-Gear by SilentChaos512.
the class ColorUtils method getBlendedColor.
public static int getBlendedColor(CompoundMaterialItem item, Collection<? extends IMaterialInstance> materials, int layer) {
int[] componentSums = new int[3];
int maxColorSum = 0;
int colorCount = 0;
int i = 0;
for (IMaterialInstance mat : materials) {
IMaterialDisplay model = mat.getDisplayProperties();
List<MaterialLayer> layers = model.getLayerList(GearType.ALL, PartType.MAIN, mat).getLayers();
if (layers.size() > layer) {
int color = layers.get(layer).getColor();
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
int colorWeight = item.getColorWeight(i, materials.size());
for (int j = 0; j < colorWeight; ++j) {
maxColorSum += Math.max(r, Math.max(g, b));
componentSums[0] += r;
componentSums[1] += g;
componentSums[2] += b;
++colorCount;
}
++i;
}
}
return blendColors(componentSums, maxColorSum, colorCount);
}
Aggregations