Regenerate patches with relative headers. This should lower conflicts in future PRs.

Convert Forge to use Official mappings.
Mojang released their obfuscation mappings but we have not used them up until now due to wanting to get their license to be more explicitly permissive.
It is clear that their intent is to allow us to use their names for developing mods like this.
See the full wording, and our interpretation here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
This commit is contained in:
LexManos committed 2021-03-09 14:21:48 -08:00
1 parent 802298d99d
commit a95b968c13
832 files changed
+4464 -4373

No files matched your search

@@ -41,7 +41,7 @@ public class CrashReportExtender
{
for (final ICrashCallable call: crashCallables)
{
category.addDetail(call.getLabel(), call);
category.setDetail(call.getLabel(), call);
}
}
@@ -82,23 +82,23 @@ public class CrashReportExtender
public static File dumpModLoadingCrashReport(final Logger logger, final LoadingFailedException error, final File topLevelDir) {
final CrashReport crashReport = CrashReport.makeCrashReport(new Exception("Mod Loading has failed"), "Mod loading error has occurred");
final CrashReport crashReport = CrashReport.forThrowable(new Exception("Mod Loading has failed"), "Mod loading error has occurred");
error.getErrors().forEach(mle -> {
final Optional<IModInfo> modInfo = Optional.ofNullable(mle.getModInfo());
final CrashReportCategory category = crashReport.makeCategory(modInfo.map(iModInfo -> "MOD "+iModInfo.getModId()).orElse("NO MOD INFO AVAILABLE"));
final CrashReportCategory category = crashReport.addCategory(modInfo.map(iModInfo -> "MOD "+iModInfo.getModId()).orElse("NO MOD INFO AVAILABLE"));
Throwable cause = mle.getCause();
int depth = 0;
while (cause != null && cause.getCause() != null && cause.getCause()!=cause) {
category.addDetail("Caused by "+(depth++), cause + generateEnhancedStackTrace(cause.getStackTrace()).replaceAll(Strings.LINE_SEPARATOR+"\t", "\n\t\t"));
category.setDetail("Caused by "+(depth++), cause + generateEnhancedStackTrace(cause.getStackTrace()).replaceAll(Strings.LINE_SEPARATOR+"\t", "\n\t\t"));
cause = cause.getCause();
}
if (cause != null)
category.applyStackTrace(cause);
category.addDetail("Mod File", () -> modInfo.map(IModInfo::getOwningFile).map(t->((ModFileInfo)t).getFile().getFileName()).orElse("NO FILE INFO"));
category.addDetail("Failure message", () -> mle.getCleanMessage().replace("\n", "\n\t\t"));
category.addDetail("Mod Version", () -> modInfo.map(IModInfo::getVersion).map(Object::toString).orElse("NO MOD INFO AVAILABLE"));
category.addDetail("Mod Issue URL", () -> modInfo.map(IModInfo::getOwningFile).map(ModFileInfo.class::cast).flatMap(mfi->mfi.<String>getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED"));
category.addDetail("Exception message", Objects.toString(cause, "MISSING EXCEPTION MESSAGE"));
category.setDetail("Mod File", () -> modInfo.map(IModInfo::getOwningFile).map(t->((ModFileInfo)t).getFile().getFileName()).orElse("NO FILE INFO"));
category.setDetail("Failure message", () -> mle.getCleanMessage().replace("\n", "\n\t\t"));
category.setDetail("Mod Version", () -> modInfo.map(IModInfo::getVersion).map(Object::toString).orElse("NO MOD INFO AVAILABLE"));
category.setDetail("Mod Issue URL", () -> modInfo.map(IModInfo::getOwningFile).map(ModFileInfo.class::cast).flatMap(mfi->mfi.<String>getConfigElement("issueTrackerURL")).orElse("NOT PROVIDED"));
category.setDetail("Exception message", Objects.toString(cause, "MISSING EXCEPTION MESSAGE"));
});
final File file1 = new File(topLevelDir, "crash-reports");
final File file2 = new File(file1, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-fml.txt");
@@ -107,7 +107,7 @@ public class CrashReportExtender
} else {
logger.fatal("Failed to save crash report");
}
System.out.print(crashReport.getCompleteReport());
System.out.print(crashReport.getFriendlyReport());
return file2;
}
}
@@ -49,7 +49,7 @@ public class DatagenModLoader {
if (mods.contains("minecraft") && mods.size() == 1) return;
LOGGER.info("Initializing Data Gatherer for mods {}", mods);
runningDataGen = true;
Bootstrap.register();
Bootstrap.bootStrap();
dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, serverGenerators, clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat);
ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{});
if (!mods.contains("forge")) {
@@ -71,13 +71,13 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
CompoundNBT registries = new CompoundNBT();
fmlData.put("Registries", registries);
LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getWorldName());
LOGGER.debug(WORLDPERSISTENCE,"Gathering id map for writing to world save {}", serverInfo.getLevelName());
for (Map.Entry<ResourceLocation, ForgeRegistry.Snapshot> e : RegistryManager.ACTIVE.takeSnapshot(true).entrySet())
{
registries.put(e.getKey().toString(), e.getValue().write());
}
LOGGER.debug(WORLDPERSISTENCE,"ID Map collection complete {}", serverInfo.getWorldName());
LOGGER.debug(WORLDPERSISTENCE,"ID Map collection complete {}", serverInfo.getLevelName());
return fmlData;
}
@@ -114,7 +114,7 @@ public final class FMLWorldPersistenceHook implements WorldPersistenceHooks.Worl
{
Map<ResourceLocation, ForgeRegistry.Snapshot> snapshot = new HashMap<>();
CompoundNBT regs = tag.getCompound("Registries");
for (String key : regs.keySet())
for (String key : regs.getAllKeys())
{
snapshot.put(new ResourceLocation(key), ForgeRegistry.Snapshot.read(regs.getCompound(key)));
}
@@ -31,7 +31,7 @@ public enum LogicalSidedProvider
{
WORKQUEUE((c)->c.get(), (s)->s.get()),
INSTANCE((c)->c.get(), (s)->s.get()),
CLIENTWORLD((c)-> Optional.<World>of(c.get().world), (s)->Optional.<World>empty())
CLIENTWORLD((c)-> Optional.<World>of(c.get().level), (s)->Optional.<World>empty())
;
private static Supplier<Minecraft> client;
private static Supplier<MinecraftServer> server;
@@ -29,7 +29,7 @@ public class TextComponentMessageFormatHandler {
public static int handle(final TranslationTextComponent parent, final List<ITextProperties> children, final Object[] formatArgs, final String format) {
try {
StringTextComponent component = new StringTextComponent(ForgeI18n.parseFormat(format, formatArgs));
component.getStyle().mergeStyle(parent.getStyle());
component.getStyle().applyTo(parent.getStyle());
children.add(component);
return format.length();
} catch (IllegalArgumentException ex) {
@@ -104,7 +104,7 @@ public class ClientHooks
filter(e -> !ModList.get().isLoaded(e.getKey())).
collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
LOGGER.debug(CLIENTHOOKS, "Received FML ping data from server at {}: FMLNETVER={}, mod list is compatible : {}, channel list is compatible: {}, extra server mods: {}", target.serverIP, fmlver, modsMatch, channelsMatch, extraServerMods);
LOGGER.debug(CLIENTHOOKS, "Received FML ping data from server at {}: FMLNETVER={}, mod list is compatible : {}, channel list is compatible: {}, extra server mods: {}", target.ip, fmlver, modsMatch, channelsMatch, extraServerMods);
String extraReason = null;
@@ -169,12 +169,12 @@ public class ClientHooks
tooltip = ForgeI18n.parseMessage("fml.menu.multiplayer.unknown", target.forgeData.type);
}
Minecraft.getInstance().getTextureManager().bindTexture(iconSheet);
Minecraft.getInstance().getTextureManager().bind(iconSheet);
AbstractGui.blit(mStack, x + width - 18, y + 10, 16, 16, 0, idx, 16, 16, 256, 256);
if(relativeMouseX > width - 15 && relativeMouseX < width && relativeMouseY > 10 && relativeMouseY < 26)
//TODO using StringTextComponent here is a hack, we should be using TranslationTextComponents.
gui.func_238854_b_(Collections.singletonList(new StringTextComponent(tooltip)));
gui.setToolTip(Collections.singletonList(new StringTextComponent(tooltip)));
}
@@ -186,19 +186,19 @@ public class ClientHooks
@SuppressWarnings("resource")
static File getSavesDir()
{
return new File(Minecraft.getInstance().gameDir, "saves");
return new File(Minecraft.getInstance().gameDirectory, "saves");
}
private static NetworkManager getClientToServerNetworkManager()
{
return Minecraft.getInstance().getConnection()!=null ? Minecraft.getInstance().getConnection().getNetworkManager() : null;
return Minecraft.getInstance().getConnection()!=null ? Minecraft.getInstance().getConnection().getConnection() : null;
}
public static void handleClientWorldClosing(ClientWorld world)
{
NetworkManager client = getClientToServerNetworkManager();
// ONLY revert a non-local connection
if (client != null && !client.isLocalChannel())
if (client != null && !client.isMemoryConnection())
{
GameData.revertToFrozen();
}
@@ -251,7 +251,7 @@ public class ClientHooks
}
else
{
List<IResourcePack> resPacks = fallbackResourceManager.resourcePacks;
List<IResourcePack> resPacks = fallbackResourceManager.fallbacks;
logger.error(" domain {} has {} location{}:",resourceDomain, resPacks.size(), resPacks.size() != 1 ? "s" :"");
for (IResourcePack resPack : resPacks)
{
@@ -306,7 +306,7 @@ public class ClientHooks
}
public static void firePlayerLogout(PlayerController pc, ClientPlayerEntity player) {
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedOutEvent(pc, player, player != null ? player.connection != null ? player.connection.getNetworkManager() : null : null));
MinecraftForge.EVENT_BUS.post(new ClientPlayerNetworkEvent.LoggedOutEvent(pc, player, player != null ? player.connection != null ? player.connection.getConnection() : null : null));
}
public static void firePlayerRespawn(PlayerController pc, ClientPlayerEntity oldPlayer, ClientPlayerEntity newPlayer, NetworkManager networkManager) {
@@ -99,20 +99,20 @@ public class ClientModLoader
ClientModLoader.mc = minecraft;
LogicalSidedProvider.setClient(()->minecraft);
LanguageHook.loadForgeAndMCLangs();
earlyLoaderGUI = new EarlyLoaderGUI(minecraft.getMainWindow());
earlyLoaderGUI = new EarlyLoaderGUI(minecraft.getWindow());
createRunnableWithCatch(()->ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), new SpacedRunnable(earlyLoaderGUI::renderTick))).run();
if (error == null) {
ResourcePackLoader.loadResourcePacks(defaultResourcePacks, ClientModLoader::buildPackFinder);
DatapackCodec.VANILLA_CODEC.addModPacks(ResourcePackLoader.getPackNames());
mcResourceManager.addReloadListener(ClientModLoader::onResourceReload);
mcResourceManager.addReloadListener(BrandingControl.resourceManagerReloadListener());
DatapackCodec.DEFAULT.addModPacks(ResourcePackLoader.getPackNames());
mcResourceManager.registerReloadListener(ClientModLoader::onResourceReload);
mcResourceManager.registerReloadListener(BrandingControl.resourceManagerReloadListener());
ModelLoaderRegistry.init();
}
}
private static CompletableFuture<Void> onResourceReload(final IFutureReloadListener.IStage stage, final IResourceManager resourceManager, final IProfiler prepareProfiler, final IProfiler executeProfiler, final Executor asyncExecutor, final Executor syncExecutor) {
return CompletableFuture.runAsync(createRunnableWithCatch(() -> startModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor)), ModWorkManager.parallelExecutor())
.thenCompose(stage::markCompleteAwaitingOthers)
.thenCompose(stage::wait)
.thenRunAsync(() -> finishModLoading(ModWorkManager.wrappedExecutor(syncExecutor), asyncExecutor), ModWorkManager.parallelExecutor());
}
@@ -134,7 +134,7 @@ public class ClientModLoader
private static void postSidedRunnable() {
LOGGER.debug(LOADING, "Running post client event work");
RenderingRegistry.loadEntityRenderers(mc.getRenderManager());
RenderingRegistry.loadEntityRenderers(mc.getEntityRenderDispatcher());
}
private static void preSidedRunnable() {
@@ -147,7 +147,7 @@ public class ClientModLoader
loading = false;
loadingComplete = true;
// reload game settings on main thread
syncExecutor.execute(()->mc.gameSettings.loadOptions());
syncExecutor.execute(()->mc.options.load());
}
public static VersionChecker.Status checkForUpdates()
@@ -185,10 +185,10 @@ public class ClientModLoader
} else {
// Double check we have the langs loaded for forge
LanguageHook.loadForgeAndMCLangs();
dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error, mc.gameDir);
dumpedLocation = CrashReportExtender.dumpModLoadingCrashReport(LOGGER, error, mc.gameDirectory);
}
if (error != null || !warnings.isEmpty()) {
mc.displayGuiScreen(new LoadingErrorScreen(error, warnings, dumpedLocation));
mc.setScreen(new LoadingErrorScreen(error, warnings, dumpedLocation));
return true;
} else {
ClientHooks.logMissingTextureErrors();
@@ -215,7 +215,7 @@ public class ClientModLoader
IModInfo mod = e.getKey().getModInfos().get(0);
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
final String name = "mod:" + mod.getModId();
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.PLAIN);
final ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
if (packInfo == null) {
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));
@@ -229,9 +229,9 @@ public class ClientModLoader
hiddenPacks.add(e.getValue());
}
}
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
final ResourcePackInfo packInfo = ResourcePackInfo.create("mod_resources", true, () -> new DelegatingResourcePack("mod_resources", "Mod Resources",
new PackMetadataSection(new TranslationTextComponent("fml.resources.modresources", hiddenPacks.size()), 6),
hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.PLAIN);
hiddenPacks), factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
consumer.accept(packInfo);
}
}
@@ -47,10 +47,10 @@ public class EarlyLoaderGUI {
@SuppressWarnings("deprecation")
private void setupMatrix() {
RenderSystem.clear(256, Minecraft.IS_RUNNING_ON_MAC);
RenderSystem.clear(256, Minecraft.ON_OSX);
RenderSystem.matrixMode(5889);
RenderSystem.loadIdentity();
RenderSystem.ortho(0.0D, window.getFramebufferWidth() / window.getGuiScaleFactor(), window.getFramebufferHeight() / window.getGuiScaleFactor(), 0.0D, 1000.0D, 3000.0D);
RenderSystem.ortho(0.0D, window.getWidth() / window.getGuiScale(), window.getHeight() / window.getGuiScale(), 0.0D, 1000.0D, 3000.0D);
RenderSystem.matrixMode(5888);
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, 0.0F, -2000.0F);
@@ -67,16 +67,16 @@ public class EarlyLoaderGUI {
@SuppressWarnings("deprecation")
void renderTick() {
if (handledElsewhere) return;
int guiScale = window.calcGuiScale(0, false);
int guiScale = window.calculateScale(0, false);
window.setGuiScale(guiScale);
RenderSystem.clearColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT, Minecraft.IS_RUNNING_ON_MAC);
RenderSystem.clear(GL11.GL_COLOR_BUFFER_BIT, Minecraft.ON_OSX);
RenderSystem.pushMatrix();
setupMatrix();
renderBackground();
renderMessages();
window.flipFrame();
window.updateDisplay();
RenderSystem.popMatrix();
}
@@ -84,9 +84,9 @@ public class EarlyLoaderGUI {
GL11.glBegin(GL11.GL_QUADS);
GL11.glColor4f(239F / 255F, 50F / 255F, 61F / 255F, 255F / 255F); //Color from ResourceLoadProgressGui
GL11.glVertex3f(0, 0, -10);
GL11.glVertex3f(0, window.getScaledHeight(), -10);
GL11.glVertex3f(window.getScaledWidth(), window.getScaledHeight(), -10);
GL11.glVertex3f(window.getScaledWidth(), 0, -10);
GL11.glVertex3f(0, window.getGuiScaledHeight(), -10);
GL11.glVertex3f(window.getGuiScaledWidth(), window.getGuiScaledHeight(), -10);
GL11.glVertex3f(window.getGuiScaledWidth(), 0, -10);
GL11.glEnd();
}
@@ -98,7 +98,7 @@ public class EarlyLoaderGUI {
final float fade = MathHelper.clamp((4000.0f - (float) pair.getLeft() - ( i - 4 ) * 1000.0f) / 5000.0f, 0.0f, 1.0f);
if (fade <0.01f && !nofade) continue;
StartupMessageManager.Message msg = pair.getRight();
renderMessage(msg.getText(), msg.getTypeColour(), ((window.getScaledHeight() - 15) / 10) - i + 1, nofade ? 1.0f : fade);
renderMessage(msg.getText(), msg.getTypeColour(), ((window.getGuiScaledHeight() - 15) / 10) - i + 1, nofade ? 1.0f : fade);
}
renderMemoryInfo();
}
@@ -111,7 +111,7 @@ public class EarlyLoaderGUI {
final float pctmemory = (float) heapusage.getUsed() / heapusage.getMax();
String memory = String.format("Memory Heap: %d / %d MB (%.1f%%) OffHeap: %d MB", heapusage.getUsed() >> 20, heapusage.getMax() >> 20, pctmemory * 100.0, offheapusage.getUsed() >> 20);
final int i = MathHelper.hsvToRGB((1.0f - (float)Math.pow(pctmemory, 1.5f)) / 3f, 1.0f, 0.5f);
final int i = MathHelper.hsvToRgb((1.0f - (float)Math.pow(pctmemory, 1.5f)) / 3f, 1.0f, 0.5f);
memorycolour[2] = ((i) & 0xFF) / 255.0f;
memorycolour[1] = ((i >> 8 ) & 0xFF) / 255.0f;
memorycolour[0] = ((i >> 16 ) & 0xFF) / 255.0f;
@@ -120,7 +120,7 @@ public class EarlyLoaderGUI {
@SuppressWarnings("deprecation")
void renderMessage(final String message, final float[] colour, int line, float alpha) {
GlStateManager.enableClientState(GL11.GL_VERTEX_ARRAY);
GlStateManager._enableClientState(GL11.GL_VERTEX_ARRAY);
ByteBuffer charBuffer = MemoryUtil.memAlloc(message.length() * 270);
int quads = STBEasyFont.stb_easy_font_print(0, 0, message, null, charBuffer);
GL14.glVertexPointer(2, GL11.GL_FLOAT, 16, charBuffer);
@@ -140,7 +140,7 @@ public class EarlyLoaderGUI {
RenderSystem.popMatrix();
RenderSystem.enableCull();
GlStateManager.disableClientState(GL11.GL_VERTEX_ARRAY);
GlStateManager._disableClientState(GL11.GL_VERTEX_ARRAY);
MemoryUtil.memFree(charBuffer);
}
}
@@ -137,7 +137,7 @@ public class GuiUtils
public static void drawContinuousTexturedBox(ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
{
Minecraft.getInstance().getTextureManager().bindTexture(res);
Minecraft.getInstance().getTextureManager().bind(res);
drawContinuousTexturedBox(x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
}
@@ -216,13 +216,13 @@ public class GuiUtils
final float vScale = 1f / 0x100;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder wr = tessellator.getBuffer();
BufferBuilder wr = tessellator.getBuilder();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
wr.pos(x , y + height, zLevel).tex( u * uScale, ((v + height) * vScale)).endVertex();
wr.pos(x + width, y + height, zLevel).tex((u + width) * uScale, ((v + height) * vScale)).endVertex();
wr.pos(x + width, y , zLevel).tex((u + width) * uScale, ( v * vScale)).endVertex();
wr.pos(x , y , zLevel).tex( u * uScale, ( v * vScale)).endVertex();
tessellator.draw();
wr.vertex(x , y + height, zLevel).uv( u * uScale, ((v + height) * vScale)).endVertex();
wr.vertex(x + width, y + height, zLevel).uv((u + width) * uScale, ((v + height) * vScale)).endVertex();
wr.vertex(x + width, y , zLevel).uv((u + width) * uScale, ( v * vScale)).endVertex();
wr.vertex(x , y , zLevel).uv( u * uScale, ( v * vScale)).endVertex();
tessellator.end();
}
/**
@@ -296,7 +296,7 @@ public class GuiUtils
public static void drawContinuousTexturedBox(MatrixStack matrixStack, ResourceLocation res, int x, int y, int u, int v, int width, int height, int textureWidth, int textureHeight,
int topBorder, int bottomBorder, int leftBorder, int rightBorder, float zLevel)
{
Minecraft.getInstance().getTextureManager().bindTexture(res);
Minecraft.getInstance().getTextureManager().bind(res);
drawContinuousTexturedBox(matrixStack, x, y, u, v, width, height, textureWidth, textureHeight, topBorder, bottomBorder, leftBorder, rightBorder, zLevel);
}
@@ -375,14 +375,14 @@ public class GuiUtils
final float vScale = 1f / 0x100;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder wr = tessellator.getBuffer();
BufferBuilder wr = tessellator.getBuilder();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
Matrix4f matrix = matrixStack.getLast().getMatrix();
wr.pos(matrix, x , y + height, zLevel).tex( u * uScale, ((v + height) * vScale)).endVertex();
wr.pos(matrix, x + width, y + height, zLevel).tex((u + width) * uScale, ((v + height) * vScale)).endVertex();
wr.pos(matrix, x + width, y , zLevel).tex((u + width) * uScale, ( v * vScale)).endVertex();
wr.pos(matrix, x , y , zLevel).tex( u * uScale, ( v * vScale)).endVertex();
tessellator.draw();
Matrix4f matrix = matrixStack.last().pose();
wr.vertex(matrix, x , y + height, zLevel).uv( u * uScale, ((v + height) * vScale)).endVertex();
wr.vertex(matrix, x + width, y + height, zLevel).uv((u + width) * uScale, ((v + height) * vScale)).endVertex();
wr.vertex(matrix, x + width, y , zLevel).uv((u + width) * uScale, ( v * vScale)).endVertex();
wr.vertex(matrix, x , y , zLevel).uv( u * uScale, ( v * vScale)).endVertex();
tessellator.end();
}
@Nonnull
@@ -469,7 +469,7 @@ public class GuiUtils
for (ITextProperties textLine : textLines)
{
int textLineWidth = font.getStringPropertyWidth(textLine);
int textLineWidth = font.width(textLine);
if (textLineWidth > tooltipTextWidth)
tooltipTextWidth = textLineWidth;
}
@@ -504,13 +504,13 @@ public class GuiUtils
for (int i = 0; i < textLines.size(); i++)
{
ITextProperties textLine = textLines.get(i);
List<ITextProperties> wrappedLine = font.getCharacterManager().func_238362_b_(textLine, tooltipTextWidth, Style.EMPTY);
List<ITextProperties> wrappedLine = font.getSplitter().splitLines(textLine, tooltipTextWidth, Style.EMPTY);
if (i == 0)
titleLinesCount = wrappedLine.size();
for (ITextProperties line : wrappedLine)
{
int lineWidth = font.getStringPropertyWidth(line);
int lineWidth = font.width(line);
if (lineWidth > wrappedTooltipWidth)
wrappedTooltipWidth = lineWidth;
wrappedTextLines.add(line);
@@ -547,8 +547,8 @@ public class GuiUtils
borderColorStart = colorEvent.getBorderStart();
borderColorEnd = colorEvent.getBorderEnd();
mStack.push();
Matrix4f mat = mStack.getLast().getMatrix();
mStack.pushPose();
Matrix4f mat = mStack.last().pose();
//TODO, lots of unnessesary GL calls here, we can buffer all these together.
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY - 4, tooltipX + tooltipTextWidth + 3, tooltipY - 3, backgroundColor, backgroundColor);
drawGradientRect(mat, zLevel, tooltipX - 3, tooltipY + tooltipHeight + 3, tooltipX + tooltipTextWidth + 3, tooltipY + tooltipHeight + 4, backgroundColor, backgroundColor);
@@ -562,7 +562,7 @@ public class GuiUtils
MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostBackground(stack, textLines, mStack, tooltipX, tooltipY, font, tooltipTextWidth, tooltipHeight));
IRenderTypeBuffer.Impl renderType = IRenderTypeBuffer.getImpl(Tessellator.getInstance().getBuffer());
IRenderTypeBuffer.Impl renderType = IRenderTypeBuffer.immediate(Tessellator.getInstance().getBuilder());
mStack.translate(0.0D, 0.0D, zLevel);
int tooltipTop = tooltipY;
@@ -571,7 +571,7 @@ public class GuiUtils
{
ITextProperties line = textLines.get(lineNumber);
if (line != null)
font.func_238416_a_(LanguageMap.getInstance().func_241870_a(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880);
font.drawInBatch(LanguageMap.getInstance().getVisualOrder(line), (float)tooltipX, (float)tooltipY, -1, true, mat, renderType, false, 0, 15728880);
if (lineNumber + 1 == titleLinesCount)
tooltipY += 2;
@@ -579,8 +579,8 @@ public class GuiUtils
tooltipY += 10;
}
renderType.finish();
mStack.pop();
renderType.endBatch();
mStack.popPose();
MinecraftForge.EVENT_BUS.post(new RenderTooltipEvent.PostText(stack, textLines, mStack, tooltipX, tooltipTop, font, tooltipTextWidth, tooltipHeight));
@@ -608,13 +608,13 @@ public class GuiUtils
RenderSystem.shadeModel(GL11.GL_SMOOTH);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
BufferBuilder buffer = tessellator.getBuilder();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
buffer.pos(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.pos(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.pos(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
buffer.pos(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
tessellator.draw();
buffer.vertex(mat, right, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.vertex(mat, left, top, zLevel).color(startRed, startGreen, startBlue, startAlpha).endVertex();
buffer.vertex(mat, left, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
buffer.vertex(mat, right, bottom, zLevel).color( endRed, endGreen, endBlue, endAlpha).endVertex();
tessellator.end();
RenderSystem.shadeModel(GL11.GL_FLAT);
RenderSystem.disableBlend();
@@ -35,16 +35,16 @@ public class ConfirmationScreen extends NotificationScreen
@Override
protected void addConfirmationButtons()
{
this.func_230480_a_(new Button(this.field_230708_k_ / 2 - 104, this.field_230709_l_ - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.yes")), b ->
this.addButton(new Button(this.width / 2 - 104, this.height - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.yes")), b ->
{
ConfirmationScreen.this.field_230706_i_.currentScreen = null;
ConfirmationScreen.this.minecraft.currentScreen = null;
query.setResult(true);
query.finish();
}
));
this.func_230480_a_(new Button(this.field_230708_k_ / 2 + 4, this.field_230709_l_ - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.no")), b ->
this.addButton(new Button(this.width / 2 + 4, this.height - PADDING - 20, 100, 20, new StringTextComponent(ForgeI18n.parseMessage("gui.no")), b ->
{
ConfirmationScreen.this.field_230706_i_.currentScreen = null;
ConfirmationScreen.this.minecraft.currentScreen = null;
query.setResult(false);
query.finish();
}
@@ -80,20 +80,20 @@ public class LoadingErrorScreen extends ErrorScreen {
this.warningHeader = new StringTextComponent(TextFormatting.YELLOW + ForgeI18n.parseMessage("fml.loadingerrorscreen.warningheader", this.modLoadErrors.size()) + TextFormatting.RESET);
int yOffset = 46;
this.addButton(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getOSType().openFile(modsDir.toFile())));
this.addButton(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getOSType().openFile(logFile.toFile())));
this.addButton(new ExtendedButton(50, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.mods.folder")), b -> Util.getPlatform().openFile(modsDir.toFile())));
this.addButton(new ExtendedButton(this.width / 2 + 5, this.height - yOffset, this.width / 2 - 55, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", logFile.getFileName())), b -> Util.getPlatform().openFile(logFile.toFile())));
if (this.modLoadErrors.isEmpty()) {
this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.continue.launch")), b -> {
ClientHooks.logMissingTextureErrors();
this.minecraft.displayGuiScreen(null);
this.minecraft.setScreen(null);
}));
} else {
this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getOSType().openFile(dumpedLocation.toFile())));
this.addButton(new ExtendedButton(this.width / 4, this.height - 24, this.width / 2, 20, new StringTextComponent(ForgeI18n.parseMessage("fml.button.open.file", dumpedLocation.getFileName())), b -> Util.getPlatform().openFile(dumpedLocation.toFile())));
}
this.entryList = new LoadingEntryList(this, this.modLoadErrors, this.modLoadWarnings);
this.children.add(this.entryList);
this.setListener(this.entryList);
this.setFocused(this.entryList);
}
@Override
@@ -106,20 +106,20 @@ public class LoadingErrorScreen extends ErrorScreen {
}
private void drawMultiLineCenteredString(MatrixStack mStack, FontRenderer fr, ITextComponent str, int x, int y) {
for (IReorderingProcessor s : fr.trimStringToWidth(str, this.width)) {
fr.func_238407_a_(mStack, s, (float) (x - fr.func_243245_a(s) / 2.0), y, 0xFFFFFF);
y+=fr.FONT_HEIGHT;
for (IReorderingProcessor s : fr.split(str, this.width)) {
fr.drawShadow(mStack, s, (float) (x - fr.width(s) / 2.0), y, 0xFFFFFF);
y+=fr.lineHeight;
}
}
public static class LoadingEntryList extends ExtendedList<LoadingEntryList.LoadingMessageEntry> {
LoadingEntryList(final LoadingErrorScreen parent, final List<ModLoadingException> errors, final List<ModLoadingWarning> warnings) {
super(parent.minecraft, parent.width, parent.height, 35, parent.height - 50, 2 * parent.minecraft.fontRenderer.FONT_HEIGHT + 8);
super(parent.minecraft, parent.width, parent.height, 35, parent.height - 50, 2 * parent.minecraft.font.lineHeight + 8);
boolean both = !errors.isEmpty() && !warnings.isEmpty();
if (both)
addEntry(new LoadingMessageEntry(parent.errorHeader, true));
errors.forEach(e->addEntry(new LoadingMessageEntry(new StringTextComponent(e.formatToString()))));
if (both) {
int maxChars = (this.width - 10) / parent.minecraft.fontRenderer.getStringWidth("-");
int maxChars = (this.width - 10) / parent.minecraft.font.width("-");
addEntry(new LoadingMessageEntry(new StringTextComponent("\n" + Strings.repeat("-", maxChars) + "\n")));
addEntry(new LoadingMessageEntry(parent.warningHeader, true));
}
@@ -153,15 +153,15 @@ public class LoadingErrorScreen extends ErrorScreen {
@Override
public void render(MatrixStack mStack, int entryIdx, int top, int left, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean p_194999_5_, final float partialTicks) {
FontRenderer font = Minecraft.getInstance().fontRenderer;
final List<IReorderingProcessor> strings = font.trimStringToWidth(message, LoadingEntryList.this.width);
FontRenderer font = Minecraft.getInstance().font;
final List<IReorderingProcessor> strings = font.split(message, LoadingEntryList.this.width);
int y = top + 2;
for (int i = 0; i < Math.min(strings.size(), 2); i++) {
if (center)
font.func_238422_b_(mStack, strings.get(i), left + (width) - font.func_243245_a(strings.get(i)) / 2F, y, 0xFFFFFF);
font.draw(mStack, strings.get(i), left + (width) - font.width(strings.get(i)) / 2F, y, 0xFFFFFF);
else
font.func_238422_b_(mStack, strings.get(i), left + 5, y, 0xFFFFFF);
y += font.FONT_HEIGHT;
font.draw(mStack, strings.get(i), left + 5, y, 0xFFFFFF);
y += font.lineHeight;
}
}
}
@@ -74,7 +74,7 @@ import net.minecraftforge.forgespi.language.IModInfo;
public class ModListScreen extends Screen
{
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripControlCodes(value); }
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripColor(value); }
private static final Logger LOGGER = LogManager.getLogger();
private enum SortType implements Comparator<ModInfo>
{
@@ -167,7 +167,7 @@ public class ModListScreen extends Screen
int maxTextLength = this.width - 12;
if (maxTextLength >= 0)
{
ret.addAll(LanguageMap.getInstance().func_244260_a(font.getCharacterManager().func_238362_b_(chat, maxTextLength, Style.EMPTY)));
ret.addAll(LanguageMap.getInstance().getVisualOrder(font.getSplitter().splitLines(chat, maxTextLength, Style.EMPTY)));
}
}
return ret;
@@ -177,7 +177,7 @@ public class ModListScreen extends Screen
public int getContentHeight()
{
int height = 50;
height += (lines.size() * font.FONT_HEIGHT);
height += (lines.size() * font.lineHeight);
if (height < this.bottom - this.top - 8)
height = this.bottom - this.top - 8;
return height;
@@ -186,14 +186,14 @@ public class ModListScreen extends Screen
@Override
protected int getScrollAmount()
{
return font.FONT_HEIGHT * 3;
return font.lineHeight * 3;
}
@Override
protected void drawPanel(MatrixStack mStack, int entryRight, int relativeY, Tessellator tess, int mouseX, int mouseY)
{
if (logoPath != null) {
Minecraft.getInstance().getTextureManager().bindTexture(logoPath);
Minecraft.getInstance().getTextureManager().bind(logoPath);
RenderSystem.enableBlend();
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
// Draw the logo image inscribed in a rectangle with width entryWidth (minus some padding) and height 50
@@ -207,11 +207,11 @@ public class ModListScreen extends Screen
if (line != null)
{
RenderSystem.enableBlend();
ModListScreen.this.font.func_238407_a_(mStack, line, left + PADDING, relativeY, 0xFFFFFF);
ModListScreen.this.font.drawShadow(mStack, line, left + PADDING, relativeY, 0xFFFFFF);
RenderSystem.disableAlphaTest();
RenderSystem.disableBlend();
}
relativeY += font.FONT_HEIGHT;
relativeY += font.lineHeight;
}
final Style component = findTextLine(mouseX, mouseY);
@@ -228,14 +228,14 @@ public class ModListScreen extends Screen
if (offset <= 0)
return null;
int lineIdx = (int) (offset / font.FONT_HEIGHT);
int lineIdx = (int) (offset / font.lineHeight);
if (lineIdx >= lines.size() || lineIdx < 1)
return null;
IReorderingProcessor line = lines.get(lineIdx-1);
if (line != null)
{
return font.getCharacterManager().func_243239_a(line, mouseX);
return font.getSplitter().componentStyleAtWidth(line, mouseX);
}
return null;
}
@@ -260,8 +260,8 @@ public class ModListScreen extends Screen
{
for (ModInfo mod : mods)
{
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(mod.getDisplayName()) + 10);
listWidth = Math.max(listWidth,getFontRenderer().getStringWidth(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
listWidth = Math.max(listWidth,getFontRenderer().width(mod.getDisplayName()) + 10);
listWidth = Math.max(listWidth,getFontRenderer().width(MavenVersionStringHelper.artifactVersionToString(mod.getVersion())) + 5);
}
listWidth = Math.max(Math.min(listWidth, width/3), 100);
listWidth += listWidth % numButtons != 0 ? (numButtons - listWidth % numButtons) : 0;
@@ -270,9 +270,9 @@ public class ModListScreen extends Screen
int doneButtonWidth = Math.min(modInfoWidth, 200);
int y = this.height - 20 - PADDING;
this.addButton(new Button(((listWidth + PADDING + this.width - doneButtonWidth) / 2), y, doneButtonWidth, 20,
new TranslationTextComponent("gui.done"), b -> ModListScreen.this.closeScreen()));
new TranslationTextComponent("gui.done"), b -> ModListScreen.this.onClose()));
this.addButton(this.openModsFolderButton = new Button(6, y, this.listWidth, 20,
new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getOSType().openFile(FMLPaths.MODSDIR.get().toFile())));
new TranslationTextComponent("fml.menu.mods.openmodsfolder"), b -> Util.getPlatform().openFile(FMLPaths.MODSDIR.get().toFile())));
y -= 20 + PADDING;
this.addButton(this.configButton = new Button(6, y, this.listWidth, 20,
new TranslationTextComponent("fml.menu.mods.config"), b -> ModListScreen.this.displayModConfig()));
@@ -282,7 +282,7 @@ public class ModListScreen extends Screen
search = new TextFieldWidget(getFontRenderer(), PADDING + 1, y, listWidth - 2, 14, new TranslationTextComponent("fml.menu.mods.search"));
int fullButtonHeight = PADDING + 20 + PADDING;
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().FONT_HEIGHT - PADDING);
this.modList = new ModListWidget(this, listWidth, fullButtonHeight, search.y - getFontRenderer().lineHeight - PADDING);
this.modList.setLeftPos(6);
this.modInfo = new InfoPanel(this.minecraft, modInfoWidth, this.height - PADDING - fullButtonHeight, PADDING);
@@ -290,7 +290,7 @@ public class ModListScreen extends Screen
children.add(search);
children.add(modList);
children.add(modInfo);
search.setFocused2(false);
search.setFocus(false);
search.setCanLoseFocus(true);
final int width = listWidth / numButtons;
@@ -309,7 +309,7 @@ public class ModListScreen extends Screen
if (selected == null) return;
try
{
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.displayGuiScreen(newScreen));
ConfigGuiHandler.getGuiFactoryFor(selected.getInfo()).map(f->f.apply(this.minecraft, this)).ifPresent(newScreen -> this.minecraft.setScreen(newScreen));
}
catch (final Exception e)
{
@@ -323,7 +323,7 @@ public class ModListScreen extends Screen
search.tick();
modList.setSelected(selected);
if (!search.getText().equals(lastFilterText))
if (!search.getValue().equals(lastFilterText))
{
reloadMods();
sorted = false;
@@ -336,7 +336,7 @@ public class ModListScreen extends Screen
modList.refreshList();
if (selected != null)
{
selected = modList.getEventListeners().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
selected = modList.children().stream().filter(e -> e.getInfo() == selected.getInfo()).findFirst().orElse(null);
updateCache();
}
sorted = true;
@@ -351,8 +351,8 @@ public class ModListScreen extends Screen
private void reloadMods()
{
this.mods = this.unsortedMods.stream().
filter(mi->StringUtils.toLowerCase(stripControlCodes(mi.getDisplayName())).contains(StringUtils.toLowerCase(search.getText()))).collect(Collectors.toList());
lastFilterText = search.getText();
filter(mi->StringUtils.toLowerCase(stripControlCodes(mi.getDisplayName())).contains(StringUtils.toLowerCase(search.getValue()))).collect(Collectors.toList());
lastFilterText = search.getValue();
}
private void resortMods(SortType newSort)
@@ -375,8 +375,8 @@ public class ModListScreen extends Screen
this.modInfo.render(mStack, mouseX, mouseY, partialTicks);
ITextComponent text = new TranslationTextComponent("fml.menu.mods.search");
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().getStringPropertyWidth(text) / 2);
getFontRenderer().func_238422_b_(mStack, text.func_241878_f(), x, search.y - getFontRenderer().FONT_HEIGHT, 0xFFFFFF);
int x = modList.getLeft() + ((modList.getRight() - modList.getLeft()) / 2) - (getFontRenderer().width(text) / 2);
getFontRenderer().draw(mStack, text.getVisualOrderText(), x, search.y - getFontRenderer().lineHeight, 0xFFFFFF);
this.search.render(mStack, mouseX , mouseY, partialTicks);
super.render(mStack, mouseX, mouseY, partialTicks);
}
@@ -419,20 +419,20 @@ public class ModListScreen extends Screen
try
{
NativeImage logo = null;
InputStream logoResource = resourcePack.getRootResourceStream(logoFile);
InputStream logoResource = resourcePack.getRootResource(logoFile);
if (logoResource != null)
logo = NativeImage.read(logoResource);
if (logo != null)
{
return Pair.of(tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo) {
return Pair.of(tm.register("modlogo", new DynamicTexture(logo) {
@Override
public void updateDynamicTexture() {
this.bindTexture();
NativeImage td = this.getTextureData();
public void upload() {
this.bind();
NativeImage td = this.getPixels();
// Use custom "blur" value which controls texture filtering (nearest-neighbor vs linear)
this.getTextureData().uploadTextureSub(0, 0, 0, 0, 0, td.getWidth(), td.getHeight(), selectedMod.getLogoBlur(), false, false, false);
this.getPixels().upload(0, 0, 0, 0, 0, td.getWidth(), td.getHeight(), selectedMod.getLogoBlur(), false, false, false);
}
}), new Size2i(logo.getWidth(), logo.getHeight()));
}
@@ -488,13 +488,13 @@ public class ModListScreen extends Screen
@Override
public void resize(Minecraft mc, int width, int height)
{
String s = this.search.getText();
String s = this.search.getValue();
SortType sort = this.sortType;
ModListWidget.ModEntry selected = this.selected;
this.init(mc, width, height);
this.search.setText(s);
this.search.setValue(s);
this.selected = selected;
if (!this.search.getText().isEmpty())
if (!this.search.getValue().isEmpty())
reloadMods();
if (sort != SortType.NORMAL)
resortMods(sort);
@@ -502,8 +502,8 @@ public class ModListScreen extends Screen
}
@Override
public void closeScreen()
public void onClose()
{
this.minecraft.displayGuiScreen(this.parentScreen);
this.minecraft.setScreen(this.parentScreen);
}
}
@@ -41,7 +41,7 @@ public class NotificationScreen extends Screen
protected int getContentHeight()
{
int height = 0;
height += (textLines.length * field_230712_o_.FONT_HEIGHT) + 4;
height += (textLines.length * font.FONT_HEIGHT) + 4;
if (height < this.height - 50)
height = this.height - 50;
return height;
@@ -56,7 +56,7 @@ public class NotificationScreen extends Screen
@Override
protected int getScrollAmount()
{
return field_230712_o_.FONT_HEIGHT * 3;
return font.FONT_HEIGHT * 3;
}
}
@@ -80,44 +80,44 @@ public class NotificationScreen extends Screen
}
@Override
public void func_231160_c_()
public void init()
{
super.func_231160_c_();
int panelY = PADDING + headerLines.length * field_230712_o_.FONT_HEIGHT + PADDING;
int panelHeight = this.field_230709_l_ - PADDING - 20 - panelY;
super.init();
int panelY = PADDING + headerLines.length * font.FONT_HEIGHT + PADDING;
int panelHeight = this.height - PADDING - 20 - panelY;
if (!action.isEmpty()) {
panelHeight = panelHeight - field_230712_o_.FONT_HEIGHT - PADDING;
panelHeight = panelHeight - font.FONT_HEIGHT - PADDING;
}
textPanel = new TextPanel(this.field_230706_i_, this.field_230708_k_ - (PADDING * 2), panelHeight, panelY, PADDING);
this.field_230705_e_.add(textPanel);
textPanel = new TextPanel(this.minecraft, this.width - (PADDING * 2), panelHeight, panelY, PADDING);
this.children.add(textPanel);
addConfirmationButtons();
}
protected void addConfirmationButtons() {
this.field_230710_m_.add(new Button(this.field_230708_k_ / 2 - 100, this.field_230709_l_ - PADDING - 20, 200, 20, new TranslationTextComponent("gui.done"), b -> {
NotificationScreen.this.field_230706_i_.displayGuiScreen(null);
this.buttons.add(new Button(this.width / 2 - 100, this.height - PADDING - 20, 200, 20, new TranslationTextComponent("gui.done"), b -> {
NotificationScreen.this.minecraft.displayGuiScreen(null);
query.finish();
}));
}
@Override
public void func_230430_a_(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
public void render(MatrixStack mStack, int mouseX, int mouseY, float partialTicks)
{
this.func_230446_a_(mStack);
this.renderBackground(mStack);
drawCenteredLines(mStack, PADDING, headerLines);
if (textPanel != null)
{
textPanel.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
textPanel.render(mStack, mouseX, mouseY, partialTicks);
}
if (!action.isEmpty())
{
func_238471_a_(mStack, field_230712_o_, action, this.field_230708_k_ / 2, this.field_230709_l_ - PADDING - 20 - field_230712_o_.FONT_HEIGHT, -1);
drawCenteredString(mStack, font, action, this.width / 2, this.height - PADDING - 20 - font.FONT_HEIGHT, -1);
}
super.func_230430_a_(mStack, mouseX, mouseY, partialTicks);
super.render(mStack, mouseX, mouseY, partialTicks);
}
protected void drawCenteredLines(MatrixStack mStack, int yStart, String... lines)
@@ -125,8 +125,8 @@ public class NotificationScreen extends Screen
for (String line : lines)
{
if (!line.isEmpty())
this.func_238471_a_(mStack, field_230712_o_, line, this.field_230708_k_ / 2, yStart, 0xFFFFFF);
yStart += field_230712_o_.FONT_HEIGHT;
this.drawCenteredString(mStack, font, line, this.width / 2, yStart, 0xFFFFFF);
yStart += font.FONT_HEIGHT;
}
}
}
@@ -26,6 +26,8 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import net.minecraft.client.gui.widget.button.Button.IPressable;
/**
* This class provides a button that fixes several bugs present in the vanilla GuiButton drawing code.
* The gist of it is that it allows buttons of any size without gaps in the graphics and with the
@@ -58,14 +60,14 @@ public class ExtendedButton extends Button
this.renderBg(mStack, mc, mouseX, mouseY);
ITextComponent buttonText = this.getMessage();
int strWidth = mc.fontRenderer.getStringPropertyWidth(buttonText);
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
int strWidth = mc.font.width(buttonText);
int ellipsisWidth = mc.font.width("...");
if (strWidth > width - 6 && strWidth > ellipsisWidth)
//TODO, srg names make it hard to figure out how to append to an ITextProperties from this trim operation, wraping this in StringTextComponent is kinda dirty.
buttonText = new StringTextComponent(mc.fontRenderer.func_238417_a_(buttonText, width - 6 - ellipsisWidth).getString() + "...");
buttonText = new StringTextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "...");
drawCenteredString(mStack, mc.fontRenderer, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor());
drawCenteredString(mStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor());
}
}
}
@@ -39,7 +39,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
{
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripControlCodes(value); }
private static String stripControlCodes(String value) { return net.minecraft.util.StringUtils.stripColor(value); }
private static final ResourceLocation VERSION_CHECK_ICONS = new ResourceLocation(ForgeVersion.MOD_ID, "textures/gui/version_check_icons.png");
private final int listWidth;
@@ -47,7 +47,7 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
public ModListWidget(ModListScreen parent, int listWidth, int top, int bottom)
{
super(parent.getMinecraftInstance(), listWidth, parent.height, top, bottom, parent.getFontRenderer().FONT_HEIGHT * 2 + 8);
super(parent.getMinecraftInstance(), listWidth, parent.height, top, bottom, parent.getFontRenderer().lineHeight * 2 + 8);
this.parent = parent;
this.listWidth = listWidth;
this.refreshList();
@@ -92,12 +92,12 @@ public class ModListWidget extends ExtendedList<ModListWidget.ModEntry>
ITextComponent version = new StringTextComponent(stripControlCodes(MavenVersionStringHelper.artifactVersionToString(modInfo.getVersion())));
VersionChecker.CheckResult vercheck = VersionChecker.getResult(modInfo);
FontRenderer font = this.parent.getFontRenderer();
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(font.func_238417_a_(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
font.func_238422_b_(mStack, LanguageMap.getInstance().func_241870_a(ITextProperties.func_240655_a_(font.func_238417_a_(version, listWidth))), left + 3, top + 2 + font.FONT_HEIGHT, 0xCCCCCC);
font.draw(mStack, LanguageMap.getInstance().getVisualOrder(ITextProperties.composite(font.substrByWidth(name, listWidth))), left + 3, top + 2, 0xFFFFFF);
font.draw(mStack, LanguageMap.getInstance().getVisualOrder(ITextProperties.composite(font.substrByWidth(version, listWidth))), left + 3, top + 2 + font.lineHeight, 0xCCCCCC);
if (vercheck.status.shouldDraw())
{
//TODO: Consider adding more icons for visualization
Minecraft.getInstance().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
Minecraft.getInstance().getTextureManager().bind(VERSION_CHECK_ICONS);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.pushMatrix();
AbstractGui.blit(mStack, getLeft() + width - 12, top + entryHeight / 4, vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
@@ -27,6 +27,8 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
import javax.annotation.Nullable;
import net.minecraft.client.gui.widget.button.Button.IPressable;
/**
* This class is blatantly stolen from iChunUtils with permission.
*
@@ -82,7 +84,7 @@ public class Slider extends ExtendedButton
precision = 0;
}
setMessage(new StringTextComponent("").append(dispString).appendString(val).append(suffix));
setMessage(new StringTextComponent("").append(dispString).append(val).append(suffix));
drawString = drawStr;
if(!drawString)
@@ -176,7 +178,7 @@ public class Slider extends ExtendedButton
if(drawString)
{
setMessage(new StringTextComponent("").append(dispString).appendString(val).append(suffix));
setMessage(new StringTextComponent("").append(dispString).append(val).append(suffix));
}
if (parent != null)
@@ -27,6 +27,8 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import net.minecraft.client.gui.widget.button.Button.IPressable;
/**
* This class provides a button that shows a string glyph at the beginning. The glyph can be scaled using the glyphScale parameter.
*
@@ -55,26 +57,26 @@ public class UnicodeGlyphButton extends ExtendedButton
GuiUtils.drawContinuousTexturedBox(mStack, Button.WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset());
this.renderBg(mStack, mc, mouseX, mouseY);
ITextComponent buttonText = this.getNarrationMessage();
int glyphWidth = (int) (mc.fontRenderer.getStringWidth(glyph) * glyphScale);
int strWidth = mc.fontRenderer.getStringPropertyWidth(buttonText);
int ellipsisWidth = mc.fontRenderer.getStringWidth("...");
ITextComponent buttonText = this.createNarrationMessage();
int glyphWidth = (int) (mc.font.width(glyph) * glyphScale);
int strWidth = mc.font.width(buttonText);
int ellipsisWidth = mc.font.width("...");
int totalWidth = strWidth + glyphWidth;
if (totalWidth > width - 6 && totalWidth > ellipsisWidth)
buttonText = new StringTextComponent(mc.fontRenderer.func_238417_a_(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ;
buttonText = new StringTextComponent(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString().trim() + "...") ;
strWidth = mc.fontRenderer.getStringPropertyWidth(buttonText);
strWidth = mc.font.width(buttonText);
totalWidth = glyphWidth + strWidth;
mStack.push();
mStack.pushPose();
mStack.scale(glyphScale, glyphScale, 1.0F);
this.drawCenteredString(mStack, mc.fontRenderer, new StringTextComponent(glyph),
this.drawCenteredString(mStack, mc.font, new StringTextComponent(glyph),
(int) (((this.x + (this.width / 2) - (strWidth / 2)) / glyphScale) - (glyphWidth / (2 * glyphScale)) + 2),
(int) (((this.y + ((this.height - 8) / glyphScale) / 2) - 1) / glyphScale), getFGColor());
mStack.pop();
mStack.popPose();
this.drawCenteredString(mStack, mc.fontRenderer, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)),
this.drawCenteredString(mStack, mc.font, buttonText, (int) (this.x + (this.width / 2) + (glyphWidth / glyphScale)),
this.y + (this.height - 8) / 2, getFGColor());
}
@@ -56,7 +56,7 @@ public class ClientRegistry
*/
public static synchronized void registerKeyBinding(KeyBinding key)
{
Minecraft.getInstance().gameSettings.keyBindings = ArrayUtils.add(Minecraft.getInstance().gameSettings.keyBindings, key);
Minecraft.getInstance().options.keyMappings = ArrayUtils.add(Minecraft.getInstance().options.keyMappings, key);
}
/**
@@ -47,7 +47,7 @@ public class PacketLoggingHandler
{
ChannelPipeline pipeline = manager.channel().pipeline();
final PacketDirection direction = manager.getDirection();
if (manager.isLocalChannel())
if (manager.isMemoryConnection())
{
pipeline.addBefore("packet_handler", "splitter", new SimpleChannelInboundHandler<IPacket<?>>()
{
@@ -56,7 +56,7 @@ public class PacketLoggingHandler
protected void channelRead0(ChannelHandlerContext ctx, IPacket<?> msg) throws Exception
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
msg.writePacketData(buf);
msg.write(buf);
LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
ctx.fireChannelRead(msg);
}
@@ -70,7 +70,7 @@ public class PacketLoggingHandler
if (msg instanceof IPacket<?>)
{
PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
((IPacket<?>)msg).writePacketData(buf);
((IPacket<?>)msg).write(buf);
LOGGER.debug("{} {}:\n{}", prefix, msg.getClass().getSimpleName(), ByteBufUtils.getContentDump(buf));
}
ctx.write(msg, promise);
@@ -117,7 +117,7 @@ public class ConfigTracker {
}
public void receiveSyncedConfig(final FMLHandshakeMessages.S2CConfigData s2CConfigData, final Supplier<NetworkEvent.Context> contextSupplier) {
if (!Minecraft.getInstance().isIntegratedServerRunning()) {
if (!Minecraft.getInstance().isLocalServer()) {
Optional.ofNullable(fileMap.get(s2CConfigData.getFileName())).ifPresent(mc-> {
mc.setConfigData(TomlFormat.instance().createParser().parse(new ByteArrayInputStream(s2CConfigData.getBytes())));
mc.fireEvent(new ModConfig.Reloading(mc));
@@ -35,6 +35,8 @@ import java.util.function.Supplier;
import static net.minecraftforge.fml.Logging.LOADING;
import net.minecraftforge.forgespi.language.IModLanguageProvider.IModLanguageLoader;
public class MinecraftModLanguageProvider implements IModLanguageProvider {
private static final Logger LOGGER = LogManager.getLogger();
@Override
@@ -117,7 +117,7 @@ public class FMLHandshakeHandler {
{
this.direction = side;
this.manager = networkManager;
if (networkManager.isLocalChannel()) {
if (networkManager.isMemoryConnection()) {
this.messageList = NetworkRegistry.gatherLoginPayloads(this.direction, true);
LOGGER.debug(FMLHSMARKER, "Starting local connection.");
} else if (NetworkHooks.getConnectionType(()->this.manager)==ConnectionType.VANILLA) {
@@ -176,7 +176,7 @@ public class FMLHandshakeHandler {
c.get().setPacketHandled(true);
if (!accepted) {
LOGGER.error(FMLHSMARKER, "Terminating connection with server, mismatched mod list");
c.get().getNetworkManager().closeChannel(new StringTextComponent("Connection closed - mismatched mod channel list"));
c.get().getNetworkManager().disconnect(new StringTextComponent("Connection closed - mismatched mod channel list"));
return;
}
FMLNetworkConstants.handshakeChannel.reply(new FMLHandshakeMessages.C2SModListReply(), c.get());
@@ -206,7 +206,7 @@ public class FMLHandshakeHandler {
c.get().setPacketHandled(true);
if (!accepted) {
LOGGER.error(FMLHSMARKER, "Terminating connection with client, mismatched mod list");
c.get().getNetworkManager().closeChannel(new StringTextComponent("Connection closed - mismatched mod channel list"));
c.get().getNetworkManager().disconnect(new StringTextComponent("Connection closed - mismatched mod channel list"));
return;
}
LOGGER.debug(FMLHSMARKER, "Accepted client connection mod list");
@@ -255,7 +255,7 @@ public class FMLHandshakeHandler {
LOGGER.debug(FMLHSMARKER, "Registry load complete, continuing handshake.");
} else {
LOGGER.error(FMLHSMARKER, "Failed to load registry, closing connection.");
this.manager.closeChannel(new StringTextComponent("Failed to synchronize registry data from server, closing connection"));
this.manager.disconnect(new StringTextComponent("Failed to synchronize registry data from server, closing connection"));
}
return successfulConnection.get();
}
@@ -85,12 +85,12 @@ public class FMLHandshakeMessages
List<String> mods = new ArrayList<>();
int len = input.readVarInt();
for (int x = 0; x < len; x++)
mods.add(input.readString(0x100));
mods.add(input.readUtf(0x100));
Map<ResourceLocation, String> channels = new HashMap<>();
len = input.readVarInt();
for (int x = 0; x < len; x++)
channels.put(input.readResourceLocation(), input.readString(0x100));
channels.put(input.readResourceLocation(), input.readUtf(0x100));
List<ResourceLocation> registries = new ArrayList<>();
len = input.readVarInt();
@@ -103,12 +103,12 @@ public class FMLHandshakeMessages
public void encode(PacketBuffer output)
{
output.writeVarInt(mods.size());
mods.forEach(m -> output.writeString(m, 0x100));
mods.forEach(m -> output.writeUtf(m, 0x100));
output.writeVarInt(channels.size());
channels.forEach((k, v) -> {
output.writeResourceLocation(k);
output.writeString(v, 0x100);
output.writeUtf(v, 0x100);
});
output.writeVarInt(registries.size());
@@ -153,17 +153,17 @@ public class FMLHandshakeMessages
List<String> mods = new ArrayList<>();
int len = input.readVarInt();
for (int x = 0; x < len; x++)
mods.add(input.readString(0x100));
mods.add(input.readUtf(0x100));
Map<ResourceLocation, String> channels = new HashMap<>();
len = input.readVarInt();
for (int x = 0; x < len; x++)
channels.put(input.readResourceLocation(), input.readString(0x100));
channels.put(input.readResourceLocation(), input.readUtf(0x100));
Map<ResourceLocation, String> registries = new HashMap<>();
len = input.readVarInt();
for (int x = 0; x < len; x++)
registries.put(input.readResourceLocation(), input.readString(0x100));
registries.put(input.readResourceLocation(), input.readUtf(0x100));
return new C2SModListReply(mods, channels, registries);
}
@@ -171,18 +171,18 @@ public class FMLHandshakeMessages
public void encode(PacketBuffer output)
{
output.writeVarInt(mods.size());
mods.forEach(m -> output.writeString(m, 0x100));
mods.forEach(m -> output.writeUtf(m, 0x100));
output.writeVarInt(channels.size());
channels.forEach((k, v) -> {
output.writeResourceLocation(k);
output.writeString(v, 0x100);
output.writeUtf(v, 0x100);
});
output.writeVarInt(registries.size());
registries.forEach((k, v) -> {
output.writeResourceLocation(k);
output.writeString(v, 0x100);
output.writeUtf(v, 0x100);
});
}
@@ -259,12 +259,12 @@ public class FMLHandshakeMessages
}
void encode(final PacketBuffer buffer) {
buffer.writeString(this.fileName);
buffer.writeUtf(this.fileName);
buffer.writeByteArray(this.fileData);
}
public static S2CConfigData decode(final PacketBuffer buffer) {
return new S2CConfigData(buffer.readString(32767), buffer.readByteArray());
return new S2CConfigData(buffer.readUtf(32767), buffer.readByteArray());
}
public String getFileName() {
@@ -81,6 +81,6 @@ public class FMLLoginWrapper {
void sendServerToClientLoginPacket(final ResourceLocation resourceLocation, final PacketBuffer buffer, final int index, final NetworkManager manager) {
PacketBuffer pb = wrapPacket(resourceLocation, buffer);
manager.sendPacket(NetworkDirection.LOGIN_TO_CLIENT.buildPacket(Pair.of(pb, index), WRAPPER).getThis());
manager.send(NetworkDirection.LOGIN_TO_CLIENT.buildPacket(Pair.of(pb, index), WRAPPER).getThis());
}
}
@@ -116,6 +116,6 @@ public class FMLMCRegisterPacketHandler {
PacketBuffer pb = new PacketBuffer(Unpooled.buffer());
pb.writeBytes(getFrom(manager).toByteArray());
final ICustomPacket<IPacket<?>> iPacketICustomPacket = dir.buildPacket(Pair.of(pb, 0), FMLNetworkConstants.MC_REGISTER_RESOURCE);
manager.sendPacket(iPacketICustomPacket.getThis());
manager.send(iPacketICustomPacket.getThis());
}
}
@@ -86,15 +86,15 @@ public class FMLPlayMessages
{
this.entity = e;
this.typeId = Registry.ENTITY_TYPE.getId(e.getType()); //TODO: Codecs
this.entityId = e.getEntityId();
this.uuid = e.getUniqueID();
this.posX = e.getPosX();
this.posY = e.getPosY();
this.posZ = e.getPosZ();
this.pitch = (byte) MathHelper.floor(e.rotationPitch * 256.0F / 360.0F);
this.yaw = (byte) MathHelper.floor(e.rotationYaw * 256.0F / 360.0F);
this.headYaw = (byte) (e.getRotationYawHead() * 256.0F / 360.0F);
Vector3d vec3d = e.getMotion();
this.entityId = e.getId();
this.uuid = e.getUUID();
this.posX = e.getX();
this.posY = e.getY();
this.posZ = e.getZ();
this.pitch = (byte) MathHelper.floor(e.xRot * 256.0F / 360.0F);
this.yaw = (byte) MathHelper.floor(e.yRot * 256.0F / 360.0F);
this.headYaw = (byte) (e.getYHeadRot() * 256.0F / 360.0F);
Vector3d vec3d = e.getDeltaMovement();
double d1 = MathHelper.clamp(vec3d.x, -3.9D, 3.9D);
double d2 = MathHelper.clamp(vec3d.y, -3.9D, 3.9D);
double d3 = MathHelper.clamp(vec3d.z, -3.9D, 3.9D);
@@ -160,7 +160,7 @@ public class FMLPlayMessages
public static void handle(SpawnEntity msg, Supplier<NetworkEvent.Context> ctx)
{
ctx.get().enqueueWork(() -> {
EntityType<?> type = Registry.ENTITY_TYPE.getByValue(msg.typeId);
EntityType<?> type = Registry.ENTITY_TYPE.byId(msg.typeId);
if (type == null)
{
throw new RuntimeException(String.format("Could not spawn entity (id %d) with unknown type at (%f, %f, %f)", msg.entityId, msg.posX, msg.posY, msg.posZ));
@@ -174,14 +174,14 @@ public class FMLPlayMessages
}
e.setPacketCoordinates(msg.posX, msg.posY, msg.posZ);
e.setPositionAndRotation(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F);
e.setRotationYawHead((msg.headYaw * 360) / 256.0F);
e.setRenderYawOffset((msg.headYaw * 360) / 256.0F);
e.absMoveTo(msg.posX, msg.posY, msg.posZ, (msg.yaw * 360) / 256.0F, (msg.pitch * 360) / 256.0F);
e.setYHeadRot((msg.headYaw * 360) / 256.0F);
e.setYBodyRot((msg.headYaw * 360) / 256.0F);
e.setEntityId(msg.entityId);
e.setUniqueId(msg.uuid);
world.filter(ClientWorld.class::isInstance).ifPresent(w->((ClientWorld)w).addEntity(msg.entityId, e));
e.setVelocity(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0);
e.setId(msg.entityId);
e.setUUID(msg.uuid);
world.filter(ClientWorld.class::isInstance).ifPresent(w->((ClientWorld)w).putNonPlayerEntity(msg.entityId, e));
e.lerpMotion(msg.velX / 8000.0, msg.velY / 8000.0, msg.velZ / 8000.0);
if (e instanceof IEntityAdditionalSpawnData)
{
((IEntityAdditionalSpawnData) e).readSpawnData(msg.buf);
@@ -285,13 +285,13 @@ public class FMLPlayMessages
{
buf.writeVarInt(msg.id);
buf.writeVarInt(msg.windowId);
buf.writeTextComponent(msg.name);
buf.writeComponent(msg.name);
buf.writeByteArray(msg.additionalData.readByteArray());
}
public static OpenContainer decode(PacketBuffer buf)
{
return new OpenContainer(buf.readVarInt(), buf.readVarInt(), buf.readTextComponent(), new PacketBuffer(Unpooled.wrappedBuffer(buf.readByteArray(32600))));
return new OpenContainer(buf.readVarInt(), buf.readVarInt(), buf.readComponent(), new PacketBuffer(Unpooled.wrappedBuffer(buf.readByteArray(32600))));
}
public static void handle(OpenContainer msg, Supplier<NetworkEvent.Context> ctx)
@@ -302,15 +302,15 @@ public class FMLPlayMessages
Container c = msg.getType().create(msg.getWindowId(), Minecraft.getInstance().player.inventory, msg.getAdditionalData());
@SuppressWarnings("unchecked")
Screen s = ((ScreenManager.IScreenFactory<Container, ?>)f).create(c, Minecraft.getInstance().player.inventory, msg.getName());
Minecraft.getInstance().player.openContainer = ((IHasContainer<?>)s).getContainer();
Minecraft.getInstance().displayGuiScreen(s);
Minecraft.getInstance().player.containerMenu = ((IHasContainer<?>)s).getMenu();
Minecraft.getInstance().setScreen(s);
});
});
ctx.get().setPacketHandled(true);
}
public final ContainerType<?> getType() {
return Registry.MENU.getByValue(this.id);
return Registry.MENU.byId(this.id);
}
public int getWindowId() {
@@ -344,7 +344,7 @@ public class FMLPlayMessages
public static void encode(SyncCustomTagTypes msg, PacketBuffer buf)
{
buf.writeVarInt(msg.customTagTypeCollections.size());
msg.customTagTypeCollections.forEach((registryName, modded) -> forgeTagCollectionWrite(buf, registryName, modded.getIDTagMap()));
msg.customTagTypeCollections.forEach((registryName, modded) -> forgeTagCollectionWrite(buf, registryName, modded.getAllTags()));
}
private static <T> void forgeTagCollectionWrite(PacketBuffer buf, ResourceLocation registryName, Map<ResourceLocation, ITag<T>> tags)
@@ -353,7 +353,7 @@ public class FMLPlayMessages
buf.writeVarInt(tags.size());
tags.forEach((name, tag) -> {
buf.writeResourceLocation(name);
List<T> elements = tag.getAllElements();
List<T> elements = tag.getValues();
buf.writeVarInt(elements.size());
for (T element : elements)
{
@@ -395,29 +395,29 @@ public class FMLPlayMessages
elementBuilder.add(element);
}
}
tags.put(name, ITag.getTagOf(elementBuilder.build()));
tags.put(name, ITag.fromSet(elementBuilder.build()));
}
return ITagCollection.getTagCollectionFromMap(tags);
return ITagCollection.of(tags);
}
public static void handle(SyncCustomTagTypes msg, Supplier<NetworkEvent.Context> ctx)
{
ctx.get().enqueueWork(() -> {
if (Minecraft.getInstance().world != null)
if (Minecraft.getInstance().level != null)
{
ITagCollectionSupplier tagCollectionSupplier = Minecraft.getInstance().world.getTags();
ITagCollectionSupplier tagCollectionSupplier = Minecraft.getInstance().level.getTagManager();
//Validate that all the tags exist using the tag type collections from the packet
// We mimic vanilla in that we validate before updating the actual stored tags so that it can gracefully fallback
// to the last working set of tags
//Note: We gracefully ignore any tag types the server may have that we don't as they won't be in our tag registry
// so they won't be validated
//Override and use the tags from the packet to test for validation before we actually set them
Multimap<ResourceLocation, ResourceLocation> missingTags = TagRegistryManager.validateTags(ForgeTagHandler.withSpecificCustom(tagCollectionSupplier, msg.customTagTypeCollections));
Multimap<ResourceLocation, ResourceLocation> missingTags = TagRegistryManager.getAllMissingTags(ForgeTagHandler.withSpecificCustom(tagCollectionSupplier, msg.customTagTypeCollections));
if (missingTags.isEmpty())
{
//If we have no missing tags, update the custom tag types
ForgeTagHandler.updateCustomTagTypes(msg);
if (!ctx.get().getNetworkManager().isLocalChannel())
if (!ctx.get().getNetworkManager().isMemoryConnection())
{
//And if everything hasn't already been set due to being in single player
// Fetch and update the custom tag types. We skip vanilla tag types as they have already been fetched
@@ -427,7 +427,7 @@ public class FMLPlayMessages
}
} else {
LOGGER.warn("Incomplete server tags, disconnecting. Missing: {}", missingTags);
ctx.get().getNetworkManager().closeChannel(new TranslationTextComponent("multiplayer.disconnect.missing_tags"));
ctx.get().getNetworkManager().disconnect(new TranslationTextComponent("multiplayer.disconnect.missing_tags"));
}
}
});
@@ -85,17 +85,17 @@ public class FMLStatusPing {
public static class Serializer {
public static FMLStatusPing deserialize(JsonObject forgeData, JsonDeserializationContext ctx) {
try {
final Map<ResourceLocation, Pair<String, Boolean>> channels = StreamSupport.stream(JSONUtils.getJsonArray(forgeData, "channels").spliterator(), false).
final Map<ResourceLocation, Pair<String, Boolean>> channels = StreamSupport.stream(JSONUtils.getAsJsonArray(forgeData, "channels").spliterator(), false).
map(JsonElement::getAsJsonObject).
collect(Collectors.toMap(jo -> new ResourceLocation(JSONUtils.getString(jo, "res")),
jo -> Pair.of(JSONUtils.getString(jo, "version"), JSONUtils.getBoolean(jo, "required")))
collect(Collectors.toMap(jo -> new ResourceLocation(JSONUtils.getAsString(jo, "res")),
jo -> Pair.of(JSONUtils.getAsString(jo, "version"), JSONUtils.getAsBoolean(jo, "required")))
);
final Map<String, String> mods = StreamSupport.stream(JSONUtils.getJsonArray(forgeData, "mods").spliterator(), false).
final Map<String, String> mods = StreamSupport.stream(JSONUtils.getAsJsonArray(forgeData, "mods").spliterator(), false).
map(JsonElement::getAsJsonObject).
collect(Collectors.toMap(jo -> JSONUtils.getString(jo, "modId"), jo->JSONUtils.getString(jo, "modmarker")));
collect(Collectors.toMap(jo -> JSONUtils.getAsString(jo, "modId"), jo->JSONUtils.getAsString(jo, "modmarker")));
final int remoteFMLVersion = JSONUtils.getInt(forgeData, "fmlNetworkVersion");
final int remoteFMLVersion = JSONUtils.getAsInt(forgeData, "fmlNetworkVersion");
return new FMLStatusPing(channels, mods, remoteFMLVersion);
} catch (JsonSyntaxException e) {
LOGGER.debug(NETWORK, "Encountered an error parsing status ping data", e);
@@ -209,8 +209,8 @@ public class NetworkEvent extends Event
ThreadTaskExecutor<?> executor = LogicalSidedProvider.WORKQUEUE.get(getDirection().getReceptionSide());
// Must check ourselves as Minecraft will sometimes delay tasks even when they are received on the client thread
// Same logic as ThreadTaskExecutor#runImmediately without the join
if (!executor.isOnExecutionThread()) {
return executor.deferTask(runnable); // Use the internal method so thread check isn't done twice
if (!executor.isSameThread()) {
return executor.submitAsync(runnable); // Use the internal method so thread check isn't done twice
} else {
runnable.run();
return CompletableFuture.completedFuture(null);
@@ -223,7 +223,7 @@ public class NetworkEvent extends Event
@Nullable
public ServerPlayerEntity getSender()
{
INetHandler netHandler = networkManager.getNetHandler();
INetHandler netHandler = networkManager.getPacketListener();
if (netHandler instanceof ServerPlayNetHandler)
{
ServerPlayNetHandler netHandlerPlayServer = (ServerPlayNetHandler) netHandler;
@@ -90,7 +90,7 @@ public class NetworkHooks
private static boolean validateSideForProcessing(final ICustomPacket<?> packet, final NetworkInstance ni, final NetworkManager manager) {
if (packet.getDirection().getReceptionSide() != EffectiveSide.get()) {
manager.closeChannel(new StringTextComponent("Illegal packet received, terminating connection"));
manager.disconnect(new StringTextComponent("Illegal packet received, terminating connection"));
return false;
}
return true;
@@ -98,7 +98,7 @@ public class NetworkHooks
public static void validatePacketDirection(final NetworkDirection packetDirection, final Optional<NetworkDirection> expectedDirection, final NetworkManager connection) {
if (packetDirection != expectedDirection.orElse(packetDirection)) {
connection.closeChannel(new StringTextComponent("Illegal packet received, terminating connection"));
connection.disconnect(new StringTextComponent("Illegal packet received, terminating connection"));
throw new IllegalStateException("Invalid packet received, aborting connection");
}
}
@@ -204,10 +204,10 @@ public class NetworkHooks
*/
public static void openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, Consumer<PacketBuffer> extraDataWriter)
{
if (player.world.isRemote) return;
player.closeContainer();
player.getNextWindowId();
int openContainerId = player.currentWindowId;
if (player.level.isClientSide) return;
player.doCloseContainer();
player.nextContainerCounter();
int openContainerId = player.containerCounter;
PacketBuffer extraData = new PacketBuffer(Unpooled.buffer());
extraDataWriter.accept(extraData);
extraData.readerIndex(0); // reset to beginning in case modders read for whatever reason
@@ -222,10 +222,10 @@ public class NetworkHooks
Container c = containerSupplier.createMenu(openContainerId, player.inventory, player);
ContainerType<?> type = c.getType();
FMLPlayMessages.OpenContainer msg = new FMLPlayMessages.OpenContainer(type, openContainerId, containerSupplier.getDisplayName(), output);
FMLNetworkConstants.playChannel.sendTo(msg, player.connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT);
FMLNetworkConstants.playChannel.sendTo(msg, player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT);
player.openContainer = c;
player.openContainer.addListener(player);
player.containerMenu = c;
player.containerMenu.addSlotListener(player);
MinecraftForge.EVENT_BUS.post(new PlayerContainerEvent.Open(player, c));
}
@@ -252,7 +252,7 @@ public class NetworkHooks
Map<ResourceLocation, ITagCollection<?>> customTagTypes = tagCollectionSupplier.getCustomTagTypes();
if (!customTagTypes.isEmpty())
{
FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.SyncCustomTagTypes(customTagTypes), player.connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT);
FMLNetworkConstants.playChannel.sendTo(new FMLPlayMessages.SyncCustomTagTypes(customTagTypes), player.connection.getConnection(), NetworkDirection.PLAY_TO_CLIENT);
}
}
}
@@ -61,7 +61,7 @@ public class PacketDispatcher {
private void dispatchPacket(final ResourceLocation resourceLocation, final PacketBuffer buffer) {
final ICustomPacket<?> packet = this.customPacketSupplier.apply(Pair.of(buffer, packetIndex), resourceLocation);
this.manager.sendPacket(packet.getThis());
this.manager.send(packet.getThis());
}
}
}
@@ -214,50 +214,50 @@ public class PacketDistributor<T> {
}
private Consumer<IPacket<?>> playerConsumer(final Supplier<ServerPlayerEntity> entityPlayerMPSupplier) {
return p -> entityPlayerMPSupplier.get().connection.netManager.sendPacket(p);
return p -> entityPlayerMPSupplier.get().connection.connection.send(p);
}
private Consumer<IPacket<?>> playerListDimConsumer(final Supplier<RegistryKey<World>> dimensionTypeSupplier) {
return p->getServer().getPlayerList().func_232642_a_(p, dimensionTypeSupplier.get());
return p->getServer().getPlayerList().broadcastAll(p, dimensionTypeSupplier.get());
}
private Consumer<IPacket<?>> playerListAll(final Supplier<Void> voidSupplier) {
return p -> getServer().getPlayerList().sendPacketToAllPlayers(p);
return p -> getServer().getPlayerList().broadcastAll(p);
}
private Consumer<IPacket<?>> clientToServer(final Supplier<Void> voidSupplier) {
return p -> Minecraft.getInstance().getConnection().sendPacket(p);
return p -> Minecraft.getInstance().getConnection().send(p);
}
private Consumer<IPacket<?>> playerListPointConsumer(final Supplier<TargetPoint> targetPointSupplier) {
return p -> {
final TargetPoint tp = targetPointSupplier.get();
getServer().getPlayerList().sendToAllNearExcept(tp.excluded, tp.x, tp.y, tp.z, tp.r2, tp.dim, p);
getServer().getPlayerList().broadcast(tp.excluded, tp.x, tp.y, tp.z, tp.r2, tp.dim, p);
};
}
private Consumer<IPacket<?>> trackingEntity(final Supplier<Entity> entitySupplier) {
return p-> {
final Entity entity = entitySupplier.get();
((ServerChunkProvider)entity.getEntityWorld().getChunkProvider()).sendToAllTracking(entity, p);
((ServerChunkProvider)entity.getCommandSenderWorld().getChunkSource()).broadcast(entity, p);
};
}
private Consumer<IPacket<?>> trackingEntityAndSelf(final Supplier<Entity> entitySupplier) {
return p-> {
final Entity entity = entitySupplier.get();
((ServerChunkProvider)entity.getEntityWorld().getChunkProvider()).sendToTrackingAndSelf(entity, p);
((ServerChunkProvider)entity.getCommandSenderWorld().getChunkSource()).broadcastAndSend(entity, p);
};
}
private Consumer<IPacket<?>> trackingChunk(final Supplier<Chunk> chunkPosSupplier) {
return p -> {
final Chunk chunk = chunkPosSupplier.get();
((ServerChunkProvider)chunk.getWorld().getChunkProvider()).chunkManager.getTrackingPlayers(chunk.getPos(), false).forEach(e -> e.connection.sendPacket(p));
((ServerChunkProvider)chunk.getLevel().getChunkSource()).chunkMap.getPlayers(chunk.getPos(), false).forEach(e -> e.connection.send(p));
};
}
private Consumer<IPacket<?>> networkManagerList(final Supplier<List<NetworkManager>> nmListSupplier) {
return p -> nmListSupplier.get().forEach(nm->nm.sendPacket(p));
return p -> nmListSupplier.get().forEach(nm->nm.send(p));
}
private MinecraftServer getServer() {
@@ -101,12 +101,12 @@ public class SimpleChannel
public <MSG> void sendToServer(MSG message)
{
sendTo(message, Minecraft.getInstance().getConnection().getNetworkManager(), NetworkDirection.PLAY_TO_SERVER);
sendTo(message, Minecraft.getInstance().getConnection().getConnection(), NetworkDirection.PLAY_TO_SERVER);
}
public <MSG> void sendTo(MSG message, NetworkManager manager, NetworkDirection direction)
{
manager.sendPacket(toVanillaPacket(message, direction));
manager.send(toVanillaPacket(message, direction));
}
/**
@@ -61,7 +61,7 @@ public class DelegatingResourcePack extends ResourcePack
Map<String, List<IResourcePack>> map = new HashMap<>();
for (IResourcePack pack : packList)
{
for (String namespace : pack.getResourceNamespaces(type))
for (String namespace : pack.getNamespaces(type))
{
map.computeIfAbsent(namespace, k -> new ArrayList<>()).add(pack);
}
@@ -78,9 +78,9 @@ public class DelegatingResourcePack extends ResourcePack
@SuppressWarnings("unchecked")
@Override
public <T> T getMetadata(IMetadataSectionSerializer<T> deserializer) throws IOException
public <T> T getMetadataSection(IMetadataSectionSerializer<T> deserializer) throws IOException
{
if (deserializer.getSectionName().equals("pack"))
if (deserializer.getMetadataSectionName().equals("pack"))
{
return (T) packInfo;
}
@@ -88,15 +88,15 @@ public class DelegatingResourcePack extends ResourcePack
}
@Override
public Collection<ResourceLocation> getAllResourceLocations(ResourcePackType type, String pathIn, String pathIn2, int maxDepth, Predicate<String> filter)
public Collection<ResourceLocation> getResources(ResourcePackType type, String pathIn, String pathIn2, int maxDepth, Predicate<String> filter)
{
return delegates.stream()
.flatMap(r -> r.getAllResourceLocations(type, pathIn, pathIn2, maxDepth, filter).stream())
.flatMap(r -> r.getResources(type, pathIn, pathIn2, maxDepth, filter).stream())
.collect(Collectors.toList());
}
@Override
public Set<String> getResourceNamespaces(ResourcePackType type)
public Set<String> getNamespaces(ResourcePackType type)
{
return type == ResourcePackType.CLIENT_RESOURCES ? namespacesAssets.keySet() : namespacesData.keySet();
}
@@ -111,45 +111,45 @@ public class DelegatingResourcePack extends ResourcePack
}
@Override
public InputStream getRootResourceStream(String fileName) throws IOException
public InputStream getRootResource(String fileName) throws IOException
{
// root resources do not make sense here
throw new ResourcePackFileNotFoundException(this.file, fileName);
}
@Override
protected InputStream getInputStream(String resourcePath) throws IOException
protected InputStream getResource(String resourcePath) throws IOException
{
// never called, we override all methods that call this
throw new ResourcePackFileNotFoundException(this.file, resourcePath);
}
@Override
protected boolean resourceExists(String resourcePath)
protected boolean hasResource(String resourcePath)
{
// never called, we override all methods that call this
return false;
}
@Override
public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException
public InputStream getResource(ResourcePackType type, ResourceLocation location) throws IOException
{
for (IResourcePack pack : getCandidatePacks(type, location))
{
if (pack.resourceExists(type, location))
if (pack.hasResource(type, location))
{
return pack.getResourceStream(type, location);
return pack.getResource(type, location);
}
}
throw new ResourcePackFileNotFoundException(this.file, getFullPath(type, location));
}
@Override
public boolean resourceExists(ResourcePackType type, ResourceLocation location)
public boolean hasResource(ResourcePackType type, ResourceLocation location)
{
for (IResourcePack pack : getCandidatePacks(type, location))
{
if (pack.resourceExists(type, location))
if (pack.hasResource(type, location))
{
return true;
}
@@ -167,7 +167,7 @@ public class DelegatingResourcePack extends ResourcePack
private static String getFullPath(ResourcePackType type, ResourceLocation location)
{
// stolen from ResourcePack
return String.format("%s/%s/%s", type.getDirectoryName(), location.getNamespace(), location.getPath());
return String.format("%s/%s/%s", type.getDirectory(), location.getNamespace(), location.getPath());
}
}
@@ -62,7 +62,7 @@ public class ModFileResourcePack extends ResourcePack
}
@Override
protected InputStream getInputStream(String name) throws IOException
protected InputStream getResource(String name) throws IOException
{
final Path path = modFile.getLocator().findPath(modFile, name);
if(!Files.exists(path))
@@ -71,18 +71,18 @@ public class ModFileResourcePack extends ResourcePack
}
@Override
protected boolean resourceExists(String name)
protected boolean hasResource(String name)
{
return Files.exists(modFile.getLocator().findPath(modFile, name));
}
@Override
public Collection<ResourceLocation> getAllResourceLocations(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> filter)
public Collection<ResourceLocation> getResources(ResourcePackType type, String resourceNamespace, String pathIn, int maxDepth, Predicate<String> filter)
{
try
{
Path root = modFile.getLocator().findPath(modFile, type.getDirectoryName(), resourceNamespace).toAbsolutePath();
Path root = modFile.getLocator().findPath(modFile, type.getDirectory(), resourceNamespace).toAbsolutePath();
Path inputPath = root.getFileSystem().getPath(pathIn);
return Files.walk(root).
@@ -104,10 +104,10 @@ public class ModFileResourcePack extends ResourcePack
}
@Override
public Set<String> getResourceNamespaces(ResourcePackType type)
public Set<String> getNamespaces(ResourcePackType type)
{
try {
Path root = modFile.getLocator().findPath(modFile, type.getDirectoryName()).toAbsolutePath();
Path root = modFile.getLocator().findPath(modFile, type.getDirectory()).toAbsolutePath();
return Files.walk(root,1)
.map(path -> root.relativize(path.toAbsolutePath()))
.filter(path -> path.getNameCount() > 0) // skip the root entry
@@ -119,7 +119,7 @@ public class ModFileResourcePack extends ResourcePack
{
if (type == ResourcePackType.SERVER_DATA) //We still have to add the resource namespace if client resources exist, as we load langs (which are in assets) on server
{
return this.getResourceNamespaces(ResourcePackType.CLIENT_RESOURCES);
return this.getNamespaces(ResourcePackType.CLIENT_RESOURCES);
}
else
{
@@ -128,19 +128,19 @@ public class ModFileResourcePack extends ResourcePack
}
}
public InputStream getResourceStream(ResourcePackType type, ResourceLocation location) throws IOException {
public InputStream getResource(ResourcePackType type, ResourceLocation location) throws IOException {
if (location.getPath().startsWith("lang/")) {
return super.getResourceStream(ResourcePackType.CLIENT_RESOURCES, location);
return super.getResource(ResourcePackType.CLIENT_RESOURCES, location);
} else {
return super.getResourceStream(type, location);
return super.getResource(type, location);
}
}
public boolean resourceExists(ResourcePackType type, ResourceLocation location) {
public boolean hasResource(ResourcePackType type, ResourceLocation location) {
if (location.getPath().startsWith("lang/")) {
return super.resourceExists(ResourcePackType.CLIENT_RESOURCES, location);
return super.hasResource(ResourcePackType.CLIENT_RESOURCES, location);
} else {
return super.resourceExists(type, location);
return super.hasResource(type, location);
}
}
@@ -111,7 +111,7 @@ public class ResourcePackLoader
}
@Override
public void findPacks(Consumer<ResourcePackInfo> consumer, IFactory factory)
public void loadPacks(Consumer<ResourcePackInfo> consumer, IFactory factory)
{
wrapped.addPackInfos(consumer, factory);
}
@@ -66,10 +66,10 @@ public class LanguageHook
try
{
JsonElement jsonelement = GSON.fromJson(new InputStreamReader(inputstream, StandardCharsets.UTF_8), JsonElement.class);
JsonObject jsonobject = JSONUtils.getJsonObject(jsonelement, "strings");
JsonObject jsonobject = JSONUtils.convertToJsonObject(jsonelement, "strings");
jsonobject.entrySet().forEach(entry -> {
String s = PATTERN.matcher(JSONUtils.getString(entry.getValue(), entry.getKey())).replaceAll("%$1s");
String s = PATTERN.matcher(JSONUtils.convertToString(entry.getValue(), entry.getKey())).replaceAll("%$1s");
modTable.put(entry.getKey(), s);
});
}
@@ -82,10 +82,10 @@ public class LanguageHook
private static void loadLanguage(String langName, MinecraftServer server) {
String langFile = String.format("lang/%s.json", langName);
IResourceManager resourceManager = server.getDataPackRegistries().getResourceManager();
resourceManager.getResourceNamespaces().forEach(namespace -> {
resourceManager.getNamespaces().forEach(namespace -> {
try {
ResourceLocation langResource = new ResourceLocation(namespace, langFile);
loadLocaleData(resourceManager.getAllResources(langResource));
loadLocaleData(resourceManager.getResources(langResource));
} catch (FileNotFoundException fnfe) {
} catch (Exception exception) {
LOGGER.warn("Skipped language file: {}:{}", namespace, langFile, exception);
@@ -81,7 +81,7 @@ public class ServerLifecycleHooks
private static Path getServerConfigPath(final MinecraftServer server)
{
final Path serverConfig = server.func_240776_a_(SERVERCONFIG);
final Path serverConfig = server.getWorldPath(SERVERCONFIG);
FileUtils.getOrCreateDirectory(serverConfig, "serverconfig");
return serverConfig;
}
@@ -89,7 +89,7 @@ public class ServerLifecycleHooks
public static boolean handleServerAboutToStart(final MinecraftServer server)
{
currentServer = server;
currentServer.getServerStatusResponse().setForgeData(new FMLStatusPing()); //gathers NetworkRegistry data
currentServer.getStatus().setForgeData(new FMLStatusPing()); //gathers NetworkRegistry data
// on the dedi server we need to force the stuff to setup properly
LogicalSidedProvider.setServer(()->server);
ConfigTracker.INSTANCE.loadConfigs(ModConfig.Type.SERVER, getServerConfigPath(server));
@@ -145,13 +145,13 @@ public class ServerLifecycleHooks
if (!allowLogins.get())
{
StringTextComponent text = new StringTextComponent("Server is still starting! Please wait before reconnecting.");
LOGGER.info(SERVERHOOKS,"Disconnecting Player (server is still starting): {}", text.getUnformattedComponentText());
manager.sendPacket(new SDisconnectLoginPacket(text));
manager.closeChannel(text);
LOGGER.info(SERVERHOOKS,"Disconnecting Player (server is still starting): {}", text.getContents());
manager.send(new SDisconnectLoginPacket(text));
manager.disconnect(text);
return false;
}
if (packet.getRequestedState() == ProtocolType.LOGIN) {
if (packet.getIntention() == ProtocolType.LOGIN) {
final ConnectionType connectionType = ConnectionType.forVersionFlag(packet.getFMLVersion());
final int versionNumber = connectionType.getFMLVersionNumber(packet.getFMLVersion());
@@ -166,7 +166,7 @@ public class ServerLifecycleHooks
}
}
if (packet.getRequestedState() == ProtocolType.STATUS) return true;
if (packet.getIntention() == ProtocolType.STATUS) return true;
NetworkHooks.registerServerLoginChannel(manager, packet);
NetworkFilters.injectIfNecessary(manager);
@@ -175,11 +175,11 @@ public class ServerLifecycleHooks
}
private static void rejectConnection(final NetworkManager manager, ConnectionType type, String message) {
manager.setConnectionState(ProtocolType.LOGIN);
manager.setProtocol(ProtocolType.LOGIN);
LOGGER.info(SERVERHOOKS, "Disconnecting {} connection attempt: {}", type, message);
StringTextComponent text = new StringTextComponent(message);
manager.sendPacket(new SDisconnectLoginPacket(text));
manager.closeChannel(text);
manager.send(new SDisconnectLoginPacket(text));
manager.disconnect(text);
}
public static void handleExit(int retVal)
@@ -199,7 +199,7 @@ public class ServerLifecycleHooks
IModInfo mod = e.getKey().getModInfos().get(0);
if (Objects.equals(mod.getModId(), "minecraft")) continue; // skip the minecraft "mod"
final String name = "mod:" + mod.getModId();
final ResourcePackInfo packInfo = ResourcePackInfo.createResourcePack(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.PLAIN);
final ResourcePackInfo packInfo = ResourcePackInfo.create(name, false, e::getValue, factory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
if (packInfo == null) {
// Vanilla only logs an error, instead of propagating, so handle null and warn that something went wrong
ModLoader.get().addWarning(new ModLoadingWarning(mod, ModLoadingStage.ERROR, "fml.modloading.brokenresources", e.getKey()));