Skip to content

Commit

Permalink
fix the screen size overlap bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Sep 21, 2024
1 parent 4e5c693 commit 5386a3d
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ minecraft {
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
property 'forge.enabledGameTestNamespaces', mod_id
args '--nogui'
// args '--nogui'
}

// This run config launches GameTestServer and runs all registered gametests, then exits.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.daemon=false

mod_id=storagenetwork
curse_id=268495
mod_version=1.11.0-SNAPSHOT
mod_version=1.11.0



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.lothrazar.storagenetwork.api.EnumSortType;
import com.lothrazar.storagenetwork.api.IGuiNetwork;
import com.lothrazar.storagenetwork.gui.NetworkWidget;
import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize;
import com.lothrazar.storagenetwork.jei.JeiHooks;
import com.lothrazar.storagenetwork.network.ClearRecipeMessage;
import com.lothrazar.storagenetwork.network.RequestMessage;
Expand Down Expand Up @@ -38,11 +39,9 @@ public class ScreenNetworkInventory extends AbstractContainerScreen<ContainerNet
public ScreenNetworkInventory(ContainerNetworkInventory container, Inventory inv, Component name) {
super(container, inv, name);
tile = container.tile;
network = new NetworkWidget(this);
network.setLines(8);
network = new NetworkWidget(this, NetworkGuiSize.LARGE);
imageWidth = WIDTH;
imageHeight = HEIGHT;
network.fieldHeight = 180;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.lothrazar.storagenetwork.api.EnumSortType;
import com.lothrazar.storagenetwork.api.IGuiNetwork;
import com.lothrazar.storagenetwork.gui.NetworkWidget;
import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize;
import com.lothrazar.storagenetwork.jei.JeiHooks;
import com.lothrazar.storagenetwork.network.ClearRecipeMessage;
import com.lothrazar.storagenetwork.network.RequestMessage;
Expand Down Expand Up @@ -36,7 +37,7 @@ public class ScreenNetworkTable extends AbstractContainerScreen<ContainerNetwork
public ScreenNetworkTable(ContainerNetworkCraftingTable container, Inventory inv, Component name) {
super(container, inv, name);
tile = container.getTileRequest();
network = new NetworkWidget(this);
network = new NetworkWidget(this, NetworkGuiSize.NORMAL);
imageWidth = WIDTH;
imageHeight = HEIGHT;
}
Expand Down
38 changes: 33 additions & 5 deletions src/main/java/com/lothrazar/storagenetwork/gui/NetworkWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class NetworkWidget {
public ButtonRequest sortBtn;
public ButtonRequest jeiBtn;
public ButtonRequest focusBtn;
public int fieldHeight = 90;
private int fieldHeight = 90;
private List<ItemSlotNetwork> slots;
private final IGuiNetwork gui;
private long lastClick;
Expand All @@ -53,8 +53,22 @@ public class NetworkWidget {
private int lines = 4;
private final int columns = 9;

@Deprecated
public NetworkWidget(IGuiNetwork gui) {
this(gui, NetworkGuiSize.NORMAL);
}
public NetworkWidget(IGuiNetwork gui, NetworkGuiSize size) {
this.gui = gui;
switch (size) {
case LARGE:
setLines(8);
setFieldHeight(180 - 8); // the jei -8 gets fixed here now
break;
case NORMAL:
setLines(4);
setFieldHeight(90);
break;
}
stacks = Lists.newArrayList();
slots = Lists.newArrayList();
PacketRegistry.INSTANCE.sendToServer(new RequestMessage());
Expand Down Expand Up @@ -171,7 +185,7 @@ public void rebuildItemSlots(List<ItemStack> stacksToDisplay) {
break;
}
int in = index;
// StorageNetwork.LOGGER.info(in + "GUI STORAGE rebuildItemSlots "+stacksToDisplay.get(in));

slots.add(new ItemSlotNetwork(gui, stacksToDisplay.get(in),
gui.getGuiLeft() + 8 + col * 18,
gui.getGuiTopFixJei() + 10 + row * 18,
Expand Down Expand Up @@ -301,21 +315,23 @@ public void mouseClicked(double mouseX, double mouseY, int mouseButton) {
&& (mouseButton == UtilTileEntity.MOUSE_BTN_LEFT || mouseButton == UtilTileEntity.MOUSE_BTN_RIGHT)
&& stackCarriedByMouse.isEmpty() &&
this.canClick()) {
// Request an item (from the network) if we are in the upper section of the GUI
PacketRegistry.INSTANCE.sendToServer(new RequestMessage(mouseButton, this.stackUnderMouse.copy(), Screen.hasShiftDown(),
Screen.hasAltDown() || Screen.hasControlDown()));
this.lastClick = System.currentTimeMillis();
}
else if (!stackCarriedByMouse.isEmpty() && inField((int) mouseX, (int) mouseY) &&
this.canClick()) {
//0 isd getDim()
// Insert the item held by the mouse into the network
PacketRegistry.INSTANCE.sendToServer(new InsertMessage(0, mouseButton));
this.lastClick = System.currentTimeMillis();
}
}

private boolean inField(int mouseX, int mouseY) {
return mouseX > (gui.getGuiLeft() + 7) && mouseX < (gui.getGuiLeft() + ScreenNetworkTable.WIDTH - 7)
&& mouseY > (gui.getGuiTopFixJei() + 7) && mouseY < (gui.getGuiTopFixJei() + fieldHeight);
boolean inField = mouseX > (gui.getGuiLeft() + 7) && mouseX < (gui.getGuiLeft() + ScreenNetworkTable.WIDTH - 7)
&& mouseY > (gui.getGuiTopFixJei() + 7) && mouseY < (gui.getGuiTopFixJei() + getFieldHeight());
return inField;
}

public void initButtons() {
Expand Down Expand Up @@ -386,6 +402,14 @@ public void render() {
}
}

public int getFieldHeight() {
return fieldHeight;
}

public void setFieldHeight(int fieldHeight) {
this.fieldHeight = fieldHeight;
}

public interface ISearchHandler {

public abstract void setSearch(String set);
Expand All @@ -394,4 +418,8 @@ public interface ISearchHandler {

public abstract String getName();
}

public enum NetworkGuiSize {
NORMAL, LARGE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.lothrazar.storagenetwork.api.EnumSortType;
import com.lothrazar.storagenetwork.api.IGuiNetwork;
import com.lothrazar.storagenetwork.gui.NetworkWidget;
import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize;
import com.lothrazar.storagenetwork.jei.JeiHooks;
import com.lothrazar.storagenetwork.network.ClearRecipeMessage;
import com.lothrazar.storagenetwork.network.RequestMessage;
Expand Down Expand Up @@ -35,11 +36,10 @@ public ScreenNetworkCraftingRemote(ContainerNetworkCraftingRemote screenContaine
super(screenContainer, inv, titleIn);
//since the rightclick action forces only MAIN_HAND openings, is ok
this.remote = screenContainer.getRemote();// inv.player.getItemInHand(InteractionHand.MAIN_HAND);
network = new NetworkWidget(this);
network.setLines(4);
network = new NetworkWidget(this, NetworkGuiSize.NORMAL);

this.imageWidth = WIDTH;
this.imageHeight = HEIGHT;
network.fieldHeight = 90;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.lothrazar.storagenetwork.api.EnumSortType;
import com.lothrazar.storagenetwork.api.IGuiNetwork;
import com.lothrazar.storagenetwork.gui.NetworkWidget;
import com.lothrazar.storagenetwork.gui.NetworkWidget.NetworkGuiSize;
import com.lothrazar.storagenetwork.jei.JeiHooks;
import com.lothrazar.storagenetwork.network.SettingsSyncMessage;
import com.lothrazar.storagenetwork.registry.PacketRegistry;
Expand Down Expand Up @@ -32,11 +33,9 @@ public ScreenNetworkRemote(ContainerNetworkRemote screenContainer, Inventory inv
super(screenContainer, inv, titleIn);
//since the rightclick action forces only MAIN_HAND openings, is ok
this.remote = screenContainer.getRemote();//inv.player.getItemInHand(InteractionHand.MAIN_HAND);
network = new NetworkWidget(this);
network.setLines(8);
network = new NetworkWidget(this, NetworkGuiSize.LARGE);
this.imageWidth = WIDTH;
this.imageHeight = HEIGHT;
network.fieldHeight = 180;
}

@Override
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/lothrazar/storagenetwork/jei/JeiHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ private static IJeiRuntime getRuntime() {
}
}

private static String getJeiTextInternal() {
return getRuntime().getIngredientFilter().getFilterText();
}

public static void testJeiKeybind(InputConstants.Key keyCode, ItemStack stackUnderMouse) {
try {
if (!isJeiLoaded() || getRuntime() == null) {
Expand Down
4 changes: 2 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"1.19.2-latest": "1.7.0",
"1.19.3-latest": "1.8.0",
"1.19.4-latest": "1.9.0",
"1.20.1-latest": "1.10.1"
"1.20.1-latest": "1.11.0"
},
"1.19.2": {
"1.7.0":"Merged 1.18.2-1.7.0. Compatible with jei==11.4+, forge=43+. Community Pull Request Contributions: Merge pull request #492 from IIpragmaII/trunk/1.18 @IIpragmaII @VasurTrekkson Improved performance for export node. fix priority german translation @lightlike . Fixed recipes not showing when pressing the JEI recipe key @Demerso. Create uk_ua.json @SKZGx . "
Expand All @@ -22,6 +22,6 @@
"1.20.1": {
"1.10.0":"Ported to 1.20.1, depends on flib-0.0.7+ . Fixed patchouli book. Port to new non-deprecated curios datapack tags. Includes pull requests merged into the 1.18 and 1.19 branches : Merge pull request #492 from IIpragmaII/trunk/1.18 @IIpragmaII @VasurTrekkson Improved performance for export node. fix priority german translation @lightlike . Fixed recipes not showing when pressing the JEI recipe key @Demerso. Create uk_ua.json @SKZGx "
,"1.10.1":" Merge pull request #518 from ALFEECLARE: add ja_jp translation."
,"1.10.2":" Merge pull request #536 from maxpowa : Add support for EMI mod; this also fixes crash #513. "
,"1.11.0":" Fix the bug when using small window sizes where the top row of player inventory items getting inserted instead of picked up when using the remote when jei is installed. Merge pull request #536 from maxpowa : Add support for EMI mod; this also fixes crash #513. "
}
}

0 comments on commit 5386a3d

Please sign in to comment.