mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-23 21:49:46 +00:00
Update to 1.17
Update to Official classnames Patchwork Make the game compile and run Merge in the new HUD overlay API Merge in the new render properties API PEEL Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason. New FML installer Update to 1.17.1 Co-authored-by: LexManos <[email protected]> Co-authored-by: SizableShrimp <[email protected]> Co-authored-by: cpw <[email protected]> Co-authored-by: Curle <[email protected]> Co-authored-by: Unnoen <[email protected]> Co-authored-by: covers1624 <[email protected]> Co-authored-by: DaemonUmbra <[email protected]> Co-authored-by: gigaherz <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
064ae6961b
commit
be5446b91c
1990 files changed
+35661
-37544
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
public interface IIngameOverlay
|
||||
{
|
||||
void render(ForgeIngameGui gui, PoseStack mStack, float partialTicks, int width, int height);
|
||||
}
|
||||
@@ -19,20 +19,19 @@
|
||||
|
||||
package net.minecraftforge.client.gui;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.gui.screen.MainMenuScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.loading.FMLConfig;
|
||||
import net.minecraftforge.versions.forge.ForgeVersion;
|
||||
import net.minecraftforge.fml.VersionChecker;
|
||||
import net.minecraftforge.fml.client.ClientModLoader;
|
||||
import net.minecraftforge.fmlclient.ClientModLoader;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@@ -47,7 +46,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
|
||||
public NotificationModUpdateScreen(Button modButton)
|
||||
{
|
||||
super(new TranslationTextComponent("forge.menu.updatescreen.title"));
|
||||
super(new TranslatableComponent("forge.menu.updatescreen.title"));
|
||||
this.modButton = modButton;
|
||||
}
|
||||
|
||||
@@ -66,15 +65,14 @@ public class NotificationModUpdateScreen extends Screen
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack mStack, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
if (showNotification == null || !showNotification.shouldDraw() || !FMLConfig.runVersionCheck())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS);
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
RenderSystem.setShaderTexture(0, VERSION_CHECK_ICONS);
|
||||
|
||||
int x = modButton.x;
|
||||
int y = modButton.y;
|
||||
@@ -84,7 +82,7 @@ public class NotificationModUpdateScreen extends Screen
|
||||
blit(mStack, x + w - (h / 2 + 4), y + (h / 2 - 4), showNotification.getSheetOffset() * 8, (showNotification.isAnimated() && ((System.currentTimeMillis() / 800 & 1) == 1)) ? 8 : 0, 8, 8, 64, 16);
|
||||
}
|
||||
|
||||
public static NotificationModUpdateScreen init(MainMenuScreen guiMainMenu, Button modButton)
|
||||
public static NotificationModUpdateScreen init(TitleScreen guiMainMenu, Button modButton)
|
||||
{
|
||||
NotificationModUpdateScreen notificationModUpdateScreen = new NotificationModUpdateScreen(modButton);
|
||||
notificationModUpdateScreen.resize(guiMainMenu.getMinecraft(), guiMainMenu.width, guiMainMenu.height);
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Minecraft Forge
|
||||
* Copyright (c) 2016-2021.
|
||||
*
|
||||
* 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.client.gui;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class OverlayRegistry
|
||||
{
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the beginning of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBottom(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed before the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert before. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayBelow(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(-1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed after the {@code other} parameter in the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param other The overlay to insert after. The overlay must be registered.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayAbove(@Nonnull IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, other, displayName, overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new overlay entry to the registry, placed at the end of the list.
|
||||
* Call from {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent}. No need for enqueueWork.
|
||||
* @param displayName A string for debug purposes, used primarily in exception traces coming from the overlays.
|
||||
* @param overlay An instance, lambda or method reference for the logic used in rendering the overlay.
|
||||
* @return The same object passed into the {@code overlay} parameter.
|
||||
*/
|
||||
public static synchronized IIngameOverlay registerOverlayTop(@Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return registerOverlay(1, null, displayName, overlay);
|
||||
}
|
||||
|
||||
private static IIngameOverlay registerOverlay(int sort, @Nullable IIngameOverlay other, @Nonnull String displayName, @Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
|
||||
if (entry != null)
|
||||
{
|
||||
overlaysOrdered.remove(entry);
|
||||
}
|
||||
|
||||
int insertAt = overlays.size();
|
||||
if (other == null)
|
||||
{
|
||||
if (sort < 0)
|
||||
insertAt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < overlaysOrdered.size(); i++)
|
||||
{
|
||||
OverlayEntry ov = overlaysOrdered.get(i);
|
||||
if (ov.getOverlay() == other)
|
||||
{
|
||||
if (sort < 0) insertAt = i;
|
||||
else insertAt = i+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entry = new OverlayEntry(overlay, displayName);
|
||||
|
||||
overlaysOrdered.add(insertAt, entry);
|
||||
overlays.put(overlay, entry);
|
||||
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables an overlay. This is preferred over removing overlays.
|
||||
* @param overlay The overlay object to enable or disable
|
||||
* @param enable The new state
|
||||
*/
|
||||
public static synchronized void enableOverlay(@Nonnull IIngameOverlay overlay, boolean enable)
|
||||
{
|
||||
OverlayEntry entry = overlays.get(overlay);
|
||||
if (entry != null)
|
||||
{
|
||||
entry.setEnabled(enable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the information on a registered overlay.
|
||||
* @param overlay The overlay to obtain the information for.
|
||||
* @return The registration entry for this overlay.
|
||||
*/
|
||||
@Nullable
|
||||
public static synchronized OverlayEntry getEntry(@Nonnull IIngameOverlay overlay)
|
||||
{
|
||||
return overlays.get(overlay);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns an unmodifiable view of the ordered list of entries.
|
||||
*/
|
||||
public static List<OverlayEntry> orderedEntries()
|
||||
{
|
||||
return Collections.unmodifiableList(overlaysOrdered);
|
||||
}
|
||||
|
||||
private static final Map<IIngameOverlay, OverlayEntry> overlays = Maps.newHashMap();
|
||||
private static final List<OverlayEntry> overlaysOrdered = Lists.newArrayList();
|
||||
|
||||
public static class OverlayEntry {
|
||||
private final IIngameOverlay overlay;
|
||||
private final String displayName;
|
||||
private boolean enabled = true;
|
||||
|
||||
public OverlayEntry(IIngameOverlay overlay, String displayName)
|
||||
{
|
||||
this.overlay = overlay;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the overlay renderer.
|
||||
*/
|
||||
public IIngameOverlay getOverlay()
|
||||
{
|
||||
return overlay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the debug name for this entry.
|
||||
*/
|
||||
public String getDisplayName()
|
||||
{
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if the entry will be rendered.
|
||||
*/
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* For internal use. Call via {@link #enableOverlay(IIngameOverlay, boolean)}.
|
||||
*/
|
||||
private void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,22 +22,20 @@ package net.minecraftforge.client.gui;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.FocusableGui;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.IRenderable;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraftforge.fmlclient.gui.GuiUtils;
|
||||
|
||||
public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
public abstract class ScrollPanel extends AbstractContainerEventHandler implements Widget
|
||||
{
|
||||
private final Minecraft client;
|
||||
protected final int width;
|
||||
@@ -76,7 +74,7 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
* @param mouseY
|
||||
* @param mouseX
|
||||
*/
|
||||
protected abstract void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY);
|
||||
protected abstract void drawPanel(PoseStack mStack, int entryRight, int relativeY, Tesselator tess, int mouseX, int mouseY);
|
||||
|
||||
protected boolean clickPanel(double mouseX, double mouseY, int button) { return false; }
|
||||
|
||||
@@ -184,11 +182,11 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void render(MatrixStack matrix, int mouseX, int mouseY, float partialTicks)
|
||||
public void render(PoseStack matrix, int mouseX, int mouseY, float partialTicks)
|
||||
{
|
||||
this.drawBackground();
|
||||
|
||||
Tessellator tess = Tessellator.getInstance();
|
||||
Tesselator tess = Tesselator.getInstance();
|
||||
BufferBuilder worldr = tess.getBuilder();
|
||||
|
||||
double scale = client.getWindow().getGuiScale();
|
||||
@@ -202,12 +200,10 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
}
|
||||
else // Draw dark dirt background
|
||||
{
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableFog();
|
||||
this.client.getTextureManager().bind(AbstractGui.BACKGROUND_LOCATION);
|
||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION);
|
||||
final float texScale = 32.0F;
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(this.left, this.bottom, 0.0D).uv(this.left / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.bottom, 0.0D).uv(this.right / texScale, (this.bottom + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
worldr.vertex(this.right, this.top, 0.0D).uv(this.right / texScale, (this.top + (int)this.scrollDistance) / texScale).color(0x20, 0x20, 0x20, 0xFF).endVertex();
|
||||
@@ -231,20 +227,21 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
barTop = this.top;
|
||||
}
|
||||
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
|
||||
RenderSystem.disableTexture();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, this.bottom, 0.0D).uv(0.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, this.bottom, 0.0D).uv(1.0F, 1.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, this.top, 0.0D).uv(1.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft, this.top, 0.0D).uv(0.0F, 0.0F).color(0x00, 0x00, 0x00, 0xFF).endVertex();
|
||||
tess.end();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, barTop + barHeight, 0.0D).uv(0.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, barTop + barHeight, 0.0D).uv(1.0F, 1.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth, barTop, 0.0D).uv(1.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft, barTop, 0.0D).uv(0.0F, 0.0F).color(0x80, 0x80, 0x80, 0xFF).endVertex();
|
||||
tess.end();
|
||||
worldr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
worldr.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
|
||||
worldr.vertex(barLeft, barTop + barHeight - 1, 0.0D).uv(0.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth - 1, barTop + barHeight - 1, 0.0D).uv(1.0F, 1.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
worldr.vertex(barLeft + barWidth - 1, barTop, 0.0D).uv(1.0F, 0.0F).color(0xC0, 0xC0, 0xC0, 0xFF).endVertex();
|
||||
@@ -253,19 +250,17 @@ public abstract class ScrollPanel extends FocusableGui implements IRenderable
|
||||
}
|
||||
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.shadeModel(GL11.GL_FLAT);
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.disableBlend();
|
||||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
protected void drawGradientRect(MatrixStack mStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
protected void drawGradientRect(PoseStack mStack, int left, int top, int right, int bottom, int color1, int color2)
|
||||
{
|
||||
GuiUtils.drawGradientRect(mStack.last().pose(), 0, left, top, right, bottom, color1, color2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends IGuiEventListener> children()
|
||||
public List<? extends GuiEventListener> children()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user