forked from Andrew6rant/InventoryTabs
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bf61fe
commit e1b41a9
Showing
2 changed files
with
25 additions
and
4 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
18 changes: 18 additions & 0 deletions
18
src/main/java/folk/sisby/inventory_tabs/util/DrawUtil.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,18 @@ | ||
package folk.sisby.inventory_tabs.util; | ||
|
||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.util.Identifier; | ||
|
||
public class DrawUtil { | ||
public static void drawCrunched(DrawContext context, Identifier texture, int x, int y, int width, int height, int sourceWidth, int sourceHeight, int u, int v) { | ||
int leftWidth = width / 2 + (width % 2); | ||
int topHeight = height / 2 + (height % 2); | ||
int rightWidth = width - leftWidth; | ||
int bottomHeight = height - topHeight; | ||
|
||
context.drawTexture(texture, x, y, u, v, leftWidth, topHeight); // Top Left | ||
context.drawTexture(texture, x + leftWidth, y, u + sourceWidth - rightWidth, v, rightWidth, topHeight); // Top Right | ||
context.drawTexture(texture, x, y + topHeight, u, v + sourceHeight - bottomHeight, leftWidth, bottomHeight); // Bottom Left | ||
context.drawTexture(texture, x + leftWidth, y + topHeight, u + sourceWidth - rightWidth, v + sourceHeight - bottomHeight, rightWidth, bottomHeight); // Bottom Right | ||
} | ||
} |