Skip to content

Commit

Permalink
better candle guidance in menu
Browse files Browse the repository at this point in the history
  • Loading branch information
afamiliarquiet committed Dec 2, 2024
1 parent bdd6e16 commit 7acab36
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ allows you to summon any entity to its location.
### blocks:
* summoning table! the centerpiece of any summoning ritual. used by..
throwing in a true name and building a couple rings of enchanted candles.
* crafted like an enchanting table, with a true name instead of a book and copper instead of diamonds
* crafted like an enchanting table, with a true name instead of a book and an amethyst shard and copper ingot instead of diamonds
* using a flint and steel on the summoning table while focusing will attempt to activate the summoning
* using a flint and steel on the summoning table without focusing will burn the true name you placed within
(assuming you did put one in - you should give it a try!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public SummoningTableMenu(int containerId, Inventory playerInventory, IItemHandl
}

// table inv
this.trueNameSlot = new MoodySlotItemHandler(tableInventory, 0, 44, 41) {
this.trueNameSlot = new MoodySlotItemHandler(tableInventory, 0, 44, 45) {
@Override
public boolean mayPlace(ItemStack itemStack) {
return itemStack.is(FamiliarItems.TRUE_NAME_ITEM);
Expand All @@ -65,18 +65,18 @@ public int getMaxStackSize() {
this.addSlot(this.trueNameSlot);
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
this.addSlot(new MoodySlotItemHandler(tableInventory, j + i * 2 + 1, 116 + j * 18, 32 + i * 18));
this.addSlot(new MoodySlotItemHandler(tableInventory, j + i * 2 + 1, 116 + j * 18, 36 + i * 18));
}
}

// player inv
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 98 + i * 18));
this.addSlot(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 105 + i * 18));
}
}
for (int k = 0; k < 9; k++) {
this.addSlot(new Slot(playerInventory, k, 8 + k * 18, 156));
this.addSlot(new Slot(playerInventory, k, 8 + k * 18, 163));
}

// table data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.afamiliarquiet.familiar_magic.client.gooey;

import com.mojang.datafixers.util.Pair;
import io.github.afamiliarquiet.familiar_magic.FamiliarTricks;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -9,6 +10,8 @@
import net.minecraft.world.entity.player.Inventory;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
import java.util.Optional;

import static io.github.afamiliarquiet.familiar_magic.FamiliarMagic.MOD_ID;

Expand All @@ -18,12 +21,30 @@ public class SummoningTableScreen extends AbstractContainerScreen<SummoningTable
private static final ResourceLocation BACKGROUND = ResourceLocation.fromNamespaceAndPath(MOD_ID, "textures/gui/container/summoning_table.png");
private static final ResourceLocation BACKGROUND_MOODY = ResourceLocation.fromNamespaceAndPath(MOD_ID, "textures/gui/container/summoning_table_blocked.png");

private static final ResourceLocation NO_CANDLE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/no_candle");
private static final ResourceLocation UNMATCHED_CANDLE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/unmatched_candle");
private static final ResourceLocation BAD_HEIGHT = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/bad_height");
private static final ResourceLocation BAD_QUANTITY = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/bad_quantity");
private static final ResourceLocation UNLIT_CANDLE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/unlit_candle");
private static final ResourceLocation MATCHED_CANDLE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/matched_candle");
private static final Pair<String, ResourceLocation> BAD_HEIGHT = Pair.of(
"gui.familiar_magic.candle_helper.bad_height",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/bad_height")
);
private static final Pair<String, ResourceLocation> BAD_QUANTITY = Pair.of(
"gui.familiar_magic.candle_helper.bad_quantity",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/bad_quantity")
);
private static final Pair<String, ResourceLocation> MATCHED_CANDLE = Pair.of(
"gui.familiar_magic.candle_helper.matched_candle",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/matched_candle")
);
private static final Pair<String, ResourceLocation> NO_CANDLE = Pair.of(
"gui.familiar_magic.candle_helper.no_candle",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/no_candle")
);
private static final Pair<String, ResourceLocation> UNLIT_CANDLE = Pair.of(
"gui.familiar_magic.candle_helper.unlit_candle",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/unlit_candle")
);
private static final Pair<String, ResourceLocation> UNMATCHED_CANDLE = Pair.of(
"gui.familiar_magic.candle_helper.unmatched_candle",
ResourceLocation.fromNamespaceAndPath(MOD_ID, "container/unmatched_candle")
);

private static final int[] CANDLE_CENTER_SCREEN_OFFSETS = {
-30,-30, -18,-30, -6,-30, 6,-30, 18,-30, 30,-30,
Expand All @@ -37,8 +58,8 @@ public class SummoningTableScreen extends AbstractContainerScreen<SummoningTable
public SummoningTableScreen(SummoningTableMenu menu, Inventory playerInventory, Component title) {
super(menu, playerInventory, title);
// i made this 14px taller than normal menu so make it BIGGER
this.inventoryLabelY += 14;
this.imageHeight += 14;
this.inventoryLabelY += 21;
this.imageHeight += 21;
}

@Override
Expand All @@ -54,11 +75,11 @@ protected void renderBg(GuiGraphics graphics, float partialTick, int mouseX, int
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTick) {
super.render(graphics, mouseX, mouseY, partialTick);
this.renderCandleGuide(graphics);
this.renderCandleGuide(graphics, mouseX, mouseY);
this.renderTooltip(graphics, mouseX, mouseY);
}

protected void renderCandleGuide(GuiGraphics graphics) {
protected void renderCandleGuide(GuiGraphics graphics, int mouseX, int mouseY) {
int centerX = this.leftPos + this.menu.trueNameSlot.x + 8;
int centerY = this.topPos + this.menu.trueNameSlot.y + 8;

Expand All @@ -71,20 +92,27 @@ protected void renderCandleGuide(GuiGraphics graphics) {
}

for (int i = 0; i < 32; i++) {
Pair<String, ResourceLocation> candleInfo = getCandleSprite(itemNybbles[i], worldNybbles[i], badItem);
renderCandleTile(
graphics,
centerX + CANDLE_CENTER_SCREEN_OFFSETS[i * 2],
centerY + CANDLE_CENTER_SCREEN_OFFSETS[i * 2 + 1],
getCandleSprite(itemNybbles[i], worldNybbles[i], badItem)
mouseX, mouseY,
candleInfo.getFirst(), candleInfo.getSecond()
);
}
}

private void renderCandleTile(GuiGraphics graphics, int centerX, int centerY, ResourceLocation candleSprite) {
graphics.blitSprite(candleSprite, centerX - 4, centerY - 4, 8, 8);
private void renderCandleTile(GuiGraphics graphics, int centerX, int centerY, int mouseX, int mouseY, String translationKey, ResourceLocation candleSprite) {
int x = centerX - 4;
int y = centerY - 4;
graphics.blitSprite(candleSprite, x, y, 8, 8);
if (this.isHovering(x - this.leftPos, y - this.topPos, 8, 8, mouseX, mouseY)) {
graphics.renderTooltip(this.font, List.of(Component.translatable(translationKey)), Optional.empty(), mouseX, mouseY);
}
}

private ResourceLocation getCandleSprite(byte item, byte world, boolean badItem) {
private Pair<String, ResourceLocation> getCandleSprite(byte item, byte world, boolean badItem) {
if ((FamiliarTricks.NO_CANDLE & world) != 0) { // no candle in world for nybble
return NO_CANDLE;
} else if ((item & 0b1100) != (world & 0b1100)) { // wrong height
Expand All @@ -99,23 +127,4 @@ private ResourceLocation getCandleSprite(byte item, byte world, boolean badItem)
return MATCHED_CANDLE;
}
}

@Override
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
super.renderLabels(guiGraphics, mouseX, mouseY);

// guiGraphics.drawString(
// this.font,
// Component.literal(FamiliarTricks.uuidToTrueName(UUIDUtil.uuidFromIntArray(new int[]{
// menu.tableData.get(0),
// menu.tableData.get(1),
// menu.tableData.get(2),
// menu.tableData.get(3)
// }))),
// 52,
// 31,
// 0x404040,
// false
// );
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.afamiliarquiet.familiar_magic.item;

import io.github.afamiliarquiet.familiar_magic.FamiliarMagic;
import io.github.afamiliarquiet.familiar_magic.FamiliarTricks;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.component.DataComponents;
Expand All @@ -12,7 +11,6 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ItemUtils;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/assets/familiar_magic/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"block.familiar_magic.summoning_table": "Summoning Table",
"block.familiar_magic.smoke_wisp": "Wisp of Smoke",
"container.familiar_magic.summon": "Summon",
"gui.familiar_magic.candle_helper.bad_height": "Misplaced Candle",
"gui.familiar_magic.candle_helper.bad_quantity": "Miscounted Candle",
"gui.familiar_magic.candle_helper.matched_candle": "Perfect Candle",
"gui.familiar_magic.candle_helper.no_candle": "Absent Candle",
"gui.familiar_magic.candle_helper.unlit_candle": "Dim Candle",
"gui.familiar_magic.candle_helper.unmatched_candle": "Pleasant Candle",
"gui.familiar_magic.summoning_request.name": "A Summoner Calls!",
"gui.familiar_magic.summoning_request.blurb": "Focus [%s] your mind and and Jump to their location or Sneak away from their call.",
"gui.familiar_magic.summoning_request.position": "%s / %s / %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
"particle": "familiar_magic:block/summoning_table_bottom",
"bottom": "familiar_magic:block/summoning_table_bottom",
"top": "familiar_magic:block/summoning_table_top",
"side": "familiar_magic:block/summoning_table_side"
"side": "familiar_magic:block/summoning_table_side",
"side_north": "familiar_magic:block/summoning_table_side_north",
"side_west": "familiar_magic:block/summoning_table_side_west"
},
"elements": [
{ "from": [ 0, 0, 0 ],
"to": [ 16, 12, 16 ],
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#bottom", "cullface": "down" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#top" },
"north": { "uv": [ 0, 4, 16, 16 ], "texture": "#side", "cullface": "north" },
"north": { "uv": [ 0, 4, 16, 16 ], "texture": "#side_north", "cullface": "north" },
"south": { "uv": [ 0, 4, 16, 16 ], "texture": "#side", "cullface": "south" },
"west": { "uv": [ 0, 4, 16, 16 ], "texture": "#side", "cullface": "west" },
"west": { "uv": [ 0, 4, 16, 16 ], "texture": "#side_west", "cullface": "west" },
"east": { "uv": [ 0, 4, 16, 16 ], "texture": "#side", "cullface": "east" }
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"N": {
"item": "familiar_magic:true_name"
},
"A": {
"item": "minecraft:amethyst_shard"
},
"C": {
"item": "minecraft:copper_ingot"
}
},
"pattern": [
" N ",
"C#C",
"A#C",
"###"
],
"result": {
Expand Down

0 comments on commit 7acab36

Please sign in to comment.