use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class MaterialLayer method read.
public static MaterialLayer read(FriendlyByteBuf buffer) {
ResourceLocation texture = buffer.readResourceLocation();
int color = buffer.readVarInt();
PartType partType = PartType.getNonNull(buffer.readResourceLocation());
return new MaterialLayer(texture, partType, color, true);
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class CompoundMaterialDisplay method getLayerColor.
@Override
public int getLayerColor(GearType gearType, IPartData part, IMaterialInstance materialIn, int layer) {
List<MaterialLayer> layers = getLayerList(gearType, part, materialIn).getLayers();
if (layer < layers.size()) {
ItemStack stack = materialIn.getItem();
if (stack.getItem() instanceof CompoundMaterialItem) {
List<IMaterialInstance> subMaterials = CompoundMaterialItem.getSubMaterials(stack);
int color = ColorUtils.getBlendedColor((CompoundMaterialItem) stack.getItem(), subMaterials, layer);
// return layers.get(layer).getColor();
return color;
}
}
return Color.VALUE_WHITE;
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addWithBlendedColor.
private static void addWithBlendedColor(List<MaterialLayer> list, PartData part, MaterialInstance material, ItemStack stack) {
IMaterialDisplay model = material.getDisplayProperties();
GearType gearType = GearHelper.getType(stack);
List<MaterialLayer> layers = model.getLayerList(gearType, part, material).getLayers();
addColorBlendedLayers(list, part, stack, layers);
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class GearModelOverrideList method addColorBlendedLayers.
private static void addColorBlendedLayers(List<MaterialLayer> list, PartData part, ItemStack stack, List<MaterialLayer> layers) {
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);
MaterialLayer coloredLayer = layer.withColor(blendedColor);
list.add(coloredLayer);
if (isDebugLoggingEnabled()) {
debugLogLayer(coloredLayer, Color.format(blendedColor));
}
} else {
list.add(layer);
if (isDebugLoggingEnabled()) {
debugLogLayer(layer, "colorless");
}
}
}
}
use of net.silentchaos512.gear.api.material.MaterialLayer in project Silent-Gear by SilentChaos512.
the class CompoundPartModel method buildFakeModel.
private void buildFakeModel(Function<Material, TextureAtlasSprite> spriteGetter, ImmutableList.Builder<BakedQuad> builder, Transformation rotation, IMaterial material) {
// This method will display an example item for items with no data (ie, for advancements)
MaterialInstance mat = MaterialInstance.of(material);
IMaterialDisplay model = mat.getDisplayProperties();
MaterialLayer exampleMain = model.getLayerList(this.gearType, this.partType, mat).getFirstLayer();
if (exampleMain != null) {
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, exampleMain.getTexture(this.texturePath, 0))), rotation, exampleMain.getColor()));
}
builder.addAll(getQuadsForSprite(0, spriteGetter.apply(new Material(InventoryMenu.BLOCK_ATLAS, new StaticLayer(PART_MARKER_TEXTURE).getTexture(this.gearType, 0))), rotation, Color.VALUE_WHITE));
}
Aggregations