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:
parent
5e7279b0a2
commit
5fa732d223
11 changed files with 83 additions and 39 deletions
|
@ -21,7 +21,6 @@ package net.minecraftforge.client;
|
||||||
|
|
||||||
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
|
import static net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.*;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -676,7 +675,7 @@ public class GuiIngameForge extends GuiIngame
|
||||||
GlStateManager.translatef((float)(width / 2), (float)(height - 68), 0.0F);
|
GlStateManager.translatef((float)(width / 2), (float)(height - 68), 0.0F);
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
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));
|
fontrenderer.drawStringWithShadow(overlayMessage, -fontrenderer.getStringWidth(overlayMessage) / 2, -4, color | (opacity << 24));
|
||||||
GlStateManager.disableBlend();
|
GlStateManager.disableBlend();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
|
|
|
@ -25,7 +25,6 @@ import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraftforge.eventbus.api.Cancelable;
|
import net.minecraftforge.eventbus.api.Cancelable;
|
||||||
import net.minecraftforge.eventbus.api.Event;
|
import net.minecraftforge.eventbus.api.Event;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +33,7 @@ import java.io.File;
|
||||||
* This event is {@link Cancelable}
|
* This event is {@link Cancelable}
|
||||||
*
|
*
|
||||||
* {@link #screenshotFile} contains the file the screenshot will be/was saved to
|
* {@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
|
* {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead
|
||||||
*/
|
*/
|
||||||
@Cancelable
|
@Cancelable
|
||||||
|
|
|
@ -19,9 +19,6 @@
|
||||||
|
|
||||||
package net.minecraftforge.client.model;
|
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.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
71
src/main/java/net/minecraftforge/common/util/Size2i.java
Normal file
71
src/main/java/net/minecraftforge/common/util/Size2i.java
Normal file
|
@ -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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -142,17 +141,6 @@ public class Fluid
|
||||||
*/
|
*/
|
||||||
protected int color = 0xFFFFFFFF;
|
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)
|
public Fluid(String fluidName, ResourceLocation still, ResourceLocation flowing, int color)
|
||||||
{
|
{
|
||||||
this(fluidName, still, flowing, null, color);
|
this(fluidName, still, flowing, null, color);
|
||||||
|
@ -246,12 +234,6 @@ public class Fluid
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Fluid setColor(Color color)
|
|
||||||
{
|
|
||||||
this.color = color.getRGB();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Fluid setColor(int color)
|
public Fluid setColor(int color)
|
||||||
{
|
{
|
||||||
this.color = 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.GL11.*;
|
||||||
import static org.lwjgl.opengl.GL12.*;
|
import static org.lwjgl.opengl.GL12.*;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package net.minecraftforge.fml.client.gui;
|
package net.minecraftforge.fml.client.gui;
|
||||||
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import net.minecraft.client.gui.GuiButton;
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
|
|
@ -21,7 +21,6 @@ package net.minecraftforge.fml.client.gui;
|
||||||
|
|
||||||
import static net.minecraft.util.StringUtils.stripControlCodes;
|
import static net.minecraft.util.StringUtils.stripControlCodes;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -58,6 +57,7 @@ import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.text.ITextComponent;
|
import net.minecraft.util.text.ITextComponent;
|
||||||
import net.minecraft.util.text.TextComponentString;
|
import net.minecraft.util.text.TextComponentString;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.common.util.Size2i;
|
||||||
import net.minecraftforge.fml.ForgeI18n;
|
import net.minecraftforge.fml.ForgeI18n;
|
||||||
import net.minecraftforge.fml.MavenVersionStringHelper;
|
import net.minecraftforge.fml.MavenVersionStringHelper;
|
||||||
import net.minecraftforge.fml.ModContainer;
|
import net.minecraftforge.fml.ModContainer;
|
||||||
|
@ -184,10 +184,10 @@ public class GuiModList extends GuiScreen
|
||||||
class Info extends GuiListExtended.IGuiListEntry<Info>
|
class Info extends GuiListExtended.IGuiListEntry<Info>
|
||||||
{
|
{
|
||||||
private ResourceLocation logoPath;
|
private ResourceLocation logoPath;
|
||||||
private Dimension logoDims;
|
private Size2i logoDims;
|
||||||
private List<ITextComponent> lines;
|
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.list = parent;
|
||||||
this.lines = resizeContent(lines);
|
this.lines = resizeContent(lines);
|
||||||
|
@ -439,7 +439,7 @@ public class GuiModList extends GuiScreen
|
||||||
List<String> lines = new ArrayList<>();
|
List<String> lines = new ArrayList<>();
|
||||||
VersionChecker.CheckResult vercheck = VersionChecker.getResult(selectedMod);
|
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();
|
TextureManager tm = mc.getTextureManager();
|
||||||
final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId())
|
final ModFileResourcePack resourcePack = ResourcePackLoader.getResourcePackFor(selectedMod.getModId())
|
||||||
|
@ -453,12 +453,12 @@ public class GuiModList extends GuiScreen
|
||||||
logo = NativeImage.read(logoResource);
|
logo = NativeImage.read(logoResource);
|
||||||
if (logo != null)
|
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) { }
|
catch (IOException e) { }
|
||||||
return Pair.<ResourceLocation, Dimension>of(null, new Dimension(0, 0));
|
return Pair.<ResourceLocation, Size2i>of(null, new Size2i(0, 0));
|
||||||
}).orElse(Pair.of(null, new Dimension(0, 0)));
|
}).orElse(Pair.of(null, new Size2i(0, 0)));
|
||||||
|
|
||||||
lines.add(selectedMod.getDisplayName());
|
lines.add(selectedMod.getDisplayName());
|
||||||
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.version", MavenVersionStringHelper.artifactVersionToString(selectedMod.getVersion())));
|
lines.add(ForgeI18n.parseMessage("fml.menu.mods.info.version", MavenVersionStringHelper.artifactVersionToString(selectedMod.getVersion())));
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
package net.minecraftforge.debug.fluid;
|
package net.minecraftforge.debug.fluid;
|
||||||
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
@ -41,7 +39,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry.ObjectHolder;
|
||||||
public class ColoredFluidTest
|
public class ColoredFluidTest
|
||||||
{
|
{
|
||||||
static final boolean ENABLED = false; // <-- enable mod
|
static final boolean ENABLED = false; // <-- enable mod
|
||||||
static final Color COLOR = Color.PINK; // <-- change this to try other colors
|
static final int COLOR = 0xFFAFAF; // <-- change this to try other colors
|
||||||
|
|
||||||
static final String MODID = "fluidadditionalfields";
|
static final String MODID = "fluidadditionalfields";
|
||||||
static final ResourceLocation RES_LOC = new ResourceLocation(MODID, "slime");
|
static final ResourceLocation RES_LOC = new ResourceLocation(MODID, "slime");
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package net.minecraftforge.debug.gameplay;
|
package net.minecraftforge.debug.gameplay;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
@ -44,6 +43,7 @@ import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
// TODO 1.13: implement without java.awt
|
||||||
@Mod(modid = DynamicBannerTest.MODID, name = "ForgeDebugDynamicBanner", version = DynamicBannerTest.VERSION, acceptableRemoteVersions = "*")
|
@Mod(modid = DynamicBannerTest.MODID, name = "ForgeDebugDynamicBanner", version = DynamicBannerTest.VERSION, acceptableRemoteVersions = "*")
|
||||||
public class DynamicBannerTest
|
public class DynamicBannerTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,11 +31,11 @@ import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.opengl.GL12;
|
import org.lwjgl.opengl.GL12;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.IntBuffer;
|
import java.nio.IntBuffer;
|
||||||
|
|
||||||
|
// TODO 1.13: implement without java.awt
|
||||||
@Mod(modid = TextureDumper.MODID, name = "Forge Texture Atlas Dump", version = TextureDumper.VERSION, clientSideOnly = true)
|
@Mod(modid = TextureDumper.MODID, name = "Forge Texture Atlas Dump", version = TextureDumper.VERSION, clientSideOnly = true)
|
||||||
public class TextureDumper
|
public class TextureDumper
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue