Skip to content

Commit e2b43de

Browse files
committed
added fabric api back
now everything seems to work (facepalm)
1 parent e822ae4 commit e2b43de

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ dependencies {
2626
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
2727
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
2828

29+
// Fabric API. This is technically optional, but you probably want it anyway.
30+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
31+
2932
// ModMenu
3033
modApi "com.terraformersmc:modmenu:6.2.1"
3134

@@ -56,7 +59,7 @@ java {
5659
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
5760
// if it is present.
5861
// If you remove this line, sources will not be generated.
59-
withSourcesJar()
62+
//withSourcesJar()
6063
}
6164

6265
jar {

src/main/java/io/csum/segmented/SegmentedMod.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,8 @@
44
import me.shedaniel.autoconfig.AutoConfig;
55
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
66
import net.fabricmc.api.ModInitializer;
7-
//import org.slf4j.Logger;
8-
//import org.slf4j.LoggerFactory;
97

108
public class SegmentedMod implements ModInitializer {
11-
//public static final String MOD_ID = "segmented";
12-
//public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
139
public static int selectedHotbarSegment = -1;
1410

1511
@Override

src/main/java/io/csum/segmented/client/gui/SegmentedHotbarRenderer.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,14 @@ public boolean renderSegmentedHotbar(MatrixStack matrices) {
4040
int scaledHeight = client.getWindow().getScaledHeight();
4141
Point2D.Float hotbar = new Point2D.Float(scaledWidthHalved + HOTBAR.x, scaledHeight + HOTBAR.y);
4242

43-
4443
RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
4544

4645
// draw the hotbar itself
4746
DrawableHelper.drawTexture(matrices,
4847
(int) hotbar.x,
4948
(int) hotbar.y,
50-
CANVAS_HOTBAR_POS.x,
51-
CANVAS_HOTBAR_POS.y,
49+
HOTBAR_POS.x,
50+
HOTBAR_POS.y,
5251
HOTBAR.width,
5352
HOTBAR.height,
5453
(int) CANVAS_SIZE.x,
@@ -59,8 +58,8 @@ public boolean renderSegmentedHotbar(MatrixStack matrices) {
5958
DrawableHelper.drawTexture(matrices,
6059
(int) hotbar.x - 1 + (inventory.selectedSlot * SLOT.width) + (HOTBAR_GAP * (inventory.selectedSlot / 3)),
6160
(int) hotbar.y - 1,
62-
VANILLA_SELECTOR.x,
63-
VANILLA_SELECTOR.y,
61+
VANILLA_SELECTOR_POS.x,
62+
VANILLA_SELECTOR_POS.y,
6463
VANILLA_SELECTOR.width,
6564
VANILLA_SELECTOR.height,
6665
(int) CANVAS_SIZE.x,
@@ -71,8 +70,8 @@ public boolean renderSegmentedHotbar(MatrixStack matrices) {
7170
drawTexture(matrices,
7271
(int) hotbar.x - 1 + (SEGMENT_SELECTOR.width * SegmentedMod.selectedHotbarSegment),
7372
(int) hotbar.y - 1,
74-
SEGMENT_SELECTOR.x,
75-
SEGMENT_SELECTOR.y,
73+
SEGMENT_SELECTOR_POS.x,
74+
SEGMENT_SELECTOR_POS.y,
7675
SEGMENT_SELECTOR.width,
7776
SEGMENT_SELECTOR.height,
7877
(int) CANVAS_SIZE.x,
@@ -89,8 +88,8 @@ public boolean renderSegmentedHotbar(MatrixStack matrices) {
8988
drawTexture(matrices,
9089
offHandX,
9190
(int) hotbar.y,
92-
OFFHAND_SLOT.x,
93-
OFFHAND_SLOT.y,
91+
OFFHAND_SLOT_POS.x,
92+
OFFHAND_SLOT_POS.y,
9493
OFFHAND_SLOT.width,
9594
OFFHAND_SLOT.height,
9695
(int) CANVAS_SIZE.x,

src/main/java/io/csum/segmented/client/util/Constants.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,32 @@
66

77
public class Constants {
88

9-
public static final Point2D.Float CANVAS_SIZE = new Point2D.Float(256, 64);
9+
public static final Point2D.Float CANVAS_SIZE = new Point2D.Float(256f, 64f);
10+
11+
// x and y mean the position of these in the texture canvas
12+
public static final Point2D.Float HOTBAR_POS = new Point2D.Float(0f, 0f);
13+
public static final Point2D.Float SEGMENT_SELECTOR_POS = new Point2D.Float(0f, 22f);
14+
public static final Point2D.Float VANILLA_SELECTOR_POS = new Point2D.Float(64f, 22f);
15+
public static final Point2D.Float OFFHAND_SLOT_POS = new Point2D.Float(192f, 0f);
1016

1117
/*
1218
* x and y are the offsets needed to get from the middle and bottom of the screen to the top left of the hotbar
1319
* the actual y value is offset by -1 so the hotbar is not cut off as it would be in vanilla
1420
*/
1521
public static final Rectangle HOTBAR = new Rectangle(-95, -23, 190, 22);
16-
17-
// the gap in the hotbar
18-
public static final int HOTBAR_GAP = 4;
19-
20-
// here, x and y mean the position of these in the texture canvas
21-
public static final Point2D.Float CANVAS_HOTBAR_POS = new Point2D.Float(0, 0);
22-
public static final Rectangle SEGMENT_SELECTOR = new Rectangle(0, 22, 64, 24);
23-
public static final Rectangle VANILLA_SELECTOR = new Rectangle(64, 22, 24, 24);
24-
public static final Rectangle OFFHAND_SLOT = new Rectangle(192, 0, 22, 22);
25-
22+
public static final Rectangle SEGMENT_SELECTOR = new Rectangle(64, 24);
23+
public static final Rectangle VANILLA_SELECTOR = new Rectangle(24, 24);
24+
public static final Rectangle OFFHAND_SLOT = new Rectangle(22, 22);
2625

2726
// the size of a single slot
2827
public static final Rectangle SLOT = new Rectangle(20, 20);
2928

3029
// the x and y inset of an item sprite in a slot
3130
public static final int ITEM_INSET = 3;
31+
32+
// the gap in the hotbar
33+
public static final int HOTBAR_GAP = 4;
34+
3235
public static final int SLOTS = 9;
3336

3437
}

src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232

3333
"depends": {
3434
"fabricloader": ">=0.14.6",
35-
"fabric": "*",
3635
"minecraft": "~1.19.4",
36+
"fabric": "*",
3737
"java": ">=17",
3838
"cloth-config2": "*"
3939
},

0 commit comments

Comments
 (0)