mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Remove uses of java.awt (#5591)
`java.awt` will statically load itself when `java.awt.Color`, `java.awt.Dimension`, etc are loaded. This conflicts with lwjgl3 and must be avoided (except for in mojang's server gui).
This commit is contained in:
1 parent
5e7279b0a2
commit
5fa732d223
11 files changed
+83
-39
No files matched your search
@@ -21,7 +21,6 @@ package net.minecraftforge.client;
|
||||
|
||||
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -676,7 +675,7 @@ public class GuiIngameForge extends GuiIngame
|
||||
GlStateManager.translatef((float)(width / 2), (float)(height - 68), 0.0F);
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
int color = (animateOverlayMessageColor ? Color.HSBtoRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
|
||||
int color = (animateOverlayMessageColor ? MathHelper.hsvToRGB(hue / 50.0F, 0.7F, 0.6F) & WHITE : WHITE);
|
||||
fontrenderer.drawStringWithShadow(overlayMessage, -fontrenderer.getStringWidth(overlayMessage) / 2, -4, color | (opacity << 24));
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -25,7 +25,6 @@ import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
@@ -34,7 +33,7 @@ import java.io.File;
|
||||
* This event is {@link Cancelable}
|
||||
*
|
||||
* {@link #screenshotFile} contains the file the screenshot will be/was saved to
|
||||
* {@link #image} contains the {@link BufferedImage} that will be saved
|
||||
* {@link #image} contains the {@link NativeImage} that will be saved
|
||||
* {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead
|
||||
*/
|
||||
@Cancelable
|
||||
|
||||
@@ -19,9 +19,6 @@
|
||||
|
||||
package net.minecraftforge.client.model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2019.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation version 2.1
|
||||
* of the License.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.util;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import javax.annotation.Nonnegative;
|
||||
|
||||
public final class Size2i
|
||||
{
|
||||
@Nonnegative
|
||||
public final int width;
|
||||
@Nonnegative
|
||||
public final int height;
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public Size2i(@Nonnegative int width, @Nonnegative int height)
|
||||
{
|
||||
Preconditions.checkArgument(width >= 0, "width must be greater or equal 0");
|
||||
Preconditions.checkArgument(height >= 0, "height must be greater or equal 0");
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj instanceof Size2i)
|
||||
{
|
||||
Size2i other = (Size2i)obj;
|
||||
return (width == other.width) && (height == other.height);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
int hash = 17;
|
||||
hash = hash * 31 + width;
|
||||
hash = hash * 31 + height;
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("width", width)
|
||||
.add("height", height)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,6 @@ import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -142,17 +141,6 @@ public class Fluid
|
||||
*/
|
||||
protected int color = 0xFFFFFFFF;
|
||||
|
||||
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, Color color)
|
||||
{
|
||||
this(fluidName, still, flowing, null, color);
|
||||
}
|
||||
|
||||
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, @Nullable ResourceLocation overlay, Color color)
|
||||
{
|
||||
this(fluidName, still, flowing, overlay);
|
||||
this.setColor(color);
|
||||
}
|
||||
|
||||
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, int color)
|
||||
{
|
||||
this(fluidName, still, flowing, null, color);
|
||||
@@ -246,12 +234,6 @@ public class Fluid
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fluid setColor(Color color)
|
||||
{
|
||||
this.color = color.getRGB();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Fluid setColor(int color)
|
||||
{
|
||||
this.color = color;
|
||||
|
||||
@@ -24,7 +24,6 @@ import static net.minecraftforge.fml.Logging.fmlLog;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL12.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
package net.minecraftforge.fml.client.gui;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.File;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@@ -21,7 +21,6 @@ package net.minecraftforge.fml.client.gui;
|
||||
|
||||
import static net.minecraft.util.StringUtils.stripControlCodes;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@@ -58,6 +57,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.util.Size2i;
|
||||
import net.minecraftforge.fml.ForgeI18n;
|
||||
import net.minecraftforge.fml.MavenVersionStringHelper;
|
||||
import net.minecraftforge.fml.ModContainer;
|
||||
@@ -184,10 +184,10 @@ public class GuiModList extends GuiScreen
|
||||
class Info extends GuiListExtended.IGuiListEntry<Info>
|
||||
{
|
||||
private ResourceLocation logoPath;
|
||||
private Dimension logoDims;
|
||||
private Size2i logoDims;
|
||||
private List<ITextComponent> lines;
|
||||
|
||||
public Info(GuiListExtended<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Dimension logoDims)
|
||||
public Info(GuiListExtended<Info> parent, List<String> lines, @Nullable ResourceLocation logoPath, Size2i logoDims)
|
||||
{
|
||||
this.list = parent;
|
||||
this.lines = resizeContent(lines);
|
||||
@@ -439,7 +439,7 @@ public class GuiModList extends GuiScreen
|
||||
List<String> lines = new ArrayList<>();
|
||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod);
|
||||
|
||||
Pair<ResourceLocation, Dimension> logoData = selectedMod.getLogoFile().map(logoFile->
|
||||
Pair<ResourceLocation, Size2i> logoData = selectedMod.getLogoFile().map(logoFile->
|
||||
{
|
||||
TextureManager tm = mc.getTextureManager();
|
||||
final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId())
|
||||
@@ -453,12 +453,12 @@ public class GuiModList extends GuiScreen
|
||||
logo = NativeImage.read(logoResource);
|
||||
if (logo != null)
|
||||
{
|
||||
return Pair.of(tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo)), new Dimension(logo.getWidth(), logo.getHeight()));
|
||||
return Pair.of(tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo)), new Size2i(logo.getWidth(), logo.getHeight()));
|
||||
}
|
||||
}
|
||||
catch (IOException e) { }
|
||||
return Pair.<ResourceLocation, Dimension>of(null, new Dimension(0, 0));
|
||||
}).orElse(Pair.of(null, new Dimension(0, 0)));
|
||||
return Pair.<ResourceLocation, Size2i>of(null, new Size2i(0, 0));
|
||||
}).orElse(Pair.of(null, new Size2i(0, 0)));
|
||||
|
||||
lines.add(selectedMod.getDisplayName());
|
||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.version", MavenVersionStringHelper.artifactVersionToString(selectedMod.getVersion())));
|
||||
|
||||
Reference in new issue
Block a user