Here are the examples of the java api org.orecruncher.lib.Color taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
17 Examples
19
Source : BiomeInfo.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
void setDustColor(final Color color) {
this.dustColor = color;
}
19
Source : BiomeInfo.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
void setFogColor(@Nonnull final Color color) {
this.fogColor = color;
}
19
Source : SpeechDataRenderer.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@EventBusSubscriber(value = Side.CLIENT, modid = ModInfo.MOD_ID)
public clreplaced SpeechDataRenderer {
private static final Color B_COLOR = Color.getColor(TextFormatting.BLACK);
// 0.25F;
private static final float B_COLOR_ALPHA = 0.5F;
private static final Color F_COLOR = Color.getColor(TextFormatting.GOLD);
private static final float F_COLOR_ALPHA = 0.99F;
private static final Color F_COLOR_DEPTH = Color.getColor(TextFormatting.GRAY);
private static RenderManager getRenderManager() {
return Minecraft.getMinecraft().getRenderManager();
}
private static double interpX() {
return getRenderManager().viewerPosX;
}
private static double interpY() {
return getRenderManager().viewerPosY;
}
private static double interpZ() {
return getRenderManager().viewerPosZ;
}
private static boolean isThirdPersonView() {
final GameSettings settings = getRenderManager().options;
return settings != null && settings.thirdPersonView == 2;
}
private static void doRender(@Nonnull final Enreplacedy enreplacedy, @Nonnull final ISpeechData data, final float partialTicks) {
final RenderContext ctx = data.getRenderContext();
if (ctx == null || ctx.numberOfMessages == 0)
return;
final FontRenderer font = Minecraft.getMinecraft().fontRenderer;
// Calculate scale and position
final float pitch = getRenderManager().playerViewX * (isThirdPersonView() ? -1 : 1);
final float yaw = -getRenderManager().playerViewY;
final float locX = ((float) (enreplacedy.prevPosX + (enreplacedy.posX - enreplacedy.prevPosX) * partialTicks - interpX()));
final float locY = ((float) (enreplacedy.prevPosY + (enreplacedy.posY - enreplacedy.prevPosY) * partialTicks - interpY()));
final float locZ = ((float) (enreplacedy.prevPosZ + (enreplacedy.posZ - enreplacedy.prevPosZ) * partialTicks - interpZ()));
final OpenGlState glState = OpenGlState.push();
GlStateManager.translate(locX, locY + enreplacedy.height + 0.25F, locZ);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GlStateManager.rotate(yaw, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(pitch, 1.0F, 0.0F, 0.0F);
final float scale = -1F;
GlStateManager.scale(scale * 0.015D, scale * 0.015F, scale * 0.015D);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
GlStateManager.enableAlpha();
// // Draw the background region
final float red = B_COLOR.red;
final float green = B_COLOR.green;
final float blue = B_COLOR.blue;
final float alpha = B_COLOR_ALPHA;
final BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin(GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_COLOR);
buffer.pos(ctx.left, ctx.top, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(ctx.left, ctx.bottom, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(ctx.right, ctx.top, 0.0D).color(red, green, blue, alpha).endVertex();
buffer.pos(ctx.right, ctx.bottom, 0.0D).color(red, green, blue, alpha).endVertex();
Tessellator.getInstance().draw();
GlStateManager.enableTexture2D();
GlStateManager.depthMask(true);
GlStateManager.translate(0, 0, -0.05F);
final ObjectArray<String> text = data.getText();
int lines = ctx.numberOfMessages;
for (int t = 0; t < ctx.numberOfMessages; t++) {
final String str = text.get(t);
final int offset = -lines * 9;
final int margin = -font.getStringWidth(str) / 2;
GlStateManager.disableDepth();
GlStateManager.depthMask(false);
font.drawString(str, margin, offset, F_COLOR_DEPTH.rgbWithAlpha(F_COLOR_ALPHA));
GlStateManager.enableDepth();
GlStateManager.depthMask(true);
font.drawString(str, margin, offset, F_COLOR.rgbWithAlpha(F_COLOR_ALPHA));
lines--;
}
OpenGlState.pop(glState);
}
private static boolean canBeSeen(@Nonnull EnreplacedyPlayer player, @Nonnull Enreplacedy subject) {
if (subject.isInvisibleToPlayer(player))
return false;
return player.canEnreplacedyBeSeen(subject);
}
@SubscribeEvent
public static void onRenderWorldLast(@Nonnull final RenderWorldLastEvent event) {
final EnreplacedyPlayer player = EnvironState.getPlayer();
if (player != null) {
// 16 block range
final int range = 16 * 16;
final ObjectArray<Enreplacedy> enreplacedies = WorldUtils.gatherEnreplacediesInView(player, range, event.getPartialTicks());
for (final Enreplacedy e : enreplacedies) {
final ISpeechData data = CapabilitySpeechData.getCapability(e);
if (data != null && canBeSeen(player, e)) {
doRender(e, data, event.getPartialTicks());
}
}
}
}
}
19
Source : FogHandler.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void fogColorEvent(final EnreplacedyViewRenderEvent.FogColors event) {
if (doFog()) {
final long start = System.nanoTime();
final Material material = event.getState().getMaterial();
if (material != Material.LAVA && material != Material.WATER) {
final Color color = this.fogColor.calculate(event);
event.setRed(color.red);
event.setGreen(color.green);
event.setBlue(color.blue);
}
this.nanos += System.nanoTime() - start;
}
}
19
Source : HolisticFogColorCalculator.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@Nonnull
@Override
public Color calculate(@Nonnull final EnreplacedyViewRenderEvent.FogColors event) {
Color result = null;
for (int i = 0; i < this.calculators.size(); i++) {
final Color color = this.calculators.get(i).calculate(event);
if (result == null)
result = color;
else
result = result.mix(color);
}
return this.cached = result;
}
19
Source : ParticleTextPopOff.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
public ParticleTextPopOff setColor(@Nonnull final Color color) {
this.renderColor = color.rgbWithAlpha(1F);
return this;
}
19
Source : MoteWaterSpray.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@Override
public void configureColor() {
final Color waterColor = BiomeUtil.getColorForLiquid(this.world, this.position);
this.red = (int) (waterColor.red * 255);
this.green = (int) (waterColor.green * 255);
this.blue = (int) (waterColor.blue * 255);
this.alpha = 255;
}
18
Source : BiomeUtil.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public final clreplaced BiomeUtil {
private static final Color NO_COLOR = new Color.ImmutableColor(1F, 1F, 1F);
// @formatter:off
private static final ObjectField<Biome, String> biomeName = new ObjectField<>(Biome.clreplaced, "biomeName", "field_76791_y");
private static final FloatField<Object> bopBiomeFogDensity = new FloatField<>("biomesoplenty.common.biome.BOPBiome", "fogDensity", null);
private static final IntegerField<Object> bopBiomeFogColor = new IntegerField<>("biomesoplenty.common.biome.BOPBiome", "fogColor", null);
private static final ObjectField<BiomeDictionary.Type, Map<String, BiomeDictionary.Type>> biomeType = new ObjectField<>(BiomeDictionary.Type.clreplaced, "byName", null);
// @formatter:on
private static final Clreplaced<?> bopBiome = ReflectedField.resolveClreplaced("biomesoplenty.common.biome.BOPBiome");
@SuppressWarnings("unchecked")
@Nonnull
public static BiomeInfo getBiomeData(@Nonnull final Biome biome) {
final IDataAccessor<BiomeInfo> accessor = (IDataAccessor<BiomeInfo>) biome;
BiomeInfo result;
result = accessor.getData();
if (result == null) {
RegistryManager.BIOME.reload();
result = accessor.getData();
}
if (result == null) {
ModBase.log().warn("Unable to find configuration for biome [%s] (hc=%d)", biome.getRegistryName(), System.idenreplacedyHashCode(biome));
result = RegistryManager.BIOME.WTF_INFO;
accessor.setData(result);
}
return result;
}
@SuppressWarnings("unchecked")
public static void setBiomeData(@Nonnull final Biome biome, @Nullable final BiomeInfo data) {
((IDataAccessor<BiomeInfo>) biome).setData(data);
}
@Nonnull
public static String getBiomeName(@Nonnull final Biome biome) {
final String result = biomeName.get(biome);
return StringUtils.isEmpty(result) ? "UNKNOWN" : result;
}
// ==================
//
// BoP Support
//
// ==================
public static boolean isBoPBiome(@Nonnull final Biome biome) {
return bopBiome != null && bopBiome.isInstance(biome);
}
public static int getBoPBiomeFogColor(@Nonnull final Biome biome) {
return bopBiomeFogColor.isAvailable() ? bopBiomeFogColor.get(biome) : 0;
}
public static float getBoPBiomeFogDensity(@Nonnull final Biome biome) {
return bopBiomeFogDensity.isAvailable() ? bopBiomeFogDensity.get(biome) : 0F;
}
// ===================================
//
// Miscellaneous Support Functions
//
// ===================================
@Nonnull
public static Set<Type> getBiomeTypes() {
if (biomeType.isAvailable()) {
return new ReferenceOpenHashSet<>(biomeType.get(null).values());
}
throw new IllegalStateException("Cannot locate BiomeDictionary.Type table!");
}
@Nonnull
public static Color getBiomeWaterColor(@Nonnull final World world, @Nonnull final BlockPos pos) {
return new Color(BiomeColorHelper.gereplacederColorAtPos(world, pos));
}
@Nonnull
public static Color getColorForLiquid(@Nonnull final World world, @Nonnull final BlockPos pos) {
return getColorForLiquid(world, WorldUtils.getBlockState(world, pos), pos);
}
@Nonnull
public static Color getColorForLiquid(@Nonnull final World world, @Nonnull final IBlockState state, @Nonnull final BlockPos pos) {
final Block liquid = state.getBlock();
if (liquid == Blocks.WATER) {
return getBiomeWaterColor(world, pos);
} else {
// Lookup in fluid registry
final Fluid fluid = FluidRegistry.lookupFluidForBlock(liquid);
if (fluid != null) {
return new Color(fluid.getColor());
}
}
return NO_COLOR;
}
@Nonnull
public static Set<Type> getBiomeTypes(@Nonnull final Biome biome) {
// It's possible to have a biome that is not registered come through here
// There is an internal check that will throw an exception if that is the
// case. Seen this with OTG installed.
try {
return new ReferenceOpenHashSet<>(BiomeDictionary.getTypes(biome));
} catch (@Nonnull final Throwable t) {
final String name = biomeName.get(biome);
ModBase.log().warn("Unable to get biome type data for biome '%s'", name);
}
return new ReferenceOpenHashSet<>();
}
public static boolean areBiomesSimilar(@Nonnull final Biome b1, @Nonnull final Biome b2) {
return BiomeDictionary.areSimilar(b1, b2);
}
}
18
Source : BiomeInfo.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public final clreplaced BiomeInfo implements Comparable<BiomeInfo> {
private final static float DEFAULT_FOG_DENSITY = 0.4F;
private final static Color DEFAULT_FOG_COLOR = new Color(64, 96, 64).asImmutable();
private final static Color DEFAULT_DUST_COLOR = new Color(255, 234, 151).asImmutable();
public final static int DEFAULT_SPOT_CHANCE = 1000 / BiomeSoundEffectsHandler.SCAN_INTERVAL;
public final static SoundEffect[] NO_SOUNDS = {};
protected final IBiome biome;
protected boolean hasPrecipitation;
protected boolean hasDust;
protected boolean hasAurora;
protected boolean hasFog;
private Color dustColor = DEFAULT_DUST_COLOR;
private Color fogColor = DEFAULT_FOG_COLOR;
private float fogDensity = DEFAULT_FOG_DENSITY;
protected SoundEffect[] sounds = NO_SOUNDS;
protected SoundEffect[] spotSounds = NO_SOUNDS;
protected int spotSoundChance = DEFAULT_SPOT_CHANCE;
protected final List<String> comments = Lists.newArrayList();
protected final boolean isRiver;
protected final boolean isOcean;
protected final boolean isDeepOcean;
protected final String traits;
public BiomeInfo(@Nonnull final IBiome biome) {
this.biome = biome;
if (!isFake()) {
this.hasPrecipitation = canRain() || getEnableSnow();
}
// If it is a BOP biome initialize from the BoP Biome
// instance. May be overwritten by DS config.
if (!biome.isFake()) {
final Biome b = biome.getBiome();
if (BiomeUtil.isBoPBiome(b)) {
final int color = BiomeUtil.getBoPBiomeFogColor(b);
if (color > 0) {
this.hasFog = true;
this.fogColor = new Color(color);
this.fogDensity = BiomeUtil.getBoPBiomeFogDensity(b);
}
}
}
this.isRiver = this.biome.getTypes().contains(Type.RIVER);
this.isOcean = this.biome.getTypes().contains(Type.OCEAN);
this.isDeepOcean = this.isOcean && getBiomeName().matches("(?i).*deep.*ocean.*|.*abyss.*");
this.traits = getBiomeTypes().stream().map(BiomeDictionary.Type::getName).collect(Collectors.joining(" "));
}
public boolean isRiver() {
return this.isRiver;
}
public boolean isOcean() {
return this.isOcean;
}
public boolean isDeepOcean() {
return this.isDeepOcean;
}
public ResourceLocation getKey() {
return this.biome.getKey();
}
public int getBiomeId() {
return this.biome.getId();
}
public Biome getBiome() {
return this.biome.getBiome();
}
public Set<Type> getBiomeTypes() {
return this.biome.getTypes();
}
public String getBiomeTraits() {
return this.traits;
}
void addComment(@Nonnull final String comment) {
if (!StringUtils.isEmpty(comment))
this.comments.add(comment);
}
public List<String> getComments() {
return this.comments;
}
public String getBiomeName() {
return this.biome.getName();
}
public boolean hasWeatherEffect() {
return getHasPrecipitation() || getHasDust();
}
public boolean getHasPrecipitation() {
return this.hasPrecipitation;
}
public boolean canRain() {
return this.biome.canRain();
}
public boolean getEnableSnow() {
return this.biome.getEnableSnow();
}
void setHasPrecipitation(final boolean flag) {
this.hasPrecipitation = flag;
}
public boolean getHasDust() {
return this.hasDust;
}
void setHasDust(final boolean flag) {
this.hasDust = flag;
}
public boolean getHasAurora() {
return this.hasAurora;
}
void setHasAurora(final boolean flag) {
this.hasAurora = flag;
}
public boolean getHasFog() {
return this.hasFog;
}
void setHasFog(final boolean flag) {
this.hasFog = flag;
}
public Color getDustColor() {
return this.dustColor;
}
void setDustColor(final Color color) {
this.dustColor = color;
}
public Color getFogColor() {
return this.fogColor;
}
void setFogColor(@Nonnull final Color color) {
this.fogColor = color;
}
public float getFogDensity() {
return this.fogDensity;
}
void setFogDensity(final float density) {
this.fogDensity = density;
}
void setSpotSoundChance(final int chance) {
this.spotSoundChance = chance;
}
void addSound(final SoundEffect sound) {
this.sounds = MyUtils.append(this.sounds, sound);
}
void addSpotSound(final SoundEffect sound) {
this.spotSounds = MyUtils.append(this.spotSounds, sound);
}
public boolean isFake() {
return this.biome instanceof FakeBiome;
}
public float getFloatTemperature(@Nonnull final BlockPos pos) {
return this.biome.getFloatTemperature(pos);
}
public float getTemperature() {
return this.biome.getTemperature();
}
public TempCategory getTempCategory() {
return this.biome.getTempCategory();
}
public TemperatureRating getTemperatureRating() {
return TemperatureRating.fromTemp(getTemperature());
}
public boolean isHighHumidity() {
return this.biome.isHighHumidity();
}
public float getRainfall() {
return this.biome.getRainfall();
}
@Nonnull
public Collection<SoundEffect> findSoundMatches() {
return findSoundMatches(new ObjectArray<>(8));
}
@Nonnull
public Collection<SoundEffect> findSoundMatches(@Nonnull final Collection<SoundEffect> results) {
for (final SoundEffect sound : this.sounds) {
if (sound.matches())
results.add(sound);
}
return results;
}
@Nullable
public SoundEffect getSpotSound(@Nonnull final Random random) {
return this.spotSounds != NO_SOUNDS && random.nextInt(this.spotSoundChance) == 0 ? new WeightTable<>(this.spotSounds).next() : null;
}
void resetSounds() {
this.sounds = NO_SOUNDS;
this.spotSounds = NO_SOUNDS;
this.spotSoundChance = DEFAULT_SPOT_CHANCE;
}
public boolean isBiomeType(@Nonnull final BiomeDictionary.Type type) {
return getBiomeTypes().contains(type);
}
public boolean areBiomesSameClreplaced(@Nonnull final Biome biome) {
return BiomeUtil.areBiomesSimilar(this.biome.getBiome(), biome);
}
public void update(@Nonnull final BiomeConfig entry) {
addComment(entry.comment);
if (entry.hasPrecipitation != null)
setHasPrecipitation(entry.hasPrecipitation);
if (entry.hasAurora != null)
setHasAurora(entry.hasAurora);
if (entry.hasDust != null)
setHasDust(entry.hasDust);
if (entry.hasFog != null)
setHasFog(entry.hasFog);
if (entry.fogDensity != null)
setFogDensity(entry.fogDensity);
if (entry.fogColor != null) {
final int[] rgb = MyUtils.splitToInts(entry.fogColor, ',');
if (rgb.length == 3)
setFogColor(new Color(rgb[0], rgb[1], rgb[2]));
}
if (entry.dustColor != null) {
final int[] rgb = MyUtils.splitToInts(entry.dustColor, ',');
if (rgb.length == 3)
setDustColor(new Color(rgb[0], rgb[1], rgb[2]));
}
if (entry.soundReset != null && entry.soundReset) {
addComment("> Sound Reset");
resetSounds();
}
if (entry.spotSoundChance != null)
setSpotSoundChance(entry.spotSoundChance);
for (final SoundConfig sr : entry.sounds) {
if (RegistryManager.SOUND.isSoundBlocked(new ResourceLocation(sr.sound)))
continue;
final SoundEffect.Builder b = new SoundEffect.Builder(sr);
final SoundEffect s = b.build();
if (s.getSoundType() == SoundType.SPOT)
addSpotSound(s);
else
addSound(s);
}
}
@Override
@Nonnull
public String toString() {
final ResourceLocation rl = this.biome.getKey();
final String registryName = rl == null ? (isFake() ? "FAKE" : "UNKNOWN") : rl.toString();
final StringBuilder builder = new StringBuilder();
builder.append("Biome [").append(getBiomeName()).append('/').append(registryName).append("] (").append(getBiomeId()).append("):");
if (!isFake()) {
builder.append("\n+ ").append('<');
builder.append(getBiomeTraits());
builder.append('>').append('\n');
builder.append("+ temp: ").append(getTemperature()).append(" (").append(getTemperatureRating().getValue()).append(")");
builder.append(" rain: ").append(getRainfall());
}
if (this.hasPrecipitation)
builder.append(" PRECIPITATION");
if (this.hasDust)
builder.append(" DUST");
if (this.hasAurora)
builder.append(" AURORA");
if (this.hasFog)
builder.append(" FOG");
if (this.hasDust && this.dustColor != null)
builder.append(" dustColor:").append(this.dustColor.toString());
if (this.hasFog && this.fogColor != null) {
builder.append(" fogColor:").append(this.fogColor.toString());
builder.append(" fogDensity:").append(this.fogDensity);
}
if (this.sounds.length > 0) {
builder.append("\n+ sounds [\n");
builder.append(Arrays.stream(this.sounds).map(c -> "+ " + c.toString()).collect(Collectors.joining("\n")));
builder.append("\n+ ]");
}
if (this.spotSounds.length > 0) {
builder.append("\n+ spot sound chance:").append(this.spotSoundChance);
builder.append("\n+ spot sounds [\n");
builder.append(Arrays.stream(this.spotSounds).map(c -> "+ " + c.toString()).collect(Collectors.joining("\n")));
builder.append("\n+ ]");
}
if (this.comments.size() > 0) {
builder.append("\n+ comments:\n");
builder.append(this.comments.stream().map(c -> "+ " + c).collect(Collectors.joining("\n")));
builder.append('\n');
}
return builder.toString();
}
@Override
public int compareTo(@Nonnull final BiomeInfo o) {
return getBiomeName().compareTo(o.getBiomeName());
}
}
18
Source : HolisticFogColorCalculator.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public clreplaced HolisticFogColorCalculator implements IFogColorCalculator {
protected ObjectArray<IFogColorCalculator> calculators = new ObjectArray<>(4);
protected Color cached;
public void add(@Nonnull final IFogColorCalculator calc) {
this.calculators.add(calc);
}
@Nonnull
@Override
public Color calculate(@Nonnull final EnreplacedyViewRenderEvent.FogColors event) {
Color result = null;
for (int i = 0; i < this.calculators.size(); i++) {
final Color color = this.calculators.get(i).calculate(event);
if (result == null)
result = color;
else
result = result.mix(color);
}
return this.cached = result;
}
@Override
public void tick() {
this.calculators.forEach(IFogColorCalculator::tick);
}
@Override
public String toString() {
return this.cached != null ? this.cached.toString() : "<NOT SET>";
}
}
18
Source : BiomeFogColorCalculator.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public clreplaced BiomeFogColorCalculator extends VanillaFogColorCalculator {
protected int posX;
protected int posZ;
// Last preplaced calculations. We can reuse if possible to avoid scanning
// the area, again.
protected double weightBiomeFog;
protected Color biomeFogColor;
protected boolean doScan = true;
@Override
@Nonnull
public Color calculate(@Nonnull final EnreplacedyViewRenderEvent.FogColors event) {
final EnreplacedyLivingBase player = EnvironState.getPlayer();
final World world = EnvironState.getWorld();
final IBlockAccessEx provider = ClientChunkCache.instance();
final int playerX = MathStuff.floor(player.posX);
final int playerZ = MathStuff.floor(player.posZ);
// ForgeHooksClient.getSkyBlendColour()
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
final int[] ranges = ForgeModContainer.blendRanges;
int distance = 6;
if (settings.fancyGraphics && ranges.length > 0) {
distance = ranges[MathStuff.clamp(settings.renderDistanceChunks, 0, ranges.length - 1)];
}
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
this.doScan |= this.posX != playerX || this.posZ != playerZ;
if (this.doScan) {
this.doScan = false;
this.posX = playerX;
this.posZ = playerZ;
this.biomeFogColor = new Color(0, 0, 0);
this.weightBiomeFog = 0;
for (int x = -distance; x <= distance; ++x) {
for (int z = -distance; z <= distance; ++z) {
pos.setPos(playerX + x, 0, playerZ + z);
// If the chunk is not available doScan will be set true. This will force
// another scan on the next tick.
this.doScan = this.doScan | !provider.isAvailable(pos);
final BiomeInfo biome = BiomeUtil.getBiomeData(provider.getBiome(pos));
final Color color;
// Fetch the color we are dealing with.
if (biome.getHasDust()) {
color = biome.getDustColor();
} else if (biome.getHasFog()) {
color = biome.getFogColor();
} else {
color = null;
}
if (color != null) {
this.biomeFogColor.add(color);
this.weightBiomeFog += 1F;
}
}
}
}
// If we have nothing then just return whatever Vanilla wanted
if (this.weightBiomeFog == 0 || distance == 0)
return super.calculate(event);
// WorldProvider.getFogColor() - need to calculate the scale based
// on sunlight and stuff.
final float partialTicks = (float) event.getRenderPartialTicks();
final float celestialAngle = world.getCelestialAngle(partialTicks);
final float baseScale = MathStuff.clamp(MathStuff.cos(celestialAngle * MathStuff.PI_F * 2.0F) * 2.0F + 0.5F, 0, 1);
double rScale = baseScale * 0.94F + 0.06F;
double gScale = baseScale * 0.94F + 0.06F;
double bScale = baseScale * 0.91F + 0.09F;
// EnreplacedyRenderer.updateFogColor() - adjust the scale further
// based on rain and thunder.
final float rainStrength = Weather.getIntensityLevel();
if (rainStrength > 0) {
rScale *= 1 - rainStrength * 0.5f;
gScale *= 1 - rainStrength * 0.5f;
bScale *= 1 - rainStrength * 0.4f;
}
final float thunderStrength = Weather.getThunderStrength();
if (thunderStrength > 0) {
rScale *= 1 - thunderStrength * 0.5f;
gScale *= 1 - thunderStrength * 0.5f;
bScale *= 1 - thunderStrength * 0.5f;
}
// Normalize the blended color components based on the biome weight.
// The components contain a summation of all the fog components
// in the area around the player.
final Color fogColor = new Color(this.biomeFogColor);
fogColor.scale(//
(float) (rScale / this.weightBiomeFog), //
(float) (gScale / this.weightBiomeFog), //
(float) (bScale / this.weightBiomeFog));
final Color processedColor = applyPlayerEffects(world, player, fogColor, partialTicks);
final double weightMixed = (distance * 2 + 1) * (distance * 2 + 1);
final double weightDefault = weightMixed - this.weightBiomeFog;
final Color vanillaColor = super.calculate(event);
processedColor.scale((float) this.weightBiomeFog);
vanillaColor.scale((float) weightDefault);
return processedColor.add(vanillaColor).scale((float) (1 / weightMixed));
}
protected Color applyPlayerEffects(@Nonnull final World world, @Nonnull final EnreplacedyLivingBase player, @Nonnull final Color fogColor, final float renderPartialTicks) {
float darkScale = (float) ((player.lastTickPosY + (player.posY - player.lastTickPosY) * renderPartialTicks) * world.provider.getVoidFogYFactor());
// EnreplacedyRenderer.updateFogColor() - If the player is blind need to
// darken it further
PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.BLINDNESS);
if (potionEffect != null) {
final int duration = potionEffect.getDuration();
darkScale *= (duration < 20) ? (1 - duration / 20f) : 0;
}
if (darkScale < 1) {
darkScale = (darkScale < 0) ? 0 : darkScale * darkScale;
fogColor.scale(darkScale);
}
// EnreplacedyRenderer.updateFogColor() - If the player has night vision going
// need to lighten it a bit
potionEffect = player.getActivePotionEffect(MobEffects.NIGHT_VISION);
if (potionEffect != null) {
final int duration = potionEffect.getDuration();
final float brightness = (duration > 200) ? 1 : 0.7f + MathStuff.sin((duration - renderPartialTicks) * MathStuff.PI_F * 0.2f) * 0.3f;
float scale = 1 / fogColor.red;
scale = Math.min(scale, 1F / fogColor.green);
scale = Math.min(scale, 1F / fogColor.blue);
return fogColor.scale((1F - brightness) + scale * brightness);
}
return fogColor;
}
}
18
Source : BiomeFogColorCalculator.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
protected Color applyPlayerEffects(@Nonnull final World world, @Nonnull final EnreplacedyLivingBase player, @Nonnull final Color fogColor, final float renderPartialTicks) {
float darkScale = (float) ((player.lastTickPosY + (player.posY - player.lastTickPosY) * renderPartialTicks) * world.provider.getVoidFogYFactor());
// EnreplacedyRenderer.updateFogColor() - If the player is blind need to
// darken it further
PotionEffect potionEffect = player.getActivePotionEffect(MobEffects.BLINDNESS);
if (potionEffect != null) {
final int duration = potionEffect.getDuration();
darkScale *= (duration < 20) ? (1 - duration / 20f) : 0;
}
if (darkScale < 1) {
darkScale = (darkScale < 0) ? 0 : darkScale * darkScale;
fogColor.scale(darkScale);
}
// EnreplacedyRenderer.updateFogColor() - If the player has night vision going
// need to lighten it a bit
potionEffect = player.getActivePotionEffect(MobEffects.NIGHT_VISION);
if (potionEffect != null) {
final int duration = potionEffect.getDuration();
final float brightness = (duration > 200) ? 1 : 0.7f + MathStuff.sin((duration - renderPartialTicks) * MathStuff.PI_F * 0.2f) * 0.3f;
float scale = 1 / fogColor.red;
scale = Math.min(scale, 1F / fogColor.green);
scale = Math.min(scale, 1F / fogColor.blue);
return fogColor.scale((1F - brightness) + scale * brightness);
}
return fogColor;
}
18
Source : BiomeFogColorCalculator.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@Override
@Nonnull
public Color calculate(@Nonnull final EnreplacedyViewRenderEvent.FogColors event) {
final EnreplacedyLivingBase player = EnvironState.getPlayer();
final World world = EnvironState.getWorld();
final IBlockAccessEx provider = ClientChunkCache.instance();
final int playerX = MathStuff.floor(player.posX);
final int playerZ = MathStuff.floor(player.posZ);
// ForgeHooksClient.getSkyBlendColour()
final GameSettings settings = Minecraft.getMinecraft().gameSettings;
final int[] ranges = ForgeModContainer.blendRanges;
int distance = 6;
if (settings.fancyGraphics && ranges.length > 0) {
distance = ranges[MathStuff.clamp(settings.renderDistanceChunks, 0, ranges.length - 1)];
}
final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
this.doScan |= this.posX != playerX || this.posZ != playerZ;
if (this.doScan) {
this.doScan = false;
this.posX = playerX;
this.posZ = playerZ;
this.biomeFogColor = new Color(0, 0, 0);
this.weightBiomeFog = 0;
for (int x = -distance; x <= distance; ++x) {
for (int z = -distance; z <= distance; ++z) {
pos.setPos(playerX + x, 0, playerZ + z);
// If the chunk is not available doScan will be set true. This will force
// another scan on the next tick.
this.doScan = this.doScan | !provider.isAvailable(pos);
final BiomeInfo biome = BiomeUtil.getBiomeData(provider.getBiome(pos));
final Color color;
// Fetch the color we are dealing with.
if (biome.getHasDust()) {
color = biome.getDustColor();
} else if (biome.getHasFog()) {
color = biome.getFogColor();
} else {
color = null;
}
if (color != null) {
this.biomeFogColor.add(color);
this.weightBiomeFog += 1F;
}
}
}
}
// If we have nothing then just return whatever Vanilla wanted
if (this.weightBiomeFog == 0 || distance == 0)
return super.calculate(event);
// WorldProvider.getFogColor() - need to calculate the scale based
// on sunlight and stuff.
final float partialTicks = (float) event.getRenderPartialTicks();
final float celestialAngle = world.getCelestialAngle(partialTicks);
final float baseScale = MathStuff.clamp(MathStuff.cos(celestialAngle * MathStuff.PI_F * 2.0F) * 2.0F + 0.5F, 0, 1);
double rScale = baseScale * 0.94F + 0.06F;
double gScale = baseScale * 0.94F + 0.06F;
double bScale = baseScale * 0.91F + 0.09F;
// EnreplacedyRenderer.updateFogColor() - adjust the scale further
// based on rain and thunder.
final float rainStrength = Weather.getIntensityLevel();
if (rainStrength > 0) {
rScale *= 1 - rainStrength * 0.5f;
gScale *= 1 - rainStrength * 0.5f;
bScale *= 1 - rainStrength * 0.4f;
}
final float thunderStrength = Weather.getThunderStrength();
if (thunderStrength > 0) {
rScale *= 1 - thunderStrength * 0.5f;
gScale *= 1 - thunderStrength * 0.5f;
bScale *= 1 - thunderStrength * 0.5f;
}
// Normalize the blended color components based on the biome weight.
// The components contain a summation of all the fog components
// in the area around the player.
final Color fogColor = new Color(this.biomeFogColor);
fogColor.scale(//
(float) (rScale / this.weightBiomeFog), //
(float) (gScale / this.weightBiomeFog), //
(float) (bScale / this.weightBiomeFog));
final Color processedColor = applyPlayerEffects(world, player, fogColor, partialTicks);
final double weightMixed = (distance * 2 + 1) * (distance * 2 + 1);
final double weightDefault = weightMixed - this.weightBiomeFog;
final Color vanillaColor = super.calculate(event);
processedColor.scale((float) this.weightBiomeFog);
vanillaColor.scale((float) weightDefault);
return processedColor.add(vanillaColor).scale((float) (1 / weightMixed));
}
18
Source : EntityHealthPopoffEffect.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public clreplaced EnreplacedyHealthPopoffEffect extends EnreplacedyEffect {
private static final Color CRITICAL_TEXT_COLOR = Color.MC_GOLD;
private static final Color HEAL_TEXT_COLOR = Color.MC_GREEN;
private static final Color DAMAGE_TEXT_COLOR = Color.MC_RED;
private static final Translations xlate = new Translations();
private static final int CRITWORD_COUNT = 85;
private static final String CRITWORD_PREFIX = "critword.";
static {
xlate.load("/replacedets/dsurround/dsurround/data/critwords/");
}
protected float lastHealth;
private String getPowerWord() {
final int id = XorShiftRandom.current().nextInt(CRITWORD_COUNT);
return xlate.loadString(CRITWORD_PREFIX + id) + "!";
}
@Override
public void initialize(@Nonnull final IEnreplacedyEffectHandlerState state) {
super.initialize(state);
getState().subject().ifPresent(e -> this.lastHealth = ((EnreplacedyLivingBase) e).getHealth());
}
@Nonnull
@Override
public String name() {
return "Health Tracker";
}
@Override
public boolean receiveLastCall() {
return true;
}
@Override
public void update(@Nonnull final Enreplacedy subject) {
if (!ModOptions.effects.enableDamagePopoffs)
return;
final EnreplacedyLivingBase enreplacedy = (EnreplacedyLivingBase) subject;
if (this.lastHealth != enreplacedy.getHealth()) {
final int adjustment = MathHelper.ceil(enreplacedy.getHealth() - this.lastHealth);
this.lastHealth = enreplacedy.getHealth();
// Don't display if it is the current player in first person view
if (!EnvironState.isPlayer(subject) || !isFirstPersonView()) {
final int delta = Math.max(1, MathStuff.abs(adjustment));
final int criticalAmount = (int) (enreplacedy.getMaxHealth() / 2.5F);
final AxisAlignedBB bb = enreplacedy.getEnreplacedyBoundingBox();
final double posX = enreplacedy.posX;
final double posY = bb.maxY + 0.5D;
final double posZ = enreplacedy.posZ;
final String text = String.valueOf(delta);
final Color color = adjustment > 0 ? HEAL_TEXT_COLOR : DAMAGE_TEXT_COLOR;
final World world = EnvironState.getWorld();
ParticleTextPopOff particle;
if (ModOptions.effects.showCritWords && adjustment < 0 && delta >= criticalAmount) {
particle = new ParticleTextPopOff(world, getPowerWord(), CRITICAL_TEXT_COLOR, posX, posY + 0.5D, posZ);
getState().addParticle(particle);
}
particle = new ParticleTextPopOff(world, text, color, posX, posY, posZ);
getState().addParticle(particle);
}
}
}
// Currently restricted to the active player. Have stuff to unwind in the
// footprint code.
public static final IEnreplacedyEffectFactoryFilter DEFAULT_FILTER = (@Nonnull final Enreplacedy e, @Nonnull final EnreplacedyEffectInfo eei) -> e instanceof EnreplacedyLivingBase;
public static clreplaced Factory implements IEnreplacedyEffectFactory {
@Nonnull
@Override
public List<EnreplacedyEffect> create(@Nonnull final Enreplacedy enreplacedy) {
return ImmutableList.of(new EnreplacedyHealthPopoffEffect());
}
}
}
18
Source : AuroraColor.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@SideOnly(Side.CLIENT)
public final clreplaced AuroraColor {
/**
* Color that forms the base of the aurora and is the brightest.
*/
public final Color baseColor;
/**
* Color that forms the top of the aurora and usually fades to black.
*/
public final Color fadeColor;
/**
* Mid-band color for aurora styles that use it.
*/
public final Color middleColor;
private static final List<AuroraColor> COLOR_SETS = new ArrayList<>();
private static final float WARMER = 0.3F;
private static final float COOLER = -0.3F;
static {
COLOR_SETS.add(new AuroraColor(new Color(0x0, 0xff, 0x99), new Color(0x33, 0xff, 0x00)));
COLOR_SETS.add(new AuroraColor(Color.BLUE, Color.GREEN));
COLOR_SETS.add(new AuroraColor(Color.MAGENTA, Color.GREEN));
COLOR_SETS.add(new AuroraColor(Color.INDIGO, Color.GREEN));
COLOR_SETS.add(new AuroraColor(Color.TURQOISE, Color.LGREEN));
COLOR_SETS.add(new AuroraColor(Color.YELLOW, Color.RED));
COLOR_SETS.add(new AuroraColor(Color.GREEN, Color.RED));
COLOR_SETS.add(new AuroraColor(Color.GREEN, Color.YELLOW));
COLOR_SETS.add(new AuroraColor(Color.RED, Color.YELLOW));
COLOR_SETS.add(new AuroraColor(Color.NAVY, Color.INDIGO));
COLOR_SETS.add(new AuroraColor(Color.CYAN, Color.MAGENTA));
COLOR_SETS.add(new AuroraColor(Color.AURORA_GREEN, Color.AURORA_RED, Color.AURORA_BLUE));
// Warmer versions
COLOR_SETS.add(new AuroraColor(Color.YELLOW.luminance(WARMER).asImmutable(), Color.RED.luminance(WARMER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.GREEN.luminance(WARMER).asImmutable(), Color.RED.luminance(WARMER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.GREEN.luminance(WARMER).asImmutable(), Color.YELLOW.luminance(WARMER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.BLUE.luminance(WARMER).asImmutable(), Color.GREEN.luminance(WARMER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.INDIGO.luminance(WARMER).asImmutable(), Color.GREEN.luminance(WARMER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.AURORA_GREEN.luminance(WARMER).asImmutable(), Color.AURORA_RED.luminance(WARMER).asImmutable(), Color.AURORA_BLUE.luminance(WARMER).asImmutable()));
// Cooler versions
COLOR_SETS.add(new AuroraColor(Color.YELLOW.luminance(COOLER).asImmutable(), Color.RED.luminance(COOLER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.GREEN.luminance(COOLER).asImmutable(), Color.RED.luminance(COOLER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.GREEN.luminance(COOLER).asImmutable(), Color.YELLOW.luminance(COOLER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.BLUE.luminance(COOLER).asImmutable(), Color.GREEN.luminance(COOLER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.INDIGO.luminance(COOLER).asImmutable(), Color.GREEN.luminance(COOLER).asImmutable()));
COLOR_SETS.add(new AuroraColor(Color.AURORA_GREEN.luminance(COOLER).asImmutable(), Color.AURORA_RED.luminance(COOLER).asImmutable(), Color.AURORA_BLUE.luminance(COOLER).asImmutable()));
}
private AuroraColor(@Nonnull final Color base, @Nonnull final Color fade) {
this(base, fade, base);
}
private AuroraColor(@Nonnull final Color base, @Nonnull final Color fade, @Nonnull final Color mid) {
this.baseColor = base;
this.fadeColor = fade;
this.middleColor = mid;
}
@Nonnull
public static AuroraColor get(@Nonnull final Random random) {
final int idx = random.nextInt(COLOR_SETS.size());
return COLOR_SETS.get(idx);
}
public static int testId() {
return COLOR_SETS.size() - 1;
}
}
18
Source : AuroraClassic.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@Override
public void render(final float partialTick) {
final float alpha = getAlpha();
final Tessellator tess = Tessellator.getInstance();
final BufferBuilder renderer = tess.getBuffer();
final double tranY = getTranslationY(partialTick);
final double tranX = getTranslationX(partialTick);
final double tranZ = getTranslationZ(partialTick);
final Color base = getBaseColor();
final Color fade = getFadeColor();
final double zero = 0.0D;
final OpenGlState glState = OpenGlState.push();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.disableTexture2D();
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.disableAlpha();
GlStateManager.disableCull();
GlStateManager.depthMask(false);
this.band.translate(partialTick);
final Panel[] array = this.band.getNodeList();
for (int b = 0; b < this.bandCount; b++) {
GlStateManager.pushMatrix();
GlStateManager.translate(tranX, tranY, tranZ + this.offset * b);
GlStateManager.scale(0.5D, 8.0D, 0.5D);
renderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION_COLOR);
for (int i = 0; i < array.length - 1; i++) {
final Panel node = array[i];
final double posY = node.getModdedY();
final double posX = node.tetX;
final double posZ = node.tetZ;
final double tetX = node.tetX2;
final double tetZ = node.tetZ2;
final double posX2;
final double posZ2;
final double tetX2;
final double tetZ2;
final double posY2;
if (i < array.length - 2) {
final Panel nodePlus = array[i + 1];
posX2 = nodePlus.tetX;
posZ2 = nodePlus.tetZ;
tetX2 = nodePlus.tetX2;
tetZ2 = nodePlus.tetZ2;
posY2 = nodePlus.getModdedY();
} else {
posX2 = tetX2 = node.posX;
posZ2 = tetZ2 = node.getModdedZ();
posY2 = 0.0D;
}
// Front
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, posY, posZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
// Bottom
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
// Back
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, posY, tetZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
}
tess.draw();
GlStateManager.popMatrix();
}
OpenGlState.pop(glState);
}
17
Source : EntityHealthPopoffEffect.java
with MIT License
from OreCruncher
with MIT License
from OreCruncher
@Override
public void update(@Nonnull final Enreplacedy subject) {
if (!ModOptions.effects.enableDamagePopoffs)
return;
final EnreplacedyLivingBase enreplacedy = (EnreplacedyLivingBase) subject;
if (this.lastHealth != enreplacedy.getHealth()) {
final int adjustment = MathHelper.ceil(enreplacedy.getHealth() - this.lastHealth);
this.lastHealth = enreplacedy.getHealth();
// Don't display if it is the current player in first person view
if (!EnvironState.isPlayer(subject) || !isFirstPersonView()) {
final int delta = Math.max(1, MathStuff.abs(adjustment));
final int criticalAmount = (int) (enreplacedy.getMaxHealth() / 2.5F);
final AxisAlignedBB bb = enreplacedy.getEnreplacedyBoundingBox();
final double posX = enreplacedy.posX;
final double posY = bb.maxY + 0.5D;
final double posZ = enreplacedy.posZ;
final String text = String.valueOf(delta);
final Color color = adjustment > 0 ? HEAL_TEXT_COLOR : DAMAGE_TEXT_COLOR;
final World world = EnvironState.getWorld();
ParticleTextPopOff particle;
if (ModOptions.effects.showCritWords && adjustment < 0 && delta >= criticalAmount) {
particle = new ParticleTextPopOff(world, getPowerWord(), CRITICAL_TEXT_COLOR, posX, posY + 0.5D, posZ);
getState().addParticle(particle);
}
particle = new ParticleTextPopOff(world, text, color, posX, posY, posZ);
getState().addParticle(particle);
}
}
}