Skip to content

Commit

Permalink
1.20.4 NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Apr 4, 2024
1 parent 200a430 commit 13b9d9d
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 55 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
## Change
- update mafglib version to `0.1.7`
- port to 1.20.4 NeoForge
19 changes: 6 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,15 @@ archivesBaseName = project.archives_base_name
version = "${project.mod_version}-mc${project.minecraft_version}"
group = project.maven_group

loom {
forge {
mixinConfigs = [
"rocknroller.mixins.json"
]
}
}

repositories {
maven { url 'https://api.modrinth.com/maven' }
maven { url "https://maven.neoforged.net/releases/" }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
forge "net.minecraftforge:forge:${project.forge_version}"
neoForge "net.neoforged:neoforge:${project.neoforge_version}"

modImplementation "maven.modrinth:mafglib:${project.malilib_version}"

Expand Down Expand Up @@ -74,8 +67,8 @@ modrinth {
changelog = file("CHANGELOG.md").getText('UTF-8')
uploadFile = remapJar
additionalFiles = [sourcesJar]
gameVersions = ["1.20", "1.20.1"]
loaders = ["forge", "neoforge"]
gameVersions = ["1.20.3", "1.20.4"]
loaders = ["neoforge"]
dependencies {
required.project("mafglib")
}
Expand All @@ -90,9 +83,9 @@ task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
mainFile.releaseType = "beta"
mainFile.changelog = file("CHANGELOG.md")
mainFile.changelogType = "markdown"
mainFile.addModLoader("Forge", "NeoForge")
mainFile.addModLoader("NeoForge")
mainFile.addJavaVersion("Java 17", "Java 18")
mainFile.addGameVersion("1.20", "1.20.1")
mainFile.addGameVersion("1.20.3", "1.20.4")
mainFile.addRequirement("mafglib")

def sourcesFile = mainFile.withAdditionalFile(sourcesJar)
Expand Down
14 changes: 6 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

loom.platform=forge
loom.platform=neoforge

# Base properties
# minecraft version
minecraft_version=1.20.1
# forge version, latest version can be found on https://files.minecraftforge.net/
forge_version=1.20.1-47.1.21
# yarn, latest version can be found on https://fabricmc.net/develop/
yarn_mappings=1.20.1+build.9
minecraft_version=1.20.4
neoforge_version=20.4.219
yarn_mappings=1.20.4+build.3

# Mod Properties
mod_version=0.1.2
mod_version=0.1.0
maven_group=org.thinkingstudio.rocknroller
archives_base_name=RocknRoller
mod_id=rocknroller
Expand All @@ -21,4 +19,4 @@ loom.platform=forge
curseforge_id=916852

# Dependencies
malilib_version=0.1.7-mc1.20.1
malilib_version=0.1.4-mc1.20.4
4 changes: 1 addition & 3 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
pluginManagement {
// when using additional gradle plugins like shadow,
// add their repositories to this list!
repositories {
maven { url "https://maven.fabricmc.net/" }
maven { url "https://maven.architectury.dev/" }
maven { url "https://files.minecraftforge.net/maven/" }
maven { url "https://maven.neoforged.net/releases/" }
gradlePluginPortal()
}
}
16 changes: 7 additions & 9 deletions src/main/java/fi/dy/masa/itemscroller/ItemScroller.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package fi.dy.masa.itemscroller;

import fi.dy.masa.itemscroller.gui.GuiConfigs;
import fi.dy.masa.malilib.compat.forge.ForgePlatformUtils;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import fi.dy.masa.malilib.compat.neoforge.ForgePlatformUtils;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.loading.FMLLoader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import fi.dy.masa.malilib.event.InitializationHandler;
Expand All @@ -15,12 +13,12 @@ public class ItemScroller {
public static final Logger logger = LogManager.getLogger(Reference.MOD_ID);

public ItemScroller() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

modEventBus.addListener(this::onInitializeClient);
if (FMLLoader.getDist().isClient()) {
this.onInitializeClient();
}
}

public void onInitializeClient(FMLClientSetupEvent event) {
public void onInitializeClient() {
ForgePlatformUtils.getInstance().getClientModIgnoredServerOnly();
InitializationHandler.getInstance().registerInitializationHandler(new InitHandler());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void initTradeListWidget(CallbackInfo ci)
}

@Inject(method = "mouseScrolled", at = @At("RETURN"))
private void onMouseScrollPost(double mouseX, double mouseY, double amount, CallbackInfoReturnable<Boolean> cir)
private void onMouseScrollPost(double mouseX, double mouseY, double horizontalAmount, double verticalAmount, CallbackInfoReturnable<Boolean> cir)
{
if (Configs.Toggles.VILLAGER_TRADE_FEATURES.getBooleanValue() &&
Configs.Generic.VILLAGER_TRADE_LIST_REMEMBER_SCROLL.getBooleanValue() &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import javax.annotation.Nonnull;

import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtSizeTracker;
import net.minecraft.screen.slot.Slot;

import fi.dy.masa.itemscroller.ItemScroller;
import fi.dy.masa.itemscroller.Reference;
import fi.dy.masa.itemscroller.config.Configs;
Expand Down Expand Up @@ -204,7 +207,7 @@ public void readFromDisk()
if (file.exists() && file.isFile() && file.canRead())
{
FileInputStream is = new FileInputStream(file);
this.readFromNBT(NbtIo.readCompressed(is));
this.readFromNBT(NbtIo.readCompressed(is, NbtSizeTracker.ofUnlimitedBytes()));
is.close();
//ItemScroller.logger.info("Read recipes from file '{}'", file.getPath());
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.minecraft.inventory.RecipeInputInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.CraftingRecipe;
import net.minecraft.recipe.RecipeEntry;
import net.minecraft.recipe.RecipeType;
import net.minecraft.registry.Registries;
import net.minecraft.screen.MerchantScreenHandler;
Expand Down Expand Up @@ -110,20 +111,22 @@ public static void updateCraftingOutputSlot(PlayerEntity player,
{
ItemStack stack = ItemStack.EMPTY;
CraftingRecipe recipe = Configs.Generic.USE_RECIPE_CACHING.getBooleanValue() ? lastRecipe : null;
RecipeEntry<?> recipeEntry = null;

if (recipe == null || recipe.matches(craftMatrix, world) == false)
{
Optional<CraftingRecipe> optional = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftMatrix, world);
recipe = optional.isPresent() ? optional.get() : null;
Optional<RecipeEntry<CraftingRecipe>> optional = world.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftMatrix, world);
recipe = optional.map(RecipeEntry::value).orElse(null);
recipeEntry = optional.orElse(null);
}

if (recipe != null)
{
if ((recipe.isIgnoredInRecipeBook() ||
world.getGameRules().getBoolean(GameRules.DO_LIMITED_CRAFTING) == false ||
((ClientPlayerEntity) player).getRecipeBook().contains(recipe)))
((ClientPlayerEntity) player).getRecipeBook().contains(recipeEntry)))
{
inventoryCraftResult.setLastRecipe(recipe);
inventoryCraftResult.setLastRecipe(recipeEntry);
stack = recipe.craft(craftMatrix, MinecraftClient.getInstance().getNetworkHandler().getRegistryManager());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@
import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import it.unimi.dsi.fastutil.ints.IntArrayList;

import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtList;
import net.minecraft.nbt.NbtSizeTracker;
import net.minecraft.screen.MerchantScreenHandler;
import net.minecraft.village.TradeOffer;
import net.minecraft.village.TradeOfferList;

import fi.dy.masa.itemscroller.ItemScroller;
import fi.dy.masa.itemscroller.Reference;
import fi.dy.masa.itemscroller.config.Configs;
import fi.dy.masa.itemscroller.util.Constants;
import fi.dy.masa.malilib.util.FileUtils;
import fi.dy.masa.malilib.util.StringUtils;
import it.unimi.dsi.fastutil.ints.IntArrayList;

public class VillagerDataStorage
{
Expand Down Expand Up @@ -214,7 +217,7 @@ public void readFromDisk()
if (file.exists() && file.isFile() && file.canRead())
{
FileInputStream is = new FileInputStream(file);
this.readFromNBT(NbtIo.readCompressed(is));
this.readFromNBT(NbtIo.readCompressed(is, NbtSizeTracker.ofUnlimitedBytes()));
is.close();
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modLoader = "javafml"
loaderVersion = "[43,)"
loaderVersion = "[1,)"
license = "LGPLv3"

[[mods]]
Expand All @@ -16,23 +16,26 @@ ItemScroller unofficial forge port.
Move items in inventory GUIs by scrolling the mouse wheel or dragging over slots
'''

[[mixins]]
config = "rocknroller.mixins.json"

[[dependencies.rocknroller]]
modId = "forge"
mandatory = true
versionRange = "[43,)"
modId = "neoforge"
type = "required"
versionRange = "[20.3,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.rocknroller]]
modId = "minecraft"
mandatory = true
versionRange = "[1.20,)"
type = "required"
versionRange = "[1.20.3,)"
ordering = "NONE"
side = "BOTH"

[[dependencies.rocknroller]]
modId = "mafglib"
mandatory = true
type = "required"
versionRange = "*"
ordering = "NONE"
side = "BOTH"
6 changes: 0 additions & 6 deletions src/main/resources/pack.mcmeta

This file was deleted.

0 comments on commit 13b9d9d

Please sign in to comment.