-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto Import Items for Alloy Forgery Recipes within REI
- Loading branch information
1 parent
3a028be
commit 67276a2
Showing
6 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/wraith/alloyforgery/compat/rei/AlloyForgeryCommonPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package wraith.alloyforgery.compat.rei; | ||
|
||
import me.shedaniel.rei.api.common.display.DisplaySerializerRegistry; | ||
import me.shedaniel.rei.api.common.plugins.REIServerPlugin; | ||
import me.shedaniel.rei.api.common.transfer.info.MenuInfoRegistry; | ||
import me.shedaniel.rei.api.common.transfer.info.simple.SimpleMenuInfoProvider; | ||
import wraith.alloyforgery.AlloyForgeScreenHandler; | ||
|
||
public class AlloyForgeryCommonPlugin implements REIServerPlugin { | ||
|
||
@Override | ||
public void registerMenuInfo(MenuInfoRegistry registry) { | ||
registry.register(AlloyForgingCategory.ID, AlloyForgeScreenHandler.class, SimpleMenuInfoProvider.of(AlloyForgeryMenuInfo::new)); | ||
} | ||
|
||
@Override | ||
public void registerDisplaySerializer(DisplaySerializerRegistry registry) { | ||
registry.register(AlloyForgingCategory.ID, AlloyForgingDisplay.Serializer.INSTANCE); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/wraith/alloyforgery/compat/rei/AlloyForgeryMenuInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package wraith.alloyforgery.compat.rei; | ||
|
||
import me.shedaniel.rei.api.common.transfer.info.MenuInfoContext; | ||
import me.shedaniel.rei.api.common.transfer.info.clean.InputCleanHandler; | ||
import me.shedaniel.rei.api.common.transfer.info.simple.SimplePlayerInventoryMenuInfo; | ||
import me.shedaniel.rei.api.common.transfer.info.stack.SlotAccessor; | ||
import net.minecraft.inventory.Inventory; | ||
import wraith.alloyforgery.AlloyForgeScreenHandler; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public record AlloyForgeryMenuInfo(AlloyForgingDisplay display) implements SimplePlayerInventoryMenuInfo<AlloyForgeScreenHandler, AlloyForgingDisplay> { | ||
|
||
@Override | ||
public Iterable<SlotAccessor> getInputSlots(MenuInfoContext<AlloyForgeScreenHandler, ?, AlloyForgingDisplay> context) { | ||
Inventory inventory = context.getMenu().getControllerInventory(); | ||
|
||
List<SlotAccessor> list = new ArrayList<>(inventory.size() - 2); | ||
for (int i = 0; i < inventory.size() - 2; i++) { | ||
list.add(SlotAccessor.fromContainer(inventory, i)); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
@Override | ||
public AlloyForgingDisplay getDisplay() { | ||
return this.display; | ||
} | ||
|
||
@Override | ||
public InputCleanHandler<AlloyForgeScreenHandler, AlloyForgingDisplay> getInputCleanHandler() { | ||
return context -> { | ||
for (SlotAccessor gridStack : getInputSlots(context)) { | ||
InputCleanHandler.returnSlotsToPlayerInventory(context, getDumpHandler(), gridStack); | ||
} | ||
|
||
clearInputSlots(context.getMenu()); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters