Skip to content

Instantly share code, notes, and snippets.

View SizableShrimp's full-sized avatar
📞
Contact me on Discord!

SizableShrimp

📞
Contact me on Discord!
View GitHub Profile
@SizableShrimp
SizableShrimp / LegacyComponentSerializer.java
Last active August 10, 2023 03:00
Simple util class to convert a Component using color codes to a legacy String
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.FormattedCharSink;
import java.util.EnumSet;
public class LegacyComponentSerializer {
public static String convertToLegacy(Component component) {
@SizableShrimp
SizableShrimp / DatapackRegistryProvider.java
Created February 27, 2023 04:35
Datapack registry holder datagen 1.19.2
import com.google.gson.JsonElement;
import com.mojang.logging.LogUtils;
import com.mojang.serialization.Codec;
import com.mojang.serialization.DynamicOps;
import cpw.mods.modlauncher.api.LamdbaExceptionUtils;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataGenerator;
@SizableShrimp
SizableShrimp / build.gradle
Last active August 3, 2022 20:29
Using shadowJar with FG's jarJar
afterEvaluate {
tasks.named('jarJar') {
enabled = false
}
tasks.named('reobfJarJar') {
enabled = false
}
}
tasks.register('fullJar', net.minecraftforge.gradle.userdev.tasks.JarJar) {
@SizableShrimp
SizableShrimp / README.md
Last active January 20, 2023 04:19
How to remap your mod to include Forge's 1.19 renames

How to remap your mod to include Forge's 1.19 renames

Forge versions 41.0.64 and 41.0.94 for Minecraft 1.19 together bring a large overhaul to rendering along with general renames to many older fields, methods, and classes that were previously based on MCP names. Together, these changes have broken almost all mods written for any older versions of Forge 1.19 or lower.

However, the Forge team has created a tool to aid modders in automatically remapping their mods to be in line with the renames. This tool has been designed with the future in mind. This means you should be able to use it starting from any Minecraft/Forge version (on FG5) on the way to porting to any future Minecraft/Forge versions (1.19+ / 41.0.94+).

Note: This does not port your mod for you. However, it greatly helps in automating parts that would otherwise be tedious.

@SizableShrimp
SizableShrimp / README.md
Last active January 20, 2023 04:19
Overview of Forge 1.18.2 registry and tag changes

Overview of Forge 1.18.2 registry and tag changes

Forge version 1.18.2-40.0.18 introduced some changes to how custom registries and tags work to support Mojang's new universal tag system. The differences between tags in 1.18.1 and 1.18.2 were great enough to warrant breaking changes in Forge where necessary.

Enabling tags for custom registries

For simplicity, custom Forge registries are opt-in for universal tags. To enable tags for a registry, call RegistryBuilder#hasTags(). This tells Forge to run the necessary setup to allow tags for a custom registry. Tag-enabled forge registries will be registered to the root registry in Registry to promote as much compatibility with vanilla systems as possible.

@SizableShrimp
SizableShrimp / README.md
Last active January 20, 2023 04:20
How to use the Game Test Framework on Forge

Game Test Framework on Forge

The Game Test Framework is a powerful tool provided by Mojang that is included with Minecraft in 1.17 and up. It allows you to declare game tests that can be run inside a Minecraft world and provide a success or fail state. Game tests are similar in concept to unit tests, but they allow you to interact with a running instance of Minecraft. This means you can test block interactions, entity interactions, item functionality, etc. Game tests use template structures to define the dimensions of the test and what blocks and entities will start in the test structure. This framework has useful applications for Continuous Integration (CI) and testing during development to ensure features are working as expected.

For a more in-depth explanation about the Game Test Framework itself and how Mojang uses it to test the base game, please see this video with contributions by Dinnerbone. This guide is tailored towards Forge modders by expla

@SizableShrimp
SizableShrimp / README.md
Last active May 9, 2024 13:59
How to setup shading with Minecraft Forge

How to setup shading with Minecraft Forge

Shading is the concept of packing external dependencies inside your jar so that they exist in production. Without this, using external libraries would produce ClassNotFoundExceptions when you run your mod jar outside of an IDE. This guide explains how to setup shading through Gradle.

Assumptions

This guide assumes that:

  • You are on ForgeGradle 5 or higher
  • You are on Gradle 7.0 or higher
@SizableShrimp
SizableShrimp / README.md
Last active May 9, 2024 13:59
How to fix Java libraries not loading in Minecraft Forge 1.17+

How to fix Java libraries not loading in Minecraft Forge 1.17+

By default, Minecraft Forge does not load dependencies from the classpath unless they are explicitly declared as mods. These steps outline how to remedy this. This guide assumes that:

  1. You are on ForgeGradle 5 or higher.
  2. You are on Forge 1.17.1 (37.0.13) or higher.

Using Java libraries

To configure your Java libraries to be loaded by Forge, you should use the minecraftLibrary configuration provided by ForgeGradle. You now must make sure to declare your dependencies using minecraftLibrary configuration.

@SizableShrimp
SizableShrimp / DataManager.java
Created December 5, 2020 21:42
My broken upload code
/*
* Copyright (c) 2020 SizableShrimp.
* This file is provided under version 3 of the GNU Lesser General Public License.
*/
package me.sizableshrimp.adventofcode2020.helper;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
@SizableShrimp
SizableShrimp / My idea.md
Created September 21, 2020 04:55
Among Us - Angels vs. Devils

Among Us - Angels vs. Devils

The concept

A new group is added to the game called "Devils", which have to always tell lies whenever asked questions. The current number of Devils that should be in a game is up for debate, but I'm thinking 1-2 similar to how many Impostors there are. The Devils would still be crewmates in-game, but they are like minions of sorts for the Impostors. Impostors can decide whether to lie or tell the truth depending on what makes more sense in the situation. Switching between lying and telling the truth too often however could lead to the Impostor being found out. If the Impostors win, the Devils win as well. Devils still have to do their tasks but can intentionally fake tasks to draw suspicion and try to get themselves outed as an Impostor.