use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.
the class ModelGemArmor method setRenderColor.
private void setRenderColor(int color) {
Color c = new Color(color);
GlStateManager.color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
}
use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.
the class ItemDrawingCompass method spawnParticles.
public boolean spawnParticles(ItemStack stack, EntityPlayer player, World world) {
BlockPos pos1 = getBlock1(stack);
BlockPos pos2 = getBlock2(stack);
if (pos1.getY() <= 0 || pos2.getY() <= 0 || pos1.equals(pos2)) {
return false;
}
Color color = getColor(stack);
// Spawn circle.
BlockPos center = new BlockPos(pos1.getX(), pos2.getY(), pos1.getZ());
float radius = (float) Math.sqrt(center.distanceSq(pos2));
int count = (int) (5 * radius);
float increment = (float) (2 * Math.PI / count);
float start = increment * (world.getTotalWorldTime() % 30) / 30f;
Vec3d vec;
for (float angle = start; angle < 2 * Math.PI + start; angle += increment) {
vec = new Vec3d(radius, 0, 0).rotateYaw(angle);
particle(player, world, color, center.getX() + 0.5 + vec.xCoord, center.getY() + 0.5 + vec.yCoord, center.getZ() + 0.5 + vec.zCoord);
}
// Spawn line.
double distance = Math.sqrt(pos1.distanceSq(pos2));
count = (int) (2 * distance);
double dx = (double) (pos2.getX() - pos1.getX()) / count;
double dy = (double) (pos2.getY() - pos1.getY()) / count;
double dz = (double) (pos2.getZ() - pos1.getZ()) / count;
for (int i = 0; i < count; ++i) {
vec = new Vec3d(pos1.getX() + 0.5 + i * dx, pos1.getY() + 0.5 + i * dy, pos1.getZ() + 0.5 + i * dz);
particle(player, world, color, vec.xCoord, vec.yCoord, vec.zCoord);
}
return true;
}
use of net.silentchaos512.utils.Color in project SilentGems by SilentChaos512.
the class GemsClientEvents method onTooltipForToolMaterial.
private void onTooltipForToolMaterial(ItemTooltipEvent event, ItemStack stack, ToolPart part, boolean ctrlDown, boolean shiftDown) {
int index = 1;
final String sep = loc.getMiscText("Tooltip.Separator");
List<String> list = event.getToolTip();
// Material grade
EnumMaterialGrade grade = EnumMaterialGrade.fromStack(stack);
if (grade != EnumMaterialGrade.NONE) {
list.add(index++, loc.getMiscText("ToolPart.Grade", grade.getLocalizedName()));
}
// Material tier
EnumMaterialTier tier = part.getTier();
list.add(index++, loc.getMiscText("ToolPart.Tier", tier.getLocalizedName()));
// Show stats?
if (ctrlDown) {
int multi = 100 + EnumMaterialGrade.fromStack(stack).bonusPercent;
// @formatter:off
list.add(index++, sep);
TextFormatting color = TextFormatting.GOLD;
list.add(index++, color + TooltipHelper.get("HarvestSpeed", part.getHarvestSpeed() * multi / 100));
list.add(index++, color + TooltipHelper.get("HarvestLevel", part.getHarvestLevel() * multi / 100));
list.add(index++, sep);
color = TextFormatting.DARK_GREEN;
list.add(index++, color + TooltipHelper.get("MeleeSpeed", (int) (part.getMeleeSpeed() * multi)));
list.add(index++, color + TooltipHelper.get("MeleeDamage", part.getMeleeDamage() * multi / 100));
list.add(index++, color + TooltipHelper.get("MagicDamage", part.getMagicDamage() * multi / 100));
list.add(index++, color + TooltipHelper.get("Protection", part.getProtection() * multi / 100));
list.add(index++, sep);
color = TextFormatting.BLUE;
list.add(index++, color + TooltipHelper.get("Durability", part.getDurability() * multi / 100));
list.add(index++, color + TooltipHelper.get("ChargeSpeed", part.getChargeSpeed() * multi / 100));
list.add(index++, color + TooltipHelper.get("Enchantability", part.getEnchantability() * multi / 100));
list.add(index++, sep);
// Debug info
if (shiftDown) {
event.getToolTip().add(index++, TextFormatting.DARK_GRAY + "* Part key: " + part.getKey());
}
// @formatter:on
} else {
list.add(index++, TextFormatting.GOLD + loc.getMiscText("PressCtrl"));
}
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class StatInstance method formatMul1.
private MutableComponent formatMul1(ItemStat stat, @Nonnegative int decimalPlaces, boolean addColor) {
int percent = Math.round(100 * this.value);
Color color = getFormattedColor(percent, 0f, addColor);
String text = trimNumber(String.format("%s%d%%", percent < 0 ? "" : "+", percent));
return TextUtil.withColor(new TextComponent(text), color);
}
use of net.silentchaos512.utils.Color in project Silent-Gear by SilentChaos512.
the class StatInstance method formatAvg.
private MutableComponent formatAvg(ItemStat stat, @Nonnegative int decimalPlaces, boolean addColor) {
Color color = getFormattedColor(this.value, 0f, addColor);
String text;
if (stat.getDisplayFormat() == ItemStat.DisplayFormat.PERCENTAGE) {
text = Math.round(this.value * 100) + "%";
} else {
// v (or vx for multiplier stats like armor durability)
String format = "%s" + ("%." + decimalPlaces + "f") + "%s";
String ret = trimNumber(String.format(format, "", this.value, ""));
text = stat.getDisplayFormat() == ItemStat.DisplayFormat.MULTIPLIER ? ret + "x" : ret;
}
return TextUtil.withColor(new TextComponent(text), color);
}
Aggregations