Eliminate uses of java.awt.Color since using awt with lwjgl3 is apparently bad now

This commit is contained in:
Vincent Lee committed 2020-01-23 22:32:42 -06:00
1 parent 42ee5d0d8d
commit 6a46558652
25 files changed
+155 -118

No files matched your search

@@ -89,9 +89,12 @@ public class TileEntityFunctionalFlower extends TileEntitySpecialFlower {
if(getWorld().isRemote) {
double particleChance = 1F - (double) mana / (double) getMaxMana() / 3.5F;
Color color = new Color(getColor());
int color = getColor();
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
if(Math.random() > particleChance)
BotaniaAPI.internalHandler.sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
BotaniaAPI.internalHandler.sparkleFX(getWorld(), getPos().getX() + 0.3 + Math.random() * 0.5, getPos().getY() + 0.5 + Math.random() * 0.5, getPos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
}
}
@@ -98,13 +98,17 @@ public class TileEntityGeneratingFlower extends TileEntitySpecialFlower {
if(getWorld().isRemote) {
double particleChance = 1F - (double) getMana() / (double) getMaxMana() / 3.5F;
Color color = new Color(getColor());
int color = getColor();
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
if(Math.random() > particleChance) {
Vec3d offset = getWorld().getBlockState(getPos()).getOffset(getWorld(), getPos());
double x = getPos().getX() + offset.x;
double y = getPos().getY() + offset.y;
double z = getPos().getZ() + offset.z;
BotaniaAPI.internalHandler.sparkleFX(getWorld(), x + 0.3 + Math.random() * 0.5, y + 0.5 + Math.random() * 0.5, z + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
BotaniaAPI.internalHandler.sparkleFX(getWorld(), x + 0.3 + Math.random() * 0.5, y + 0.5 + Math.random() * 0.5, z + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
}
}
@@ -26,6 +26,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderWorldLastEvent;
@@ -44,7 +45,6 @@ import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nullable;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@@ -95,7 +95,7 @@ public final class BlockHighlightRenderHandler {
int r = (int) (105 * gs);
int g = (int) (25 * gs);
int b = (int) (145 * gs);
Color color = new Color(r, g, b);
int color = r << 16 | g << 8 | b;
int alpha = 32;
if(e.ticksExisted < 8)
@@ -111,7 +111,7 @@ public final class BlockHighlightRenderHandler {
buffers.draw();
}
private static void renderRectangle(MatrixStack ms, IRenderTypeBuffer buffers, AxisAlignedBB aabb, boolean inner, @Nullable Color color, byte alpha) {
private static void renderRectangle(MatrixStack ms, IRenderTypeBuffer buffers, AxisAlignedBB aabb, boolean inner, @Nullable Integer color, byte alpha) {
double renderPosX = Minecraft.getInstance().getRenderManager().info.getProjectedView().getX();
double renderPosY = Minecraft.getInstance().getRenderManager().info.getProjectedView().getY();
double renderPosZ = Minecraft.getInstance().getRenderManager().info.getProjectedView().getZ();
@@ -120,7 +120,10 @@ public final class BlockHighlightRenderHandler {
ms.translate(aabb.minX - renderPosX, aabb.minY - renderPosY, aabb.minZ - renderPosZ);
if(color == null)
color = Color.getHSBColor(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
color = MathHelper.hsvToRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
int r = (color >> 16 & 0xFF);
int g = (color >> 8 & 0xFF);
int b = (color & 0xFF);
float f = 1F / 16F;
float x = (float) (aabb.maxX - aabb.minX - f);
@@ -128,20 +131,20 @@ public final class BlockHighlightRenderHandler {
IVertexBuilder buffer = buffers.getBuffer(RenderHelper.RECTANGLE);
Matrix4f mat = ms.peek().getModel();
buffer.vertex(mat, x, f, f).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, f, f, f).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, f, f, z).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, x, f, z).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, x, f, f).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, f, f, f).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, f, f, z).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, x, f, z).color(r, g, b, alpha).endVertex();
if(inner) {
x += f;
z += f;
float f1 = f + f / 4F;
alpha *= 2;
buffer.vertex(mat, x, f1, 0).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, 0, f1, 0).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, 0, f1, z).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, x, f1, z).color(color.getRed(), color.getGreen(), color.getBlue(), alpha).endVertex();
buffer.vertex(mat, x, f1, 0).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, 0, f1, 0).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, 0, f1, z).color(r, g, b, alpha).endVertex();
buffer.vertex(mat, x, f1, z).color(r, g, b, alpha).endVertex();
}
ms.pop();
@@ -157,8 +160,10 @@ public final class BlockHighlightRenderHandler {
double y = center.getY();
double z = center.getZ() + 0.5;
ms.translate(x - renderPosX, y - renderPosY, z - renderPosZ);
int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
Color colorRGB = new Color(color);
int color = MathHelper.hsvToRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
int r = (color >> 16 & 0xFF);
int g = (color >> 8 & 0xFF);
int b = (color & 0xFF);
int alpha = 32;
float f = 1F / 16F;
@@ -171,13 +176,13 @@ public final class BlockHighlightRenderHandler {
IVertexBuilder buffer = buffers.getBuffer(RenderHelper.CIRCLE);
Matrix4f mat = ms.peek().getModel();
Runnable centerFunc = () -> buffer.vertex(mat, 0, f, 0).color(colorRGB.getRed(), colorRGB.getGreen(), colorRGB.getBlue(), alpha).endVertex();
Runnable centerFunc = () -> buffer.vertex(mat, 0, f, 0).color(r, g, b, alpha).endVertex();
List<Runnable> vertexFuncs = new ArrayList<>();
for(int i = 0; i < totalAngles + 1; i += step) {
double rad = (totalAngles - i) * Math.PI / 180.0;
float xp = (float) (Math.cos(rad) * radius);
float zp = (float) (Math.sin(rad) * radius);
vertexFuncs.add(() -> buffer.vertex(mat, xp, f, zp).color(colorRGB.getRed(), colorRGB.getGreen(), colorRGB.getBlue(), alpha).endVertex());
vertexFuncs.add(() -> buffer.vertex(mat, xp, f, zp).color(r, g, b, alpha).endVertex());
}
RenderHelper.triangleFan(centerFunc, vertexFuncs);
@@ -185,13 +190,13 @@ public final class BlockHighlightRenderHandler {
float f1 = f + f / 4F;
int alpha2 = 64;
centerFunc = () -> buffer.vertex(mat, 0, f1, 0).color(colorRGB.getRed(), colorRGB.getGreen(), colorRGB.getBlue(), alpha2).endVertex();
centerFunc = () -> buffer.vertex(mat, 0, f1, 0).color(r, g, b, alpha2).endVertex();
vertexFuncs.clear();
for(int i = 0; i < totalAngles + 1; i += step) {
double rad = (totalAngles - i) * Math.PI / 180.0;
float xp = (float) (Math.cos(rad) * radius);
float zp = (float) (Math.sin(rad) * radius);
vertexFuncs.add(() -> buffer.vertex(mat, xp, f1, zp).color(colorRGB.getRed(), colorRGB.getGreen(), colorRGB.getBlue(), alpha2).endVertex());
vertexFuncs.add(() -> buffer.vertex(mat, xp, f1, zp).color(r, g, b, alpha2).endVertex());
}
RenderHelper.triangleFan(centerFunc, vertexFuncs);
ms.pop();
@@ -28,6 +28,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Util;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -49,7 +50,6 @@ import vazkii.botania.client.core.helper.RenderHelper;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.lib.LibMisc;
import java.awt.*;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.List;
@@ -76,7 +76,7 @@ public final class BoundTileRenderer {
ms.push();
PlayerEntity player = Minecraft.getInstance().player;
int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
int color = MathHelper.hsvToRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);
if(!player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) {
BlockPos coords = ((ICoordBoundItem) player.getHeldItemMainhand().getItem()).getBinding(player.getHeldItemMainhand());
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.FoliageColors;
import net.minecraft.world.biome.BiomeColors;
import vazkii.botania.api.BotaniaAPI;
@@ -36,8 +37,6 @@ import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
import vazkii.botania.common.item.lens.ItemLens;
import vazkii.botania.common.item.material.ItemPetal;
import java.awt.*;
public final class ColorHandler {
public static void init() {
@@ -52,7 +51,7 @@ public final class ColorHandler {
(state, world, pos, tintIndex) -> {
if (((BlockPool) state.getBlock()).variant == BlockPool.Variant.FABULOUS) {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB(time * 0.005F, 0.6F, 1F);
return MathHelper.hsvToRGB(time * 0.005F, 0.6F, 1F);
} else {
if(world != null && pos != null) {
TileEntity te = world.getTileEntity(pos);
@@ -70,7 +69,7 @@ public final class ColorHandler {
blocks.register(
(state, world, pos, tintIndex) -> {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
return Color.HSBtoRGB(time * 5 % 360 / 360F, 0.4F, 0.9F);
return MathHelper.hsvToRGB(time * 5 % 360 / 360F, 0.4F, 0.9F);
},
ModBlocks.gaiaSpreader
);
@@ -102,7 +101,7 @@ public final class ColorHandler {
ItemColors items = Minecraft.getInstance().getItemColors();
items.register((s, t) -> Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F),
items.register((s, t) -> MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 0.25F, 1F),
ModItems.lifeEssence, ModItems.gaiaIngot);
items.register((s, t) ->
@@ -125,11 +124,11 @@ public final class ColorHandler {
ModBlocks.petalBlockBrown, ModBlocks.petalBlockGreen, ModBlocks.petalBlockRed, ModBlocks.petalBlockBlack,
ModBlocks.manaPool, ModBlocks.creativePool, ModBlocks.dilutedPool, ModBlocks.fabulousPool, ModBlocks.gaiaSpreader);
items.register((s, t) -> t == 1 ? Color.HSBtoRGB(0.528F, (float) ((ItemManaMirror) ModItems.manaMirror).getMana(s) / (float) TilePool.MAX_MANA, 1F) : -1, ModItems.manaMirror);
items.register((s, t) -> t == 1 ? MathHelper.hsvToRGB(0.528F, (float) ((ItemManaMirror) ModItems.manaMirror).getMana(s) / (float) TilePool.MAX_MANA, 1F) : -1, ModItems.manaMirror);
items.register((s, t) -> t == 1 ? Color.HSBtoRGB(0.528F, (float) ((ItemManaTablet) ModItems.manaTablet).getMana(s) / (float) ItemManaTablet.MAX_MANA, 1F) : -1, ModItems.manaTablet);
items.register((s, t) -> t == 1 ? MathHelper.hsvToRGB(0.528F, (float) ((ItemManaTablet) ModItems.manaTablet).getMana(s) / (float) ItemManaTablet.MAX_MANA, 1F) : -1, ModItems.manaTablet);
items.register((s, t) -> Color.HSBtoRGB(0.55F, ((float) s.getMaxDamage() - (float) s.getDamage()) / (float)s.getMaxDamage() * 0.5F, 1F), ModItems.spellCloth);
items.register((s, t) -> MathHelper.hsvToRGB(0.55F, ((float) s.getMaxDamage() - (float) s.getDamage()) / (float)s.getMaxDamage() * 0.5F, 1F), ModItems.spellCloth);
items.register((s, t) -> {
if(t != 1)
@@ -139,13 +138,13 @@ public final class ColorHandler {
if(brew == BotaniaAPI.fallbackBrew)
return s.getItem() instanceof ItemBloodPendant ? 0xC6000E : 0x989898;
Color color = new Color(brew.getColor(s));
int color = brew.getColor(s);
double speed = s.getItem() == ModItems.brewFlask || s.getItem() == ModItems.brewVial ? 0.1 : 0.2;
int add = (int) (Math.sin(ClientTickHandler.ticksInGame * speed) * 24);
int r = Math.max(0, Math.min(255, color.getRed() + add));
int g = Math.max(0, Math.min(255, color.getGreen() + add));
int b = Math.max(0, Math.min(255, color.getBlue() + add));
int r = Math.max(0, Math.min(255, (color >> 16 & 0xFF) + add));
int g = Math.max(0, Math.min(255, (color >> 8 & 0xFF) + add));
int b = Math.max(0, Math.min(255, (color & 0xFF) + add));
return r << 16 | g << 8 | b;
}, ModItems.bloodPendant, ModItems.incenseStick, ModItems.brewFlask, ModItems.brewVial);
@@ -157,18 +156,25 @@ public final class ColorHandler {
if(t == 2) {
BurstProperties props = ((ItemManaGun) s.getItem()).getBurstProps(Minecraft.getInstance().player, s, false, Hand.MAIN_HAND);
Color color = new Color(props.color);
float mul = (float) (Math.sin((double) ClientTickHandler.ticksInGame / 5) * 0.15F);
int c = (int) (255 * mul);
return new Color(Math.max(0, Math.min(255, color.getRed() + c)), Math.max(0, Math.min(255, color.getGreen() + c)), Math.max(0, Math.min(255, color.getBlue() + c))).getRGB();
int r = (props.color >> 16 & 0xFF) + c;
int g = (props.color >> 8 & 0xFF) + c;
int b = (props.color & 0xFF) + c;
int cr = MathHelper.clamp(r, 0, 255);
int cg = MathHelper.clamp(g, 0, 255);
int cb = MathHelper.clamp(b, 0, 255);
return cr << 16 | cg << 8 | cb;
} else return -1;
}, ModItems.manaGun);
items.register((s, t) -> t == 1 ? Color.HSBtoRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(Util.milliTime() / 100D) * 0.5 + 1.2F)) : -1, ModItems.enderDagger);
items.register((s, t) -> t == 1 ? MathHelper.hsvToRGB(0.75F, 1F, 1.5F - (float) Math.min(1F, Math.sin(Util.milliTime() / 100D) * 0.5 + 1.2F)) : -1, ModItems.enderDagger);
items.register((s, t) -> t == 1 && ItemTerraPick.isEnabled(s) ? Color.HSBtoRGB(0.375F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F) : -1, ModItems.terraPick);
items.register((s, t) -> t == 1 && ItemTerraPick.isEnabled(s) ? MathHelper.hsvToRGB(0.375F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F) : -1, ModItems.terraPick);
dyeHandler = (s, t) -> t == 0 ? ((ItemLens) s.getItem()).getLensColor(s) : -1;
items.register(dyeHandler, ModItems.lensNormal, ModItems.lensSpeed, ModItems.lensPower, ModItems.lensTime, ModItems.lensEfficiency, ModItems.lensBounce,
@@ -27,6 +27,7 @@ import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
@@ -278,8 +279,11 @@ public final class HUDHandler {
else return;
}
Color color = new Color(Color.HSBtoRGB(0.55F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F));
RenderSystem.color4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1 - (color.getRed() / 255F));
int color = MathHelper.hsvToRGB(0.55F, (float) Math.min(1F, Math.sin(Util.milliTime() / 200D) * 0.5 + 1F), 1F);
int r = (color >> 16 & 0xFF);
int g = (color >> 8 & 0xFF);
int b = color & 0xFF;
RenderSystem.color4f(r / 255F, g / 255F, b / 255F, 1 - (r / 255F));
mc.textureManager.bindTexture(manaBar);
RenderSystem.enableBlend();
@@ -426,8 +430,10 @@ public final class HUDHandler {
RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, 100, 3);
Color color_ = new Color(color);
RenderSystem.color4f(color_.getRed() / 255F, color_.getGreen() / 255F, color_.getBlue() / 255F, alpha);
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
RenderSystem.color4f(red, green, blue, alpha);
RenderHelper.drawTexturedModalRect(x + 1, y + 1, 0, 0, 5, Math.min(100, manaPercentage), 3);
RenderSystem.color4f(1, 1, 1, 1);
}
@@ -16,6 +16,7 @@ import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RenderTooltipEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -25,8 +26,6 @@ import vazkii.botania.api.mana.IManaTooltipDisplay;
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
import vazkii.botania.common.lib.LibMisc;
import java.awt.*;
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID)
public final class TooltipAdditionDisplayHandler {
@@ -61,7 +60,7 @@ public final class TooltipAdditionDisplayHandler {
RenderSystem.disableDepthTest();
AbstractGui.fill(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
for(int i = 0; i < rainbowWidth; i++)
AbstractGui.fill(mouseX + i, mouseY - height, mouseX + i + 1, mouseY, Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F));
AbstractGui.fill(mouseX + i, mouseY - height, mouseX + i + 1, mouseY, MathHelper.hsvToRGB(hueOff + huePer * i, 1F, 1F));
AbstractGui.fill(mouseX + rainbowWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
String rank = I18n.format("botania.rank" + level).replaceAll("&", "\u00a7");
@@ -84,7 +83,7 @@ public final class TooltipAdditionDisplayHandler {
RenderSystem.disableDepthTest();
AbstractGui.fill(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
AbstractGui.fill(mouseX, mouseY - height, mouseX + manaBarWidth, mouseY, Color.HSBtoRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F));
AbstractGui.fill(mouseX, mouseY - height, mouseX + manaBarWidth, mouseY, MathHelper.hsvToRGB(0.528F, ((float) Math.sin((ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.2) + 1F) * 0.3F + 0.4F, 1F));
AbstractGui.fill(mouseX + manaBarWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);
}
@@ -23,6 +23,7 @@ import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.math.MathHelper;
import vazkii.botania.api.mana.IPoolOverlayProvider;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
@@ -32,7 +33,6 @@ import vazkii.botania.common.block.mana.BlockPool;
import vazkii.botania.common.block.tile.mana.TilePool;
import javax.annotation.Nullable;
import java.awt.*;
import java.util.Random;
public class RenderTilePool extends TileEntityRenderer<TilePool> {
@@ -57,7 +57,7 @@ public class RenderTilePool extends TileEntityRenderer<TilePool> {
if (fab) {
float time = ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks;
time += new Random(pool.getPos().getX() ^ pool.getPos().getY() ^ pool.getPos().getZ()).nextInt(100000);
int color = Color.HSBtoRGB(time * 0.005F, 0.6F, 1F);
int color = MathHelper.hsvToRGB(time * 0.005F, 0.6F, 1F);
int red = (color & 0xFF0000) >> 16;
int green = (color & 0xFF00) >> 8;
@@ -25,6 +25,7 @@ import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import vazkii.botania.api.ColorHelper;
import vazkii.botania.client.core.handler.ClientTickHandler;
import vazkii.botania.client.core.proxy.ClientProxy;
@@ -33,7 +34,6 @@ import vazkii.botania.client.model.ModelSpreader;
import vazkii.botania.common.block.tile.mana.TileSpreader;
import javax.annotation.Nonnull;
import java.awt.*;
import java.util.Random;
public class RenderTileSpreader extends TileEntityRenderer<TileSpreader> {
@@ -74,10 +74,10 @@ public class RenderTileSpreader extends TileEntityRenderer<TileSpreader> {
float r = 1, g = 1, b = 1;
if(spreader.isULTRA_SPREADER()) {
Color color = Color.getHSBColor((float) ((time * 5 + new Random(spreader.getPos().hashCode()).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F);
r = color.getRed() / 255F;
g = color.getGreen() / 255F;
b = color.getBlue() / 255F;
int color = MathHelper.hsvToRGB((float) ((time * 5 + new Random(spreader.getPos().hashCode()).nextInt(10000)) % 360) / 360F, 0.4F, 0.9F);
r = (color >> 16 & 0xFF) / 255F;
g = (color >> 8 & 0xFF) / 255F;
b = (color & 0xFF) / 255F;
}
IVertexBuilder buffer = buffers.getBuffer(model.getLayer(texture));
model.render(ms, buffer, light, overlay, r, g, b, 1);
@@ -27,10 +27,10 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import vazkii.botania.common.block.tile.TileStarfield;
import java.awt.Color;
import java.nio.FloatBuffer;
import java.util.List;
import java.util.Random;
@@ -66,10 +66,10 @@ public class RenderTileStarfield extends TileEntityRenderer<TileStarfield> {
float f2 = (RANDOM.nextFloat() * 0.5F + 0.5F) * p_228883_3_;
// Botania: change color based on time
Color color = Color.getHSBColor(Util.milliTime() / 20F % 360 / 360F, 1F, 1F);
f = color.getRed() / 255F * p_228883_3_;
f1 = color.getGreen() / 255F * p_228883_3_;
f2 = color.getBlue() / 255F * p_228883_3_;
int color = MathHelper.hsvToRGB(Util.milliTime() / 20F % 360 / 360F, 1F, 1F);
f = (color >> 16 & 0xFF) / 255F * p_228883_3_;
f1 = (color >> 8 & 0xFF) / 255F * p_228883_3_;
f2 = (color & 0xFF) / 255F * p_228883_3_;
this.func_228884_a_(p_228883_1_, p_228883_4_, p_228883_5_, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, f, f1, f2, Direction.SOUTH);
this.func_228884_a_(p_228883_1_, p_228883_4_, p_228883_5_, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, f, f1, f2, Direction.NORTH);
@@ -45,8 +45,11 @@ public class BergamuteEventHandler {
evt.setResultSound(new WrappedSound(sound, MULTIPLIER));
if (RAND.nextBoolean()) {
Color color = TilePool.PARTICLE_COLOR;
BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, (float) Math.random(), 5);
int color = TilePool.PARTICLE_COLOR;
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
BotaniaAPI.internalHandler.sparkleFX(berg.getWorld(), berg.getEffectivePos().getX() + 0.3 + Math.random() * 0.5, berg.getEffectivePos().getY() + 0.5 + Math.random() * 0.5, berg.getEffectivePos().getZ() + 0.3 + Math.random() * 0.5, red, green, blue, (float) Math.random(), 5);
}
}
}
@@ -27,6 +27,7 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.api.distmarker.Dist;
@@ -39,7 +40,6 @@ import vazkii.botania.api.subtile.TileEntityGeneratingFlower;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.lib.LibMisc;
import java.awt.*;
import java.util.List;
import java.util.function.Predicate;
@@ -126,7 +126,7 @@ public class SubTileSpectrolus extends TileEntityGeneratingFlower {
@Override
public int getColor() {
return Color.HSBtoRGB(ticksExisted / 100F, 1F, 1F);
return MathHelper.hsvToRGB(ticksExisted / 100F, 1F, 1F);
}
@OnlyIn(Dist.CLIENT)
@@ -272,10 +272,11 @@ public class TileAltar extends TileSimpleInventory implements IPetalApothecary,
if(Math.random() >= 0.97) {
ICustomApothecaryColor comp = getFlowerComponent(stackAt);
Color color = new Color(comp == null ? 0x888888 : comp.getParticleColor(stackAt));
float red = color.getRed() / 255F;
float green = color.getGreen() / 255F;
float blue = color.getBlue() / 255F;
int color = comp == null ? 0x888888 : comp.getParticleColor(stackAt);
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
if(Math.random() >= 0.75F)
world.playSound(null, pos, SoundEvents.ENTITY_GENERIC_SPLASH, SoundCategory.BLOCKS, 0.1F, 10F);
SparkleParticleData data = SparkleParticleData.sparkle((float) Math.random(), red, green, blue, 10);
@@ -124,10 +124,10 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
if(recipe != null) {
if(mana != manaLastTick) {
Color color = new Color(recipe.getBrew().getColor(itemHandler.getStackInSlot(0)));
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = recipe.getBrew().getColor(itemHandler.getStackInSlot(0));
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
for(int i = 0; i < 5; i++) {
WispParticleData data1 = WispParticleData.wisp(0.1F + (float) Math.random() * 0.05F, r, g, b);
world.addParticle(data1, pos.getX() + 0.7 - Math.random() * 0.4, pos.getY() + 0.9 - Math.random() * 0.2, pos.getZ() + 0.7 - Math.random() * 0.4, 0.03F - (float) Math.random() * 0.06F, 0.03F + (float) Math.random() * 0.015F, 0.03F - (float) Math.random() * 0.06F);
@@ -170,10 +170,9 @@ public class TileBrewery extends TileSimpleInventory implements IManaReceiver, I
if(event == CRAFT_EFFECT_EVENT) {
if(world.isRemote) {
for(int i = 0; i < 25; i++) {
Color c = new Color(param);
float r = c.getRed() / 255F;
float g = c.getGreen() / 255F;
float b = c.getBlue() / 255F;
float r = (param >> 16 & 0xFF) / 255F;
float g = (param >> 8 & 0xFF) / 255F;
float b = (param & 0xFF) / 255F;
SparkleParticleData data1 = SparkleParticleData.sparkle((float) Math.random() * 2F + 0.5F, r, g, b, 10);
world.addParticle(data1, pos.getX() + 0.5 + Math.random() * 0.4 - 0.2, pos.getY() + 1, pos.getZ() + 0.5 + Math.random() * 0.4 - 0.2, 0, 0, 0);
for(int j = 0; j < 2; j++) {
@@ -74,10 +74,12 @@ public class TileIncensePlate extends TileSimpleInventory implements ITickableTi
double x = pos.getX() + 0.5;
double y = pos.getY() + 0.5;
double z = pos.getZ() + 0.5;
Color color = new Color(brew.getColor(stack));
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = brew.getColor(stack);
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
WispParticleData data1 = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, r, g, b);
world.addParticle(data1, x - (Math.random() - 0.5) * 0.2, y - (Math.random() - 0.5) * 0.2, z - (Math.random() - 0.5) * 0.2, 0.005F - (float) Math.random() * 0.01F, 0.01F + (float) Math.random() * 0.005F, 0.005F - (float) Math.random() * 0.01F);
WispParticleData data = WispParticleData.wisp(0.05F + (float) Math.random() * 0.02F, 0.2F, 0.2F, 0.2F);
@@ -32,6 +32,7 @@ import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
import net.minecraftforge.registries.ObjectHolder;
@@ -48,7 +49,6 @@ import vazkii.botania.common.lib.LibBlockNames;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
@@ -311,17 +311,20 @@ public class TileLightRelay extends TileMod implements ITickableTileEntity, IWan
Vector3 thisVec = Vector3.fromEntity(this);
Vector3 motVec = thisVec.negate().add(exitPos.getX() + 0.5, exitPos.getY() + 0.5, exitPos.getZ() + 0.5).normalize().multiply(0.5);
Color color;
int color;
int count = 4;
for(int i = 0; i < count; i++) {
color = Color.getHSBColor(ticksExisted / 36F + 1F / count * i, 1F, 1F);
color = MathHelper.hsvToRGB(ticksExisted / 36F + 1F / count * i, 1F, 1F);
double rad = Math.PI * 2.0 / count * i + ticksExisted / Math.PI;
double cos = Math.cos(rad);
double sin = Math.sin(rad);
double s = 0.4;
SparkleParticleData data = SparkleParticleData.sparkle(1.2F, color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 10);
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
SparkleParticleData data = SparkleParticleData.sparkle(1.2F, r / 255F, g / 255F, b / 255F, 10);
world.addParticle(data, getX() + cos * s, getY() - 0.5, getZ() + sin * s, 0, 0, 0);
}
@@ -71,7 +71,7 @@ import java.util.List;
public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAttachable, IThrottledPacket, ITickableTileEntity {
@ObjectHolder(LibMisc.MOD_ID + ":" + LibBlockNames.POOL)
public static TileEntityType<TilePool> TYPE;
public static final Color PARTICLE_COLOR = new Color(0x00C6FF);
public static final int PARTICLE_COLOR = 0x00C6FF;
public static final int MAX_MANA = 1000000;
private static final int MAX_MANA_DILLUTED = 10000;
@@ -255,7 +255,10 @@ public class TilePool extends TileMod implements IManaPool, IKeyLocked, ISparkAt
if(world.isRemote) {
double particleChance = 1F - (double) getCurrentMana() / (double) manaCap * 0.1;
if(Math.random() > particleChance) {
WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, PARTICLE_COLOR.getRed() / 255F, PARTICLE_COLOR.getGreen() / 255F, PARTICLE_COLOR.getBlue() / 255F, 2F);
float red = (PARTICLE_COLOR >> 16 & 0xFF) / 255F;
float green = (PARTICLE_COLOR >> 8 & 0xFF) / 255F;
float blue = (PARTICLE_COLOR & 0xFF) / 255F;
WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, red, green, blue, 2F);
world.addParticle(data, pos.getX() + 0.3 + Math.random() * 0.5, pos.getY() + 0.6 + Math.random() * 0.25, pos.getZ() + Math.random(), 0, (float) Math.random() / 25F, 0);
}
return;
@@ -420,10 +420,10 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
if(lens != null && !lens.doParticles(this, getSourceLens()))
return;
Color color = new Color(getColor());
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = getColor();
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
float osize = getParticleSize();
float size = osize;
@@ -540,10 +540,10 @@ public class EntityManaBurst extends ThrowableEntity implements IManaBurst {
if(dead && isAlive()) {
if(!fake && world.isRemote) {
Color color = new Color(getColor());
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = getColor();
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
int mana = getMana();
int maxMana = getStartingMana();
@@ -122,12 +122,15 @@ public class EntityPoolMinecart extends AbstractMinecartEntity {
if(world.isRemote) {
double particleChance = 1F - (double) getMana() / (double) TilePool.MAX_MANA * 0.1;
Color color = TilePool.PARTICLE_COLOR;
int color = TilePool.PARTICLE_COLOR;
float red = (color >> 16 & 0xFF) / 255F;
float green = (color >> 8 & 0xFF) / 255F;
float blue = (color & 0xFF) / 255F;
double x = MathHelper.floor(getX());
double y = MathHelper.floor(getY());
double z = MathHelper.floor(getZ());
if(Math.random() > particleChance) {
WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, (float) color.getRed(), color.getGreen() / 255F, color.getBlue() / 255F, 2F);
WispParticleData data = WispParticleData.wisp((float) Math.random() / 3F, red, green, blue, 2F);
world.addParticle(data, x + 0.3 + Math.random() * 0.5, y + 0.85 + Math.random() * 0.25, z + Math.random(), 0, (float) Math.random() / 25F, 0);
}
}
@@ -38,6 +38,7 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.GlobalPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
@@ -67,7 +68,6 @@ import vazkii.botania.common.network.PacketBotaniaEffect;
import vazkii.botania.common.network.PacketHandler;
import javax.annotation.Nonnull;
import java.awt.*;
import java.util.List;
import java.util.Optional;
@@ -299,10 +299,10 @@ public class ItemTwigWand extends Item implements ICoordBoundItem {
Vector3 currentPos = orig;
for(int i = 0; i < iters; i++) {
float hue = i * huePer + hueSum;
Color color = Color.getHSBColor(hue, 1F, 1F);
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = MathHelper.hsvToRGB(hue, 1F, 1F);
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
SparkleParticleData data = SparkleParticleData.noClip(0.5F, r, g, b, 4);
world.addParticle(data, currentPos.x, currentPos.y, currentPos.z, 0, 0, 0);
@@ -133,10 +133,10 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre
.render(ms.peek(), buffer, null, model, 1, 1, 1, light, OverlayTexture.DEFAULT_UV);
model = MiscellaneousIcons.INSTANCE.bloodPendantGem;
Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1));
float r = color.getRed() / 255F;
float g = color.getGreen() / 255F;
float b = color.getBlue() / 255F;
int color = Minecraft.getInstance().getItemColors().getColor(stack, 1);
float r = (color >> 16 & 0xFF) / 255F;
float g = (color >> 8 & 0xFF) / 255F;
float b = (color & 0xFF) / 255F;
Minecraft.getInstance().getBlockRendererDispatcher().getBlockModelRenderer()
.render(ms.peek(), buffer, null, model, r, g, b, 0xF000F0, OverlayTexture.DEFAULT_UV);
}
@@ -16,6 +16,7 @@ import net.minecraft.item.DyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TranslationTextComponent;
@@ -36,7 +37,6 @@ import net.minecraft.item.Item;
import vazkii.botania.common.item.ModItems;
import javax.annotation.Nonnull;
import java.awt.*;
import java.util.List;
public class ItemLens extends Item implements ILensControl, ICompositableLens, ITinyPlanetExcempt {
@@ -128,7 +128,7 @@ public class ItemLens extends Item implements ILensControl, ICompositableLens, I
return 0xFFFFFF;
if(storedColor == 16)
return Color.HSBtoRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F);
return MathHelper.hsvToRGB(Botania.proxy.getWorldElapsedTicks() * 2 % 360 / 360F, 1F, 1F);
return DyeColor.byId(storedColor).colorValue;
}
@@ -17,8 +17,6 @@ import net.minecraft.util.math.MathHelper;
import vazkii.botania.api.mana.IManaSpreader;
import vazkii.botania.client.fx.WispParticleData;
import java.awt.*;
public class LensFlare extends Lens {
@Override
@@ -52,7 +50,7 @@ public class LensFlare extends Lens {
TileEntity tile = (TileEntity) spreader;
if(storedColor == 16) {
hex = Color.HSBtoRGB(tile.getWorld().getGameTime() * 2 % 360 / 360F, 1F, 1F);
hex = MathHelper.hsvToRGB(tile.getWorld().getGameTime() * 2 % 360 / 360F, 1F, 1F);
} else if(storedColor >= 0) {
hex = DyeColor.byId(storedColor).colorValue;
}
@@ -8,6 +8,7 @@ import net.minecraft.particles.ParticleTypes;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkEvent;
import vazkii.botania.client.fx.SparkleParticleData;
@@ -17,7 +18,6 @@ import vazkii.botania.common.core.helper.Vector3;
import vazkii.botania.common.entity.EntityDoppleganger;
import vazkii.botania.common.item.ItemTwigWand;
import java.awt.*;
import java.util.function.Supplier;
// Prefer using World.addBlockEvent/Block.eventReceived/TileEntity.receiveClientEvent where possible
@@ -135,10 +135,10 @@ public class PacketBotaniaEffect {
Vector3 currentPos = orig;
for(int i = 0; i < iters; i++) {
float hue = i * huePer + hueSum;
Color color = Color.getHSBColor(hue, 1F, 1F);
float r = Math.min(1F, color.getRed() / 255F + 0.4F);
float g = Math.min(1F, color.getGreen() / 255F + 0.4F);
float b = Math.min(1F, color.getBlue() / 255F + 0.4F);
int color = MathHelper.hsvToRGB(hue, 1F, 1F);
float r = Math.min(1F, (color >> 16 & 0xFF) / 255F + 0.4F);
float g = Math.min(1F, (color >> 8 & 0xFF) / 255F + 0.4F);
float b = Math.min(1F, (color & 0xFF) / 255F + 0.4F);
SparkleParticleData data = SparkleParticleData.noClip(1, r, g, b, 12);
world.addParticle(data, currentPos.x, currentPos.y, currentPos.z, 0, 0, 0);
@@ -43,8 +43,6 @@ import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.ToolCommons;
import vazkii.botania.common.lib.ModTags;
import java.awt.Color;
public final class SkyblockWorldEvents {
private SkyblockWorldEvents() {}
@@ -181,7 +179,11 @@ public final class SkyblockWorldEvents {
world.setBlockState(pos.add(-1 + i, -1 - j, -1 + k), j == 0 ? Blocks.GRASS_BLOCK.getDefaultState() : Blocks.DIRT.getDefaultState());
world.setBlockState(pos.add(-1, -2, 0), Blocks.WATER.getDefaultState());
world.setBlockState(pos.add(1, 2, 1), ModBlocks.manaFlame.getDefaultState());
((TileManaFlame) world.getTileEntity(pos.add(1, 2, 1))).setColor(new Color(70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185), 70 + world.rand.nextInt(185)).getRGB());
int r = 70 + world.rand.nextInt(185);
int g = 70 + world.rand.nextInt(185);
int b = 70 + world.rand.nextInt(185);
int color = r << 16 | g << 8 | b;
((TileManaFlame) world.getTileEntity(pos.add(1, 2, 1))).setColor(color);
int[][] rootPositions = new int[][] {
{ -1, -3, -1 },