Skip to content

Commit

Permalink
Port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
JaisDK committed Jun 17, 2024
1 parent 7fd56d6 commit cf436ed
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Java CI with Gradle

on:
push:
branches: [ neoforge-1.20.6 ]
branches: [ dev-1.21.0 ]
pull_request:
types: [ opened, synchronize, reopened ]

Expand Down
23 changes: 20 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ plugins {
id 'idea'
id 'maven-publish'
id 'org.gradle.crypto.checksum' version '1.4.0'
id 'net.neoforged.gradle.userdev' version '7.0.105'
id 'net.neoforged.gradle.userdev' version '7.0.142'
}

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
minecraft {
// FML looks for this mod id to find the minecraft classes
modIdentifier 'minecraft'

accessTransformers {
file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
entry 'public net.minecraft.client.gui.Gui renderSlot(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/client/DeltaTracker;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V'
}
}

runs {
// applies to all the run configs below
Expand Down Expand Up @@ -58,10 +66,19 @@ runs {
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

repositories {
maven {
url "https://www.cursemaven.com"
}
maven {
url 'https://maven.blamejared.com'
}
}

dependencies {
implementation "net.neoforged:neoforge:${neo_version}"

// implementation "curse.maven:jei-238222:5101381"
implementation "curse.maven:jei-238222:5437447"
}

tasks.withType(ProcessResources).configureEach {
Expand Down
24 changes: 9 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
#org.gradle.jvmargs=
org.gradle.daemon=false
org.gradle.debug=false

#neogradle.subsystems.parchment.minecraftVersion=1.20.6
#neogradle.subsystems.parchment.mappingsVersion=2023.12.31

minecraft_version=1.20.6
neo_version=20.6.43-beta
mapping_channel=official
mapping_version=1.20.6

neogradle.subsystems.parchment.minecraftVersion=1.20.6
neogradle.subsystems.parchment.mappingsVersion=2024.05.01
## Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.20.6
minecraft_version=1.21
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.20.6,1.21)
minecraft_version_range=[1.21,1.22)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=20.6.42-beta
neo_version=21.0.10-beta
# The Neo version range can use any version of Neo as bounds
neo_version_range=[20.6,)
neo_version_range=[21.0.0-beta,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[2,)

Expand All @@ -37,7 +31,7 @@ mod_name=Inventory Tweaks Refoxed
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=Apache License, Version 2.0
# The mod version. See https://semver.org/
mod_version=1.20.6-1.1.1
mod_version=1.21.0-1.1.1
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/invtweaks/config/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private static Optional<Predicate<ItemStack>> compileClause(String clause) {

String[] parts = clause.split(":", 2);
if (parts[0].equals("/tag")) {
TagKey<Item> itemKey = TagKey.create(BuiltInRegistries.ITEM.key(), new ResourceLocation(parts[1]));
TagKey<Block> blockKey = TagKey.create(BuiltInRegistries.BLOCK.key(), new ResourceLocation(parts[1]));
TagKey<Item> itemKey = TagKey.create(BuiltInRegistries.ITEM.key(), ResourceLocation.parse(parts[1]));
TagKey<Block> blockKey = TagKey.create(BuiltInRegistries.BLOCK.key(), ResourceLocation.parse(parts[1]));

return Optional.of(stack -> stack.is(itemKey) || (
stack.getItem() instanceof BlockItem blockItem
Expand All @@ -65,7 +65,7 @@ private static Optional<Predicate<ItemStack>> compileClause(String clause) {
} else { // default to standard item checking
try {
return Optional.of(
st -> Objects.equals(BuiltInRegistries.ITEM.getKey(st.getItem()), new ResourceLocation(clause)));
st -> Objects.equals(BuiltInRegistries.ITEM.getKey(st.getItem()), ResourceLocation.parse(clause)));
} catch (ResourceLocationException e) {
InvTweaksMod.LOGGER.warn("Invalid item resource location found.");
return Optional.empty();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/invtweaks/events/ClientEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import invtweaks.util.Sorting;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -239,7 +240,7 @@ public static void renderOverlay(RenderGuiLayerEvent.Post event) {
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();

Minecraft.getInstance().gui.renderSlot(event.getGuiGraphics(), iprime, i2, Minecraft.getInstance().getFrameTime(), ent, toRender, 0);
// Minecraft.getInstance().gui.renderSlot(event.getGuiGraphics(), iprime, i2, DeltaTracker.ZERO, ent, toRender, 0);

RenderSystem.disableBlend();
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/invtweaks/gui/InvTweaksButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class InvTweaksButton extends ExtendedButton {
protected static final ResourceLocation button =
new ResourceLocation(InvTweaksMod.MODID, "textures/gui/button_sprites.png");
ResourceLocation.fromNamespaceAndPath(InvTweaksMod.MODID, "textures/gui/button_sprites.png");
private final int tx;
private final int ty;

Expand Down
58 changes: 29 additions & 29 deletions src/main/java/invtweaks/jei/InvTweaksJEI.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
//package invtweaks.jei;
//
//import invtweaks.InvTweaksMod;
//import invtweaks.events.ClientEvents;
//import mezz.jei.api.IModPlugin;
//import mezz.jei.api.JeiPlugin;
//import mezz.jei.api.runtime.IJeiRuntime;
//import net.minecraft.MethodsReturnNonnullByDefault;
//import net.minecraft.resources.ResourceLocation;
//
//import javax.annotation.ParametersAreNonnullByDefault;
//
//@SuppressWarnings("unused")
//@JeiPlugin
//@ParametersAreNonnullByDefault
//@MethodsReturnNonnullByDefault
//public class InvTweaksJEI implements IModPlugin {
// public static final ResourceLocation UID = new ResourceLocation(InvTweaksMod.MODID, "jei_plugin");
//
// @Override
// public ResourceLocation getPluginUid() {
// return UID;
// }
//
// @Override
// public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
// ClientEvents.setJEIKeyboardActiveFn(() -> jeiRuntime.getIngredientListOverlay().hasKeyboardFocus());
// }
//}
package invtweaks.jei;

import invtweaks.InvTweaksMod;
import invtweaks.events.ClientEvents;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.runtime.IJeiRuntime;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.resources.ResourceLocation;

import javax.annotation.ParametersAreNonnullByDefault;

@SuppressWarnings("unused")
@JeiPlugin
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
public class InvTweaksJEI implements IModPlugin {
public static final ResourceLocation UID = ResourceLocation.fromNamespaceAndPath(InvTweaksMod.MODID, "jei_plugin");

@Override
public ResourceLocation getPluginUid() {
return UID;
}

@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
ClientEvents.setJEIKeyboardActiveFn(() -> jeiRuntime.getIngredientListOverlay().hasKeyboardFocus());
}
}
2 changes: 1 addition & 1 deletion src/main/java/invtweaks/network/PacketSortInv.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PacketSortInv implements CustomPacketPayload, IPayloadHandler<Packe
private final boolean isPlayer;
private final String screenName;

public static final Type<PacketSortInv> TYPE = new Type<>(new ResourceLocation(InvTweaksMod.MODID, "packet_sort_inv"));
public static final Type<PacketSortInv> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(InvTweaksMod.MODID, "packet_sort_inv"));
public static final StreamCodec<RegistryFriendlyByteBuf, PacketSortInv> CODEC = new StreamCodec<>()
{
@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/invtweaks/network/PacketUpdateConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

public class PacketUpdateConfig implements CustomPacketPayload, IPayloadHandler<PacketUpdateConfig>
{
public static final Type<PacketUpdateConfig> TYPE = new Type<>(new ResourceLocation(InvTweaksMod.MODID, "packet_update_config"));
public static final Type<PacketUpdateConfig> TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(InvTweaksMod.MODID, "packet_update_config"));
public static final StreamCodec<RegistryFriendlyByteBuf, PacketUpdateConfig> CODEC = new StreamCodec<>()
{
@Override
Expand Down
19 changes: 1 addition & 18 deletions src/main/java/invtweaks/util/Sorting.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
import invtweaks.config.Category;
import invtweaks.config.ContOverride;
import invtweaks.config.InvTweaksConfig;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList;
import it.unimi.dsi.fastutil.ints.IntLists;
import invtweaks.config.Ruleset;
import it.unimi.dsi.fastutil.ints.*;
import net.minecraft.client.Minecraft;
Expand All @@ -23,21 +18,9 @@
import net.minecraft.world.inventory.ClickType;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.items.ItemHandlerHelper;
import org.apache.commons.lang3.tuple.Pair;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.PrimitiveIterator;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
public net.minecraft.client.gui.Gui renderSlot(Lnet/minecraft/client/gui/GuiGraphics;IIFLnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V # renderSlot
public net.minecraft.client.gui.Gui renderSlot(Lnet/minecraft/client/gui/GuiGraphics;IILnet/minecraft/client/DeltaTracker;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/item/ItemStack;I)V # renderSlot
3 changes: 3 additions & 0 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ issueTrackerURL="https://github.com/JDKDigital/InvTweaksRefoxed/issues"
logoFile="logo.png"
displayTest="IGNORE_ALL_VERSION"

[[accessTransformers]]
file="META-INF/accesstransformer.cfg"

[[dependencies.${mod_id}]]
modId="neoforge"
type="required"
Expand Down

0 comments on commit cf436ed

Please sign in to comment.