Skip to content

Commit

Permalink
Drawer Key Clearing Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Sep 15, 2024
1 parent e401016 commit 7b271e5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ org.gradle.jvmargs = -Xmx3G

# Custom Dep Settings. Make sure to run Setup Workspace/Reload Gradle Project after changing.

# Whether to enable Storage Drawers and its deps in runtime. Enables Hand Framing Tool.
# Whether to enable Storage Drawers and its deps in runtime. Enables Hand Framing Tool, and Drawer Key Fix.
# If this is set to false, the hand framing tool is disabled.
enable_storage_drawers = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class LabsLateMixinLoader implements ILateMixinLoader {
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BOGOSORT_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.THERMAL_FOUNDATION_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BQU_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BETTER_P2P_MODID, true))
new AbstractMap.SimpleImmutableEntry<>(LabsValues.BETTER_P2P_MODID, true),
new AbstractMap.SimpleImmutableEntry<>(LabsValues.STORAGE_DRAWERS_MODID, true))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.nomiceu.nomilabs.mixin.storagedrawers;

import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerAttributes;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
import com.jaquadro.minecraft.storagedrawers.block.tile.tiledata.StandardDrawerGroup;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = StandardDrawerGroup.DrawerData.class, remap = false)
public abstract class DrawerDataMixin {

@Shadow
private int count;

@Shadow
IDrawerAttributes attrs;

@Shadow
protected abstract void reset(boolean notify);

@Inject(method = "syncAttributes", at = @At("HEAD"))
private void labs$updateEmptyStatus(CallbackInfo ci) {
if (count == 0 && !attrs.isItemLocked(LockAttribute.LOCK_POPULATED))
reset(true);
}
}
12 changes: 12 additions & 0 deletions src/main/resources/mixins.nomilabs.storagedrawers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"package": "com.nomiceu.nomilabs.mixin.storagedrawers",
"refmap": "mixins.nomilabs.refmap.json",
"target": "@env(DEFAULT)",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"DrawerDataMixin"
],
"client": [],
"server": []
}

0 comments on commit 7b271e5

Please sign in to comment.