Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.21.1/fabric #9

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import net.fabricmc.loom.task.RemapJarTask

plugins {
id 'org.quiltmc.loom' version '1.6.+'
id 'fabric-loom' version '1.9-SNAPSHOT'
id 'io.github.ladysnake.chenille' version '0.13.1'
id 'maven-publish'
}
Expand Down Expand Up @@ -49,8 +49,8 @@ repositories {
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2"
modImplementation "org.quiltmc:quilt-loader:${project.loader_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"

Expand All @@ -60,7 +60,7 @@ dependencies {

compileOnly "com.demonwav.mcdev:annotations:1.0"

modCompileOnly "maven.modrinth:backslot:${backslot_version}" // not updated yet
modCompileOnly "maven.modrinth:backslot:${backslot_version}"
modLocalRuntime ("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}") { transitive = false }

modLocalRuntime ("com.terraformersmc:modmenu:${modmenu_version}") { transitive = false }
Expand Down
15 changes: 7 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ org.gradle.jvmargs=-Xmx3G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version = 1.21
quilt_mappings = 1
loader_version=0.26.0
minecraft_version = 1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.9

# Mod Properties
mod_version = 0.13.0
mod_version = 0.14.0
maven_group = org.ladysnake
archives_base_name = locki

# Dependencies
fabric_api_version = 0.100.1+1.21
fabric_api_version = 0.110.0+1.21.1
cca_version = 6.1.0
fpa_version=0.2-SNAPSHOT
# V1.2.12
backslot_version=1.2.15+1.20.6
backslot_version=1.2.16+1.21.1
cloth_config_version=15.0.127
modmenu_version=11.0.0-rc.2
elmendorf_version=0.13.0
Expand All @@ -28,7 +28,6 @@ org.gradle.jvmargs=-Xmx3G
gpl_version = 3
curseforge_id = 483059
modrinth_id = qS8U15sj
curseforge_versions = 1.21
cf_requirements = qsl
curseforge_versions = 1.21.1
cf_embeddeds = cardinal-components-api
release_type = beta
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
16 changes: 4 additions & 12 deletions junit-loader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@ plugins {
id 'java-library'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = "quilt-loader-junit"
archivesBaseName = "fabric-loader-junit"
version = rootProject.version
group = rootProject.group

repositories {
mavenCentral()

maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/release'
}
maven {
name = 'Quilt Snapshots'
url = 'https://maven.quiltmc.org/repository/snapshot'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
}

dependencies {
compileOnly "org.quiltmc:quilt-loader:${project.loader_version}"
compileOnly "net.fabricmc:fabric-loader:${project.loader_version}"

api platform("org.junit:junit-bom:5.9.2")
api "org.junit.jupiter:junit-jupiter-engine"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
package org.ladysnake.junitloader;

import net.fabricmc.api.EnvType;
import net.fabricmc.loader.impl.launch.knot.Knot;
import net.fabricmc.loader.impl.util.SystemProperties;
import org.junit.platform.launcher.LauncherSession;
import org.junit.platform.launcher.LauncherSessionListener;
import org.quiltmc.loader.impl.launch.knot.Knot;
import org.quiltmc.loader.impl.util.SystemProperties;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class QuiltLoaderLauncherSessionListener implements LauncherSessionListener {
public class FabricLoaderLauncherSessionListener implements LauncherSessionListener {
static {
System.setProperty(SystemProperties.DEVELOPMENT, "true");
}
Expand All @@ -34,7 +34,7 @@ public class QuiltLoaderLauncherSessionListener implements LauncherSessionListen

private ClassLoader launcherSessionClassLoader;

public QuiltLoaderLauncherSessionListener() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
public FabricLoaderLauncherSessionListener() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
final Thread currentThread = Thread.currentThread();
final ClassLoader originalClassLoader = currentThread.getContextClassLoader();

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.ladysnake.junitloader.QuiltLoaderLauncherSessionListener
org.ladysnake.junitloader.FabricLoaderLauncherSessionListener
4 changes: 0 additions & 4 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
pluginManagement {
repositories {
maven {
name = 'QuiltMC'
url = 'https://maven.quiltmc.org/repository/release'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/ladysnake/locki/Locki.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import net.fabricmc.fabric.api.command.v2.ArgumentTypeRegistry;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.util.TriState;
import net.minecraft.command.argument.SingletonArgumentInfo;
import net.minecraft.command.argument.serialize.ConstantArgumentSerializer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.command.ServerCommandSource;
Expand Down Expand Up @@ -157,8 +157,14 @@ public static Stream<String> streamNodeNames() {
@Override
public void onInitialize() {
this.baseInit();
ArgumentTypeRegistry.registerArgumentType(id("inventory_lock"), InventoryLockArgumentType.class, SingletonArgumentInfo.contextFree(InventoryLockArgumentType::inventoryLock));
ArgumentTypeRegistry.registerArgumentType(id("inventory_node"), InventoryNodeArgumentType.class, SingletonArgumentInfo.contextFree(InventoryNodeArgumentType::inventoryNode));
ArgumentTypeRegistry.registerArgumentType(id("inventory_lock"),
InventoryLockArgumentType.class,
ConstantArgumentSerializer.of(InventoryLockArgumentType::inventoryLock)
);
ArgumentTypeRegistry.registerArgumentType(id("inventory_node"),
InventoryNodeArgumentType.class,
ConstantArgumentSerializer.of(InventoryNodeArgumentType::inventoryNode)
);
}

void baseInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.registry.HolderLookup;
import net.minecraft.registry.RegistryEntryLookup;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.util.Identifier;
import org.ladysnake.cca.api.v3.component.Component;
import org.ladysnake.locki.InventoryKeeper;
Expand Down Expand Up @@ -143,7 +144,7 @@ protected BitSet lookup(InventoryNode inventoryNode) {
}

@Override
public void readFromNbt(NbtCompound tag, HolderLookup.Provider registryLookup) {
public void readFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) {
if (tag.contains("locks", NbtElement.COMPOUND_TYPE)) {
this.clearCache();
this.getLocks().clear();
Expand All @@ -170,7 +171,7 @@ public void readFromNbt(NbtCompound tag, HolderLookup.Provider registryLookup) {
}

@Override
public void writeToNbt(NbtCompound tag, HolderLookup.Provider registryLookup) {
public void writeToNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) {
NbtCompound dict = new NbtCompound();
for (Map.Entry<InventoryNode, Reference2BooleanMap<InventoryLock>> nodeEntry : this.getLocks().entrySet()) {
NbtList list = new NbtList();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/ladysnake/locki/impl/LockiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import net.fabricmc.api.ClientModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.screen.recipe_book.RecipeBookProvider;
import net.minecraft.client.gui.widget.recipe_book.RecipeBookWidget;
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import org.ladysnake.locki.DefaultInventoryNodes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.ladysnake.locki.impl;

import net.fabricmc.api.EnvType;
import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.quiltmc.loader.api.minecraft.MinecraftQuiltLoader;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

Expand All @@ -39,7 +39,7 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return MinecraftQuiltLoader.getEnvironmentType() == EnvType.CLIENT;
return FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/
package org.ladysnake.locki.impl.compat;

import net.fabricmc.loader.api.FabricLoader;
import org.objectweb.asm.tree.ClassNode;
import org.quiltmc.loader.api.QuiltLoader;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;

Expand All @@ -45,7 +45,7 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
Matcher matcher = mixinPattern.matcher(mixinClassName);
if (!matcher.matches()) throw new IllegalStateException("Bad mixin name " + mixinClassName);
String modId = matcher.group("modid");
return QuiltLoader.isModLoaded(modId);
return FabricLoader.getInstance().isModLoaded(modId);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.ladysnake.locki.impl.compat.mixin.backslot;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.backslot.network.SwitchPacketReceiver;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;
Expand All @@ -33,12 +34,20 @@ public abstract class SwitchPacketMixin {
public static boolean isItemAllowed(ItemStack stack, int slot) {
return false;
}

@Redirect(method = "receive", at = @At(value = "INVOKE", target = "Lnet/backslot/network/SwitchPacketReceiver;isItemAllowed(Lnet/minecraft/item/ItemStack;I)Z"))
/*TODO
@WrapWithCondition(
method = "receive(Lnet/backslot/network/SwitchPacket;Lnet/fabricmc/fabric/api/networking/v1/ServerPlayNetworking$Context;)V",
at = @At(
value = "INVOKE",
target = ""
)
)
private boolean lockAdditionalSlots(ItemStack stack, int slot, MinecraftServer server, ServerPlayerEntity player) {
if (InventoryKeeper.get(player).isSlotLocked(slot)) {
return false;
}
return isItemAllowed(stack, slot);
}

*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
public abstract class InputSlotFillerMixin {
@Shadow protected AbstractRecipeScreenHandler<?, ?> handler;

@WrapOperation(method = "fillInputSlots(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/recipe/RecipeHolder;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeMatcher;match(Lnet/minecraft/recipe/Recipe;Lit/unimi/dsi/fastutil/ints/IntList;)Z"))
@WrapOperation(method = "fillInputSlots(Lnet/minecraft/server/network/ServerPlayerEntity;Lnet/minecraft/recipe/RecipeEntry;Z)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeMatcher;match(Lnet/minecraft/recipe/Recipe;Lit/unimi/dsi/fastutil/ints/IntList;)Z"))
private boolean blockInventoryCrafting(RecipeMatcher instance, Recipe<?> recipe, IntList output, Operation<Boolean> original, ServerPlayerEntity entity) {
if (this.handler == entity.playerScreenHandler && InventoryKeeper.get(entity).isLocked(DefaultInventoryNodes.CRAFTING_GRID)) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package org.ladysnake.locki.impl.mixin;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
Expand All @@ -29,7 +31,6 @@
import org.ladysnake.locki.impl.LockiComponents;
import org.ladysnake.locki.impl.PlayerInventoryKeeper;
import org.objectweb.asm.Opcodes;
import org.quiltmc.loader.api.minecraft.ClientOnly;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand Down Expand Up @@ -111,7 +112,7 @@ private void constructor(PlayerEntity player, CallbackInfo ci) {
this.locki$keeper = LockiComponents.INVENTORY_KEEPER.maybeGet(player).orElse(null);
}

@ClientOnly
@Environment(EnvType.CLIENT)
@Inject(method = {"addPickBlock", "scrollInHotbar"},
at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/entity/player/PlayerInventory;selectedSlot:I", shift = At.Shift.AFTER)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.ladysnake.locki.impl.mixin;

import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.SelectedSlotUpdateC2SPacket;
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import org.ladysnake.locki.DefaultInventoryNodes;
Expand All @@ -35,8 +35,8 @@ public abstract class ServerPlayNetworkHandlerMixin {
@Shadow
public ServerPlayerEntity player;

@Inject(method = "onSelectedSlotUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/SelectedSlotUpdateC2SPacket;getSelectedSlot()I", ordinal = 0))
private void fixSelectedSlot(SelectedSlotUpdateC2SPacket packet, CallbackInfo ci) {
@Inject(method = "onUpdateSelectedSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/c2s/play/UpdateSelectedSlotC2SPacket;getSelectedSlot()I", ordinal = 0))
private void fixSelectedSlot(UpdateSelectedSlotC2SPacket packet, CallbackInfo ci) {
((UpdateSelectedSlotC2SPacketAccessor) packet).locki$setSelectedSlot(PlayerInventoryKeeper.fixSelectedSlot(player, packet.getSelectedSlot()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/
package org.ladysnake.locki.impl.mixin;

import net.minecraft.network.packet.c2s.play.SelectedSlotUpdateC2SPacket;
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(SelectedSlotUpdateC2SPacket.class)
@Mixin(UpdateSelectedSlotC2SPacket.class)
public interface UpdateSelectedSlotC2SPacketAccessor {
@Accessor("selectedSlot")
void locki$setSelectedSlot(int selectedSlot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
package org.ladysnake.locki.impl.mixin;

import net.minecraft.network.packet.c2s.play.SelectedSlotUpdateC2SPacket;
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;

@Mixin(SelectedSlotUpdateC2SPacket.class)
@Mixin(UpdateSelectedSlotC2SPacket.class)
public class UpdateSelectedSlotC2SPacketMixin {
@SuppressWarnings("unused") // only there to make selectedSlot mutable - for use by the accessor
@Shadow @Mutable @Final private int selectedSlot;
Expand Down
Loading
Loading