public void setEffectColor(String hexColor) { // TODO: Move to CasterProperties? if (hexColor == null || hexColor.length() == 0 || hexColor.equals("none")) { effectColor = null; return; } effectColor = new ColorHD(hexColor); if (hexColor.equals("random")) { setProperty("effect_color", effectColor.toString()); } }
public ColorHD mixColor(ColorHD other, double weight) { return mixColor(other.red, other.green, other.blue, weight); }
@Nullable @Override public Color getEffectColor() { return effectColor == null ? null : effectColor.getColor(); }
@Override @SuppressWarnings("deprecation") public void setPixel(int x, int y, byte color) { if (x < 0 || y < 0 || x > CANVAS_WIDTH || y > CANVAS_HEIGHT) return; pixels[x + y * CANVAS_WIDTH] = color; // Map colors in advance. if (color != MapPalette.TRANSPARENT && !dyeColors.containsKey(color)) { java.awt.Color mapColor = MapPalette.getColor(color); Color targetColor = Color.fromRGB(mapColor.getRed(), mapColor.getGreen(), mapColor.getBlue()); // Find best dyeColor DyeColor bestDyeColor = null; Double bestDistance = null; for (DyeColor testDyeColor : DyeColor.values()) { Color testColor = testDyeColor.getColor(); double testDistance = ColorHD.getDistance(testColor, targetColor); if (bestDistance == null || testDistance < bestDistance) { bestDistance = testDistance; bestDyeColor = testDyeColor; if (testDistance == 0) break; } } dyeColors.put(color, bestDyeColor); } }
public ColorHD mixColor(long r, long g, long b, double weight) { double totalWeight = weight + 1; double totalRed = (red + (r * weight)); double totalGreen = (green + (g * weight)); double totalBlue = (blue + (b * weight)); return new ColorHD( (long)(totalRed / totalWeight), (long)(totalGreen / totalWeight), (long)(totalBlue / totalWeight) ); }
blue = b; } else { Color namedColor = getColorByName(hexColor); if (namedColor != null) { red = (long)namedColor.getRed() << COMPONENT_SHIFT;
@Nullable public Color getEffectColor() { return effectColor == null ? null : effectColor.getColor(); } }
for (DyeColor testDyeColor : DyeColor.values()) { Color testColor = testDyeColor.getColor(); double testDistance = ColorHD.getDistance(testColor, color); if (bestDistance == null || testDistance < bestDistance) { bestDistance = testDistance;
public void setEffectColor(String hexColor) { // Annoying config conversion issue :\ if (hexColor.contains(".")) { hexColor = hexColor.substring(0, hexColor.indexOf('.')); } if (hexColor == null || hexColor.length() == 0 || hexColor.equals("none")) { effectColor = null; return; } effectColor = new ColorHD(hexColor); if (hexColor.equals("random")) { setProperty("effect_color", effectColor.toString()); } }
public EntityAreaEffectCloudData(ConfigurationSection parameters, MageController controller) { if (parameters.contains("color")) { ColorHD colorHD = new ColorHD(parameters.getString("color")); color = colorHD.getColor(); } if (parameters.contains("base_potion_type")) { PotionType potionType; try { potionType = PotionType.valueOf(parameters.getString("base_potion_type").toUpperCase()); basePotionData = new PotionData(potionType); } catch (Exception ex) { controller.getLogger().warning("Invalid base_potion_type: " + parameters.getString("base_potion_type")); } } if (parameters.contains("particle")) { try { particle = Particle.valueOf(parameters.getString("particle").toUpperCase()); } catch (Exception ex) { controller.getLogger().warning("Invalid particle: " + parameters.getString("particle")); } } duration = parameters.getInt("duration", 2000) * 20 / 1000; durationOnUse = parameters.getInt("duration_on_use", 0) * 20 / 1000; reapplicationDelay = parameters.getInt("reapplication_delay", 0) * 20 / 1000; waitTime = parameters.getInt("wait_time", 0) * 20 / 1000; radius = (float)parameters.getDouble("radius", 5); radiusOnUse = (float)parameters.getDouble("radius_on_use", 0); radiusPerTick = (float)parameters.getDouble("radius_per_tick", 0); potionEffects = ConfigurationUtils.getPotionEffectObjects(parameters, "potion_effects", controller.getLogger()); }
potionEffectLocation.setZ(potionEffectLocation.getZ() + random.nextDouble() - 0.5); EffectPlayer.displayParticle(Particle.SPELL_MOB, potionEffectLocation, 0, 0, 0, 0, 0, 1, effectColor.getColor(), null, (byte)0, 24);
public ColorHD mixColor(Color other, double weight) { if (other == null) return this; return mixColor(color.getRed() << COMPONENT_SHIFT, color.getGreen() << COMPONENT_SHIFT, color.getBlue() << COMPONENT_SHIFT, weight); }