Skip to content

Commit dac0f9e

Browse files
committed
shit works 2
1 parent 46628a1 commit dac0f9e

File tree

4 files changed

+47
-17
lines changed

4 files changed

+47
-17
lines changed

src/main/java/net/midget807/jewellery_box/block/jewellery_box/JewelleryBoxBlock.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,30 @@ public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEnt
7171
if (world.isClient) {
7272
return ActionResult.SUCCESS;
7373
} else {
74-
player.openHandledScreen(
75-
new SimpleNamedScreenHandlerFactory(
76-
(syncId, playerInventory, player1) -> JewelleryBoxScreenHandler.createFull(syncId, playerInventory), this.getName()
77-
)
78-
);
74+
switch (size) {
75+
case 2:
76+
player.openHandledScreen(
77+
new SimpleNamedScreenHandlerFactory(
78+
(syncId, playerInventory, player1) -> JewelleryBoxScreenHandler.createQuarter(syncId, playerInventory), this.getName()
79+
)
80+
);
81+
break;
82+
case 4:
83+
player.openHandledScreen(
84+
new SimpleNamedScreenHandlerFactory(
85+
(syncId, playerInventory, player1) -> JewelleryBoxScreenHandler.createHalf(syncId, playerInventory), this.getName()
86+
)
87+
);
88+
break;
89+
default:
90+
player.openHandledScreen(
91+
new SimpleNamedScreenHandlerFactory(
92+
(syncId, playerInventory, player1) -> JewelleryBoxScreenHandler.createFull(syncId, playerInventory), this.getName()
93+
)
94+
);
95+
break;
96+
}
97+
7998
player.incrementStat(this.getOpenStat());
8099
PiglinBrain.onGuardedBlockInteracted(player, true);
81100

src/main/java/net/midget807/jewellery_box/client/screen/JewelleryBoxScreen.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.midget807.jewellery_box.client.screen;
22

3+
import net.midget807.jewellery_box.JewelleryBoxMain;
34
import net.midget807.jewellery_box.screen.jewellery_box.JewelleryBoxScreenHandler;
45
import net.minecraft.client.gui.DrawContext;
56
import net.minecraft.client.gui.screen.ingame.HandledScreen;
@@ -9,12 +10,14 @@
910
import net.minecraft.util.Identifier;
1011

1112
public class JewelleryBoxScreen extends HandledScreen<JewelleryBoxScreenHandler> implements ScreenHandlerProvider<JewelleryBoxScreenHandler> {
12-
private static final Identifier TEXTURE = new Identifier("textures/gui/container/generic_54.png");
13+
private static final Identifier TEXTURE_8 = new Identifier(JewelleryBoxMain.MOD_ID, "textures/gui/container/jewellery_box_8.png");
14+
private static final Identifier TEXTURE_4 = new Identifier(JewelleryBoxMain.MOD_ID, "textures/gui/container/jewellery_box_4.png");
15+
private static final Identifier TEXTURE_2 = new Identifier(JewelleryBoxMain.MOD_ID, "textures/gui/container/jewellery_box_2.png");
1316
private final int columns;
1417
public JewelleryBoxScreen(JewelleryBoxScreenHandler handler, PlayerInventory inventory, Text title) {
1518
super(handler, inventory, title);
1619
this.columns = handler.getColumns();
17-
this.backgroundHeight = 114;
20+
this.backgroundHeight = 133;
1821
this.playerInventoryTitleY = this.backgroundHeight - 94;
1922
}
2023

@@ -29,7 +32,15 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
2932
protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
3033
int i = (this.width - this.backgroundWidth) / 2;
3134
int j = (this.height - this.backgroundHeight) / 2;
32-
context.drawTexture(TEXTURE, i, j, 0, 0, this.columns * 18 + 17, this.backgroundHeight);
33-
context.drawTexture(TEXTURE, i, j + 18 + 17, 0, 126, this.columns * 18 + 17, 96);
35+
switch (columns) {
36+
case 4:
37+
context.drawTexture(TEXTURE_4, i, j, 0, 0, this.backgroundWidth, this.backgroundHeight);
38+
break;
39+
case 2:
40+
context.drawTexture(TEXTURE_2, i, j, 0, 0, this.backgroundWidth, this.backgroundHeight);
41+
break;
42+
default:
43+
context.drawTexture(TEXTURE_8, i, j, 0, 0, this.backgroundWidth, this.backgroundHeight);
44+
}
3445
}
3546
}

src/main/java/net/midget807/jewellery_box/screen/jewellery_box/JewelleryBoxScreenHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ public static JewelleryBoxScreenHandler createQuarter(int syncId, PlayerInventor
2929
}
3030
public JewelleryBoxScreenHandler(ScreenHandlerType<?> type, int syncId, PlayerInventory playerInventory, Inventory inventory, int columns) {
3131
super(type, syncId);
32-
checkSize(inventory, columns);
3332
this.inventory = inventory;
3433
this.columns = columns;
34+
checkSize(inventory, columns);
3535
inventory.onOpen(playerInventory.player);
36-
int i = -3 * 18;
36+
int i = 51;
3737
for (int j = 0; j < columns; j++) {
38-
this.addSlot(new Slot(inventory, j, 8 + j * 18, 18));
38+
this.addSlot(new Slot(inventory, j, 17 + j * 18, 20));
3939
}
4040
for (int j = 0; j < 3; j++) {
4141
for (int k = 0; k < 9; k++) {
42-
this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
42+
this.addSlot(new Slot(playerInventory, k + j * 9 + 9, 8 + k * 18, j * 18 + i));
4343
}
4444
}
4545

4646
for (int j = 0; j < 9; j++) {
47-
this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 161 + i));
47+
this.addSlot(new Slot(playerInventory, j, 8 + j * 18, 109));
4848
}
4949
}
5050

@@ -55,11 +55,11 @@ public ItemStack quickMove(PlayerEntity player, int slot) {
5555
if (slot2 != null && slot2.hasStack()) {
5656
ItemStack itemStack2 = slot2.getStack();
5757
itemStack = itemStack2.copy();
58-
if (slot < columns) {
59-
if (!this.insertItem(itemStack2, columns, this.slots.size(), true)) {
58+
if (slot < this.inventory.size()) {
59+
if (!this.insertItem(itemStack2, this.inventory.size(), this.slots.size(), true)) {
6060
return ItemStack.EMPTY;
6161
}
62-
} else if (!this.insertItem(itemStack2, 0, columns, false)) {
62+
} else if (!this.insertItem(itemStack2, 0, this.inventory.size(), false)) {
6363
return ItemStack.EMPTY;
6464
}
6565

2.92 KB
Loading

0 commit comments

Comments
 (0)