Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
9fe3ca0
initial work on workbench port
ghzdude Jan 26, 2024
15e1a2e
make crafting logic not server only
ghzdude Jan 26, 2024
7244de3
fix crafting output slot
ghzdude Jan 26, 2024
f321ece
add class for jei recipe transfer
ghzdude Jan 26, 2024
5534582
update recipe appropriately
ghzdude Jan 26, 2024
571aec8
more work on ui
ghzdude Jan 26, 2024
9cacb7f
wrap InventoryCrafting
ghzdude Jan 26, 2024
bf72c78
more work on output crafting slot
ghzdude Jan 26, 2024
0d43da0
test extending modularslot
ghzdude Jan 26, 2024
ff8a469
more work on crafting logic
ghzdude Jan 26, 2024
b3b32f2
add method to get inventory
ghzdude Jan 26, 2024
bf035b6
implement method
ghzdude Jan 26, 2024
2f23636
sync crafting matrix
ghzdude Jan 26, 2024
c9ed5a9
fix some issues with the output slot
ghzdude Jan 26, 2024
849594a
more work on crafting logic woo
ghzdude Jan 26, 2024
7589dae
crafting logic mostly done now?
ghzdude Jan 26, 2024
6a8cd1f
work on workbench ui
ghzdude Jan 26, 2024
8842db7
make handlerlist nonfinal
ghzdude Jan 26, 2024
2c11ebe
add method to update cache handler
ghzdude Jan 26, 2024
c01808c
even more ui work
ghzdude Jan 26, 2024
6787f7c
the great commenting of 2024
ghzdude Jan 26, 2024
2da5cf1
update stack index
ghzdude Jan 27, 2024
18d1f57
revert change to itemCrafting
ghzdude Jan 27, 2024
380447b
simplify crafting logic slightly
ghzdude Jan 28, 2024
29acb35
more work on recipe logic
ghzdude Jan 28, 2024
98a7c71
move logic/fields in CachedRecipeData to CraftingRecipeLogic
ghzdude Jan 31, 2024
3ea0800
fix sync issue
ghzdude Jan 31, 2024
40d2372
properly fix sync issues
ghzdude Jan 31, 2024
7abfa4b
remove GregTechGuiTransferrableScreen.java and usages
ghzdude Feb 1, 2024
33561e1
implement jei compat directly
ghzdude Feb 1, 2024
2e0ac1a
add slot group for crafting matrix
ghzdude Feb 1, 2024
489af03
uncomment a portion of code
ghzdude Feb 1, 2024
e98c1bd
add recipe transferring from JEI
ghzdude Feb 1, 2024
07ec049
remove todo
ghzdude Feb 1, 2024
2a1b990
update handler on client
ghzdude Feb 1, 2024
2006809
remove available item map
ghzdude Feb 2, 2024
29e13bc
unique sync codes
ghzdude Feb 2, 2024
9593818
try implement storage view
ghzdude Feb 2, 2024
33dfea6
fully implement storage view
ghzdude Feb 2, 2024
640aff5
add method to get result stack
ghzdude Feb 3, 2024
7b6b2d0
fix issues with tools being damages
ghzdude Feb 3, 2024
1d0ce69
more work on ui
ghzdude Feb 3, 2024
db6bdc2
help me
ghzdude Feb 3, 2024
a1a86d8
only set stack if item is different from current
ghzdude Feb 3, 2024
45f90d6
don't throw exception
ghzdude Feb 3, 2024
c6f3d7d
notify neighbors on slot change
ghzdude Feb 3, 2024
9d219e0
make handler modifiable
ghzdude Feb 3, 2024
b3b9800
sync on contents change
ghzdude Feb 3, 2024
6143c41
don't call change on init
ghzdude Feb 3, 2024
b48304f
start work on recipe memorization
ghzdude Feb 4, 2024
2c4c4c1
small work
ghzdude Feb 15, 2024
eca5c00
add handler wrapper to handle incorrect slot gracefully
ghzdude Feb 23, 2024
e33263e
spotless
ghzdude Apr 17, 2024
f9116ae
add bogosorter as api
ghzdude Apr 17, 2024
41cf9aa
remove commented out code
ghzdude Apr 17, 2024
84f731c
ui testing
ghzdude Apr 18, 2024
bc86fbf
more ui testing
ghzdude Apr 18, 2024
feafa79
fixed(?) the grid
ghzdude Apr 19, 2024
55993b7
grid fixed
ghzdude Apr 19, 2024
1e512bb
more work on syncing and recipe logic
ghzdude Apr 19, 2024
375ab38
more work on syncing and recipe logic part 2 + spotless
ghzdude Apr 20, 2024
dad6f8d
simplify client syncing
ghzdude Apr 20, 2024
e2a2049
move crafting output slot into own class
ghzdude Apr 22, 2024
8606c55
we do a little refactoring
ghzdude Apr 22, 2024
99a4f8e
remove unused class
ghzdude Apr 22, 2024
f1d4655
move inventory wrapper class
ghzdude Apr 22, 2024
029ef96
collect items before each craft
ghzdude Apr 22, 2024
4e096ea
small fixes
ghzdude Apr 22, 2024
e0a9b41
small fixes part 2
ghzdude Apr 22, 2024
37703d2
small fixes part 3
ghzdude Apr 23, 2024
b4edef9
initial work on recipe memory
ghzdude Apr 24, 2024
c4698b3
make memory a sync handler
ghzdude Apr 24, 2024
f994568
more syncing fixes
ghzdude Apr 25, 2024
6b6f6ae
just crafting station things
ghzdude Apr 25, 2024
8548a20
improve crafting logic
ghzdude May 3, 2024
bdc5bbf
small rendering changes and other fixes
ghzdude May 3, 2024
a798ed3
fix rendering issues
ghzdude May 3, 2024
525781c
add locking rendering to memory slots
ghzdude May 3, 2024
eaba7ae
spotless
ghzdude May 3, 2024
92157a6
add crafting input slot
ghzdude May 3, 2024
620036c
work on various custom slots
ghzdude May 4, 2024
1136702
display and sync recipe memory times used
ghzdude May 4, 2024
8f9de58
fix tooltips for output and memory slots
ghzdude May 5, 2024
9479c89
sbobl
ghzdude May 5, 2024
eb34ae3
move changes to item handler list
ghzdude May 8, 2024
16b45dd
collect shift click slots manually
ghzdude May 11, 2024
a6aed65
integrate input slots with JEI
ghzdude Jun 4, 2024
30aa8a9
delete unused classes
ghzdude Jun 4, 2024
6877c8b
sboblss
ghzdude Jun 4, 2024
1ed3333
handle buckets properly
ghzdude Jun 4, 2024
1f4ea14
imrove wrapper and some javadocs
ghzdude Jun 4, 2024
3c8118f
Tinting (#2)
bruberu Jun 6, 2024
f096b03
fix overlay
ghzdude Jun 6, 2024
fbec6ad
casually rewrite recipe logic a bit :handsom:
ghzdude Jun 8, 2024
b16c5be
even more work on recipe logic
ghzdude Jun 9, 2024
86b1190
update todo
ghzdude Jun 9, 2024
7004a9a
make sure to use copy
ghzdude Jun 9, 2024
b210279
try and fail at shift transfer
ghzdude Jun 9, 2024
cc042d9
consume items correctly
ghzdude Jun 9, 2024
8b8eae6
sbobless
ghzdude Jun 9, 2024
055b86a
small fixes
ghzdude Jun 9, 2024
e29c370
add jei support for output slot
ghzdude Jun 9, 2024
7b5c11e
remove comment
ghzdude Jun 9, 2024
3a0b94c
make strategy ignore tag
ghzdude Jun 9, 2024
adc147f
remove the recipe on client
ghzdude Jun 9, 2024
88ff083
mostly fix recipe memory
ghzdude Jun 9, 2024
39d9627
add metadata to hash strategy
ghzdude Jun 9, 2024
2b9977f
minor fixes
ghzdude Jun 10, 2024
0476ce2
fix: all the bugs (#3)
bruberu Jun 26, 2024
f9530b6
fix rebase
ghzdude Jul 20, 2024
782d195
sootless
ghzdude Jul 20, 2024
53f1edd
epic rebase + spotless
ghzdude Aug 25, 2024
85ed6d5
improve recipe logic slightly
ghzdude Aug 25, 2024
7f273da
a few more optimizations
ghzdude Aug 28, 2024
72babe5
spblss
ghzdude Aug 28, 2024
dae5726
allow cache miss to set any stack it comes across, instead of just th…
ghzdude Oct 17, 2024
3cc5336
remove stack key if int set is empty
ghzdude Oct 17, 2024
572721b
fix rebase
ghzdude Jan 10, 2025
ddcf9a0
fix crafting widgets
ghzdude Jan 10, 2025
9f8aefb
missed a column
ghzdude Jan 10, 2025
dd973b3
use mui2 methods to draw item
ghzdude Jan 20, 2025
fa9557f
remove unneeded method
ghzdude Jan 20, 2025
4bf95a3
add todo lang
ghzdude Jan 29, 2025
627d2c1
cleanup CraftingOutputSlot
ghzdude Jan 29, 2025
1eda013
spotless
ghzdude Jan 29, 2025
595e3c6
remove workbench from JEI module
ghzdude Jan 29, 2025
a2da02b
remove unneeded override
ghzdude Jan 29, 2025
cf4bf30
name internal ids
ghzdude Jan 29, 2025
a411120
make constructor private
ghzdude Jan 29, 2025
71f5281
rename and cleanup
ghzdude Jan 29, 2025
e0933bc
cleanup and sort inventory list
ghzdude Jan 29, 2025
00cb341
fix lock not syncing
ghzdude Jan 29, 2025
2c7e4c8
oops
ghzdude Jan 29, 2025
1e6fc59
add button to clear grid
ghzdude Jan 30, 2025
5261d3a
implement multi-crafting with shift
ghzdude Jan 30, 2025
2f6b663
fix off by one crafting
ghzdude Jan 30, 2025
ac2b1e9
use modified draw item method
ghzdude Jan 30, 2025
a518150
reset ingredients
ghzdude Jan 30, 2025
f90dbf1
improve recipe memory offsetting
ghzdude Jan 30, 2025
1154606
no need to move recipes at index 0
ghzdude Jan 30, 2025
631ec1d
check and simulate if output can be inserted
ghzdude Jan 30, 2025
baccef0
clear and refresh the lookup map every tick
ghzdude Jan 30, 2025
5905980
fix issue with output slot not crafting when not holding shift
ghzdude Jan 30, 2025
0b5caea
more lang, remove todo
ghzdude Jan 30, 2025
f784b29
implement dragging for input slots
ghzdude Jan 31, 2025
dc2bf71
add todo
ghzdude Jan 31, 2025
ea54e87
fix toolbelt slot group
ghzdude Feb 1, 2025
5305077
fix tools not making crafting sounds
ghzdude Feb 1, 2025
213b735
fix item overlay rendering
ghzdude Feb 1, 2025
24f3e46
don't transfer if not in workbench
ghzdude Feb 1, 2025
98c17ed
make RecipeMemorySlot a jei ingredient provider
ghzdude Feb 1, 2025
2ac7f5d
fix duplicate recipe memory
ghzdude Feb 1, 2025
9148c5d
implement the fixes for phantom slots from mui2 master
ghzdude Feb 1, 2025
6ce953e
fix compile and add note
ghzdude Feb 3, 2025
8fa76a6
fix stack syncing
ghzdude Feb 5, 2025
4d062c2
fix scroll bar covering slots
ghzdude Feb 6, 2025
0d5d3b8
spotless
ghzdude Feb 6, 2025
0b013ec
fix substitute searching and finding required items
ghzdude Feb 6, 2025
dc6bb1f
only cast ingredient if enabled
ghzdude Feb 6, 2025
e85f863
don't set z level
ghzdude Feb 6, 2025
3b015b9
set active page to crafting when setting recipe from JEI
ghzdude Feb 6, 2025
b580b57
notify recipe logic when loading memorized recipes
ghzdude Feb 6, 2025
1079bca
sync handler on recipe logic construction
ghzdude Feb 6, 2025
d60abe1
simplify ToolItemStackHandler
ghzdude Feb 7, 2025
b34d7c9
sync slot and player for toolbelt
ghzdude Feb 7, 2025
e6589f0
don't reset selected slot in toolbelt
ghzdude Feb 7, 2025
95aea37
fix and improve the recipe repair mixin
ghzdude Feb 12, 2025
c6e68f3
send handler updates on network rebuild
ghzdude Feb 12, 2025
3cf0134
format amount crafted better
ghzdude Feb 12, 2025
ca9996e
add line for removing recipe
ghzdude Feb 12, 2025
d793acf
only sync mouse click if recipe is valid
ghzdude Feb 12, 2025
845c974
fix output slot shift clicking with full cursor item
ghzdude Feb 12, 2025
5443fb9
merge if statements
ghzdude Feb 12, 2025
b488da6
improve and clarify sync cursor item
ghzdude Feb 12, 2025
2f2df84
annotations
ghzdude Feb 12, 2025
f750d95
improve formatting a bit more
ghzdude Feb 12, 2025
36d713c
simplify CraftingOutputSlot MS and SH constructor
ghzdude Feb 12, 2025
aabe723
remove unused method
ghzdude Feb 12, 2025
4018512
fix oversight in ItemHandlerList
ghzdude Feb 13, 2025
a6dbac5
clarify gui actions and simplify syncing changes
ghzdude Feb 14, 2025
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
1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies {
api("codechicken:codechickenlib:3.2.3.358")
api("com.cleanroommc:modularui:2.5.0-rc3") { transitive = false }
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
api("curse.maven:inventory-bogosorter-632327:4951607-deobf-4951608-sources-4951609")
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
api("appeng:ae2-uel:v0.56.4") { transitive = false }
api rfg.deobf("curse.maven:ctm-267602:2915363") // CTM 1.0.2.31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public static int assignId() {
// Misc TEs (Transformer, World Accelerator)
public static final int SYNC_TILE_MODE = assignId();

// Crafting Station
public static final int UPDATE_CLIENT_HANDLER = assignId();

// Clipboard
public static final int CREATE_FAKE_UI = assignId();
public static final int MOUSE_POSITION = assignId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ public interface IQuantumController extends ICapabilityProvider {

long getTypeEnergy(IQuantumStorage<?> storage);

void updateHandler();
void onHandlerUpdate();
}
28 changes: 23 additions & 5 deletions src/main/java/gregtech/api/capability/impl/ItemHandlerList.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntArrayMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import org.jetbrains.annotations.NotNull;

import java.util.*;
Expand All @@ -16,7 +18,7 @@
public class ItemHandlerList implements IItemHandlerModifiable {

private final Int2ObjectMap<IItemHandler> handlerBySlotIndex = new Int2ObjectOpenHashMap<>();
private final Map<IItemHandler, Integer> baseIndexOffset = new IdentityHashMap<>();
private final Object2IntMap<IItemHandler> baseIndexOffset = new Object2IntArrayMap<>();

public ItemHandlerList(List<? extends IItemHandler> itemHandlerList) {
int currentSlotIndex = 0;
Expand All @@ -33,43 +35,55 @@ public ItemHandlerList(List<? extends IItemHandler> itemHandlerList) {
}
}

public int getIndexOffset(IItemHandler handler) {
return baseIndexOffset.getOrDefault(handler, -1);
}

@Override
public int getSlots() {
return handlerBySlotIndex.size();
}

@Override
public void setStackInSlot(int slot, @NotNull ItemStack stack) {
if (invalidSlot(slot)) return;
IItemHandler itemHandler = handlerBySlotIndex.get(slot);
if (!(itemHandler instanceof IItemHandlerModifiable))
throw new UnsupportedOperationException("Handler " + itemHandler + " does not support this method");
((IItemHandlerModifiable) itemHandler).setStackInSlot(slot - baseIndexOffset.get(itemHandler), stack);
int actualSlot = slot - baseIndexOffset.get(itemHandler);
if (itemHandler instanceof IItemHandlerModifiable modifiable) {
modifiable.setStackInSlot(actualSlot, stack);
} else {
itemHandler.extractItem(actualSlot, Integer.MAX_VALUE, false);
itemHandler.insertItem(actualSlot, stack, false);
}
}

@NotNull
@Override
public ItemStack getStackInSlot(int slot) {
if (invalidSlot(slot)) return ItemStack.EMPTY;
IItemHandler itemHandler = handlerBySlotIndex.get(slot);
int realSlot = slot - baseIndexOffset.get(itemHandler);
return itemHandler.getStackInSlot(slot - baseIndexOffset.get(itemHandler));
}

@Override
public int getSlotLimit(int slot) {
if (invalidSlot(slot)) return 0;
IItemHandler itemHandler = handlerBySlotIndex.get(slot);
return itemHandler.getSlotLimit(slot - baseIndexOffset.get(itemHandler));
}

@NotNull
@Override
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
if (invalidSlot(slot)) return stack;
IItemHandler itemHandler = handlerBySlotIndex.get(slot);
return itemHandler.insertItem(slot - baseIndexOffset.get(itemHandler), stack, simulate);
}

@NotNull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
if (invalidSlot(slot)) return ItemStack.EMPTY;
IItemHandler itemHandler = handlerBySlotIndex.get(slot);
return itemHandler.extractItem(slot - baseIndexOffset.get(itemHandler), amount, simulate);
}
Expand All @@ -78,4 +92,8 @@ public ItemStack extractItem(int slot, int amount, boolean simulate) {
public Collection<IItemHandler> getBackingHandlers() {
return Collections.unmodifiableCollection(handlerBySlotIndex.values());
}

private boolean invalidSlot(int slot) {
return slot < 0 && slot >= this.getSlots();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ public GTItemStackHandler(MetaTileEntity metaTileEntity, NonNullList<ItemStack>
this.metaTileEntity = metaTileEntity;
}

@Override
public void setStackInSlot(int slot, ItemStack stack) {
if (ItemStack.areItemStacksEqual(stack, getStackInSlot(slot)))
return;

super.setStackInSlot(slot, stack);
}

@Override
public void onContentsChanged(int slot) {
super.onContentsChanged(slot);
metaTileEntity.markDirty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public ModularPanel buildUI(HandGuiData guiData, PanelSyncManager guiSyncManager

int heightBonus = (handler.getSlots() / 9) * 18;

SlotGroup group = new SlotGroup("toolbelt_inventory", 9);
SlotGroup group = new SlotGroup("toolbelt_inventory", Math.min(handler.getSlots(), 9));
guiSyncManager.registerSlotGroup(group);

List<ItemSlot> slots = new ArrayList<>();
Expand Down Expand Up @@ -669,7 +669,6 @@ public boolean isItemValid(int slot, @NotNull ItemStack stack) {

@Override
protected void onContentsChanged(int slot) {
if (this.selectedSlot == slot) this.selectedSlot = -1;
this.updateSlot(slot);
this.update();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gregtech/api/mui/GTGuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ public static class IDs {

public static final UITexture MENU_OVERLAY = fullImage("textures/gui/overlay/menu_overlay.png");

public static final UITexture RECIPE_LOCK = fullImage("textures/gui/widget/lock.png");

// todo bronze/steel/primitive fluid slots?

// SLOT OVERLAYS
Expand Down Expand Up @@ -355,6 +357,7 @@ public static class IDs {
public static final UITexture BUTTON_AUTO_COLLAPSE = fullImage(
"textures/gui/widget/button_auto_collapse_overlay.png");
public static final UITexture BUTTON_X = fullImage("textures/gui/widget/button_x_overlay.png", true);
public static final UITexture BUTTON_CLEAR_GRID = fullImage("textures/gui/widget/button_clear_grid.png", false);

public static final UITexture BUTTON_CROSS = fullImage("textures/gui/widget/button_cross.png");
public static final UITexture BUTTON_REDSTONE_ON = fullImage("textures/gui/widget/button_redstone_on.png");
Expand Down
69 changes: 69 additions & 0 deletions src/main/java/gregtech/api/mui/GregTechGuiTransferHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package gregtech.api.mui;

import gregtech.api.mui.sync.PagedWidgetSyncHandler;
import gregtech.common.metatileentities.storage.CraftingRecipeLogic;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

import com.cleanroommc.modularui.screen.ModularContainer;
import com.cleanroommc.modularui.value.sync.PanelSyncManager;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.transfer.IRecipeTransferError;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandler;
import mezz.jei.api.recipe.transfer.IRecipeTransferHandlerHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class GregTechGuiTransferHandler implements IRecipeTransferHandler<ModularContainer> {

private final IRecipeTransferHandlerHelper handlerHelper;

public GregTechGuiTransferHandler(IRecipeTransferHandlerHelper handlerHelper) {
this.handlerHelper = handlerHelper;
}

@Override
public @NotNull Class<ModularContainer> getContainerClass() {
return ModularContainer.class;
}

@Override
public @Nullable IRecipeTransferError transferRecipe(ModularContainer container,
@NotNull IRecipeLayout recipeLayout,
@NotNull EntityPlayer player, boolean maxTransfer,
boolean doTransfer) {
if (!container.getSyncManager().isOpen("workbench")) {
return null;
}
PanelSyncManager syncManager = container.getSyncManager().getPanelSyncManager("workbench");
var recipeLogic = (CraftingRecipeLogic) syncManager.getSyncHandler("recipe_logic:0");
var pageController = (PagedWidgetSyncHandler) syncManager.getSyncHandler("page_controller:0");

if (!doTransfer) {
// todo highlighting in JEI?
return null;
}

var matrix = extractMatrix(recipeLayout.getItemStacks());
recipeLogic.fillCraftingGrid(matrix);
pageController.setPage(0);
return null;
}

private Int2ObjectMap<ItemStack> extractMatrix(IGuiItemStackGroup stackGroup) {
var ingredients = stackGroup.getGuiIngredients();
Int2ObjectMap<ItemStack> matrix = new Int2ObjectArrayMap<>(9);
for (var slot : ingredients.keySet()) {
if (slot != 0) {
var ing = ingredients.get(slot).getDisplayedIngredient();
if (ing == null) continue;
matrix.put(slot - 1, ingredients.get(slot).getDisplayedIngredient());
}
}
return matrix;
}
}
23 changes: 23 additions & 0 deletions src/main/java/gregtech/api/mui/InputAccessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package gregtech.api.mui;

import com.cleanroommc.modularui.api.widget.Interactable;
import com.cleanroommc.modularui.screen.viewport.LocatedWidget;

// todo remove on next mui2 update
// this can't be a true accessor because of illegal classloading
public interface InputAccessor {

boolean held();

void held(boolean held);

void timeHeld(long a);

LocatedWidget lastPressed();

void lastPressed(LocatedWidget last);

void lastButton(int b);

void addInteractable(Interactable i);
}
45 changes: 45 additions & 0 deletions src/main/java/gregtech/api/mui/sync/PagedWidgetSyncHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package gregtech.api.mui.sync;

import net.minecraft.network.PacketBuffer;

import com.cleanroommc.modularui.value.sync.SyncHandler;
import com.cleanroommc.modularui.widgets.PagedWidget;

public class PagedWidgetSyncHandler extends SyncHandler {

private final PagedWidget.Controller controller;
public static final int SET_PAGE = 0;

public PagedWidgetSyncHandler(PagedWidget.Controller controller) {
this.controller = controller;
}

@Override
public void readOnClient(int id, PacketBuffer buf) {
if (id == SET_PAGE) {
setPage(buf.readVarInt(), false);
}
}

@Override
public void readOnServer(int id, PacketBuffer buf) {
if (id == SET_PAGE) {
setPage(buf.readVarInt(), false);
}
}

public void setPage(int page) {
setPage(page, true);
}

public void setPage(int page, boolean sync) {
if (controller.isInitialised() && page != getPage()) {
controller.setPage(page);
if (sync) sync(SET_PAGE, buffer -> buffer.writeVarInt(page));
}
}

public int getPage() {
return controller.getActivePageIndex();
}
}
15 changes: 0 additions & 15 deletions src/main/java/gregtech/api/storage/ICraftingStorage.java

This file was deleted.

Loading