use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class GearElytraLayer method render.
@Override
public void render(@Nonnull PoseStack matrixStackIn, @Nonnull MultiBufferSource bufferIn, int packedLightIn, T entityIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
ItemStack stack = entityIn.getItemBySlot(EquipmentSlot.CHEST);
if (stack.getItem() instanceof GearElytraItem) {
ResourceLocation resourcelocation;
if (entityIn instanceof AbstractClientPlayer) {
AbstractClientPlayer abstractclientplayerentity = (AbstractClientPlayer) entityIn;
boolean hasElytra = abstractclientplayerentity.isElytraLoaded() && abstractclientplayerentity.getElytraTextureLocation() != null;
boolean hasCape = abstractclientplayerentity.isCapeLoaded() && abstractclientplayerentity.getCloakTextureLocation() != null && abstractclientplayerentity.isModelPartShown(PlayerModelPart.CAPE);
if (hasElytra) {
resourcelocation = abstractclientplayerentity.getElytraTextureLocation();
} else if (hasCape) {
resourcelocation = abstractclientplayerentity.getCloakTextureLocation();
} else {
resourcelocation = TEXTURE;
}
} else {
resourcelocation = TEXTURE;
}
matrixStackIn.pushPose();
matrixStackIn.translate(0.0D, 0.0D, 0.125D);
this.getParentModel().copyPropertiesTo(this.modelElytra);
this.modelElytra.setupAnim(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
VertexConsumer ivertexbuilder = ItemRenderer.getArmorFoilBuffer(bufferIn, this.modelElytra.renderType(resourcelocation), false, stack.isEnchanted());
Color color = new Color(GearClientHelper.getColor(stack, PartType.MAIN));
this.modelElytra.renderToBuffer(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
matrixStackIn.popPose();
}
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class GearData method getBlendedColor.
@Deprecated
private static int getBlendedColor(ItemStack gear, List<PartData> parts) {
int[] componentSums = new int[3];
int maxColorSum = 0;
int colorCount = 0;
int partCount = parts.size();
for (int i = 0; i < partCount; ++i) {
PartData part = parts.get(i);
int color = part.get().getColor(part, gear, 0, 0);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
// Add earlier colors multiple times, to give them greater weight
int colorWeight = (partCount - i) * (partCount - 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;
}
}
if (colorCount > 0) {
int r = componentSums[0] / colorCount;
int g = componentSums[1] / colorCount;
int b = componentSums[2] / colorCount;
float maxAverage = (float) maxColorSum / (float) colorCount;
float max = (float) Math.max(r, Math.max(g, b));
r = (int) ((float) r * maxAverage / max);
g = (int) ((float) g * maxAverage / max);
b = (int) ((float) b * maxAverage / max);
int finalColor = (r << 8) + g;
finalColor = (finalColor << 8) + b;
return finalColor;
}
return Color.VALUE_WHITE;
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class MaterialBuilder method displayAdornment.
public MaterialBuilder displayAdornment(PartTextureSet textures, int color) {
display(PartType.ADORNMENT, GearType.ALL, new MaterialLayerList(PartType.ADORNMENT, textures, color));
display(PartType.ADORNMENT, GearType.PART, new MaterialLayer(SilentGear.getId("adornment"), color), new MaterialLayer(SilentGear.getId("adornment_highlight"), Color.VALUE_WHITE));
return this;
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class MaterialBuilder method displayBowstring.
public MaterialBuilder displayBowstring(int color) {
display(PartType.CORD, new MaterialLayer(PartTextures.BOWSTRING_STRING, color), // FIXME: Doesn't quite make sense to have this here
new MaterialLayer(PartTextures.ARROW, Color.VALUE_WHITE));
display(PartType.CORD, GearType.PART, new MaterialLayer(SilentGear.getId("bowstring"), color));
return this;
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class MaterialBuilder method displayCoating.
public MaterialBuilder displayCoating(PartTextureSet textures, int color) {
display(PartType.COATING, GearType.ALL, new MaterialLayerList(PartType.MAIN, textures, color));
display(PartType.COATING, GearType.PART, new MaterialLayer(SilentGear.getId("coating_material"), color), new MaterialLayer(SilentGear.getId("coating_jar"), Color.VALUE_WHITE));
return this;
}
Aggregations