-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pump not filling itself and overhaul Tweakeruler controls
- Loading branch information
1 parent
6d92fb8
commit 5d4af71
Showing
24 changed files
with
754 additions
and
99 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
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
5 changes: 5 additions & 0 deletions
5
src/main/java/martian/minefactorial/client/overlay/package-info.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,5 @@ | ||
@OnlyIn(Dist.CLIENT) | ||
package martian.minefactorial.client.overlay; | ||
|
||
import net.neoforged.api.distmarker.Dist; | ||
import net.neoforged.api.distmarker.OnlyIn; |
74 changes: 74 additions & 0 deletions
74
src/main/java/martian/minefactorial/client/overlay/scrollmenu/OverlayScrollMenu.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,74 @@ | ||
package martian.minefactorial.client.overlay.scrollmenu; | ||
|
||
import martian.minefactorial.client.MFKeys; | ||
import net.minecraft.client.DeltaTracker; | ||
import net.minecraft.client.gui.GuiGraphics; | ||
import net.minecraft.client.gui.LayeredDraw; | ||
import net.minecraft.util.Mth; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Stack; | ||
|
||
public class OverlayScrollMenu implements LayeredDraw.Layer { | ||
private static final Stack<ScrollMenu> MENUS = new Stack<>(); | ||
|
||
public static final int LINE_HEIGHT = 20; | ||
public static final float EASING = 0.1f; | ||
|
||
@Override | ||
public void render(@NotNull GuiGraphics graphics, @NotNull DeltaTracker delta) { | ||
if (MENUS.isEmpty()) { | ||
return; | ||
} | ||
|
||
// Render each menu | ||
for (int i = 0; i < MENUS.size(); i++) { | ||
int finalI = i; // Copy `i` | ||
MENUS.forEach(menu -> menu.render(graphics, finalI * 64)); | ||
} | ||
|
||
// Get the top menu to control it | ||
ScrollMenu top = MENUS.peek(); | ||
|
||
if (MFKeys.SCROLL_MENU_DOWN.get().consumeClick()) { | ||
top.selection++; | ||
if (top.selection >= top.entries.size()) { | ||
top.selection = 0; | ||
} | ||
} else if (MFKeys.SCROLL_MENU_UP.get().consumeClick()) { | ||
top.selection--; | ||
if (top.selection < 0) { | ||
top.selection = top.entries.size() - 1; | ||
} | ||
} | ||
|
||
if (MFKeys.SCROLL_MENU_SELECT.get().consumeClick()) { | ||
top.entries.get(top.selection).callback().onSelect(); | ||
MENUS.pop(); | ||
} | ||
} | ||
|
||
public static boolean isMenuOpen() { | ||
return !MENUS.isEmpty(); | ||
} | ||
|
||
public static void clearMenus() { | ||
MENUS.clear(); | ||
} | ||
|
||
public static void pushMenu(ScrollMenu menu) { | ||
MENUS.push(menu); | ||
} | ||
|
||
public static ScrollMenu popMenu() { | ||
return MENUS.pop(); | ||
} | ||
|
||
public static ScrollMenu getTopMenu() { | ||
return MENUS.peek(); | ||
} | ||
|
||
public static Stack<ScrollMenu> getMenus() { | ||
return MENUS; | ||
} | ||
} |
Oops, something went wrong.