Skip to content

Commit

Permalink
re-implement item spawning and /give functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Mar 22, 2023
1 parent c0eb561 commit 7629d10
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
9 changes: 4 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ minecraft_version=1.19.3
yarn_mappings=1.19.3+build.4
loader_version=0.14.12
# Mod Properties
mod_version=0.3.1
mod_version=0.3.2
maven_group=com.glisco
archives_base_name=deathlog
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.69.1+1.19.3
fabric_version=0.76.0+1.19.3

# https://github.com/emilyploszaj/trinkets/releases
trinkets_version=3.5.0
trinkets_version=3.5.1

# https://maven.terraformersmc.com/releases/com/terraformersmc/modmenu
modmenu_version=5.0.2

# https://maven.wispforest.io/io/wispforest/owo-lib/
owo_version=0.9.3+1.19.3
owo_version=0.10.3+1.19.3

26 changes: 22 additions & 4 deletions src/main/java/com/glisco/deathlog/client/gui/DeathLogScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;
Expand Down Expand Up @@ -215,10 +216,27 @@ private ItemComponent makeItem(ItemStack stack, Insets margins) {
item.margins(margins);

if (!stack.isEmpty()) {
item.tooltip(stack.getTooltip(
client.player,
client.options.advancedItemTooltips ? TooltipContext.Default.ADVANCED : TooltipContext.Default.BASIC
));
var tooltip = stack.getTooltip(client.player, client.options.advancedItemTooltips ? TooltipContext.Default.ADVANCED : TooltipContext.Default.BASIC);
tooltip.add(Text.translatable(this.client.player.isCreative() ? "text.deathlog.action.give_item.spawn" : "text.deathlog.action.give_item.copy_give"));
item.tooltip(tooltip);

item.mouseDown().subscribe((mouseX, mouseY, button) -> {
if (button != GLFW.GLFW_MOUSE_BUTTON_MIDDLE) return false;

if (this.client.player.isCreative()) {
this.client.interactionManager.dropCreativeStack(stack);
} else {

String command = "/give " + client.player.getName().getString() +
" " +
Registries.ITEM.getId(stack.getItem()) +
stack.getOrCreateNbt().toString();

this.client.keyboard.setClipboard(command);
}

return true;
});
}

return item;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/deathlog/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
"key.deathlog.death_screen": "Death Log Screen",

"text.deathlog.action.restore": "Restore",
"text.deathlog.action.give_item.spawn": {"text": "Press Mouse 3 to spawn", "color": "gray"},
"text.deathlog.action.give_item.copy_give": {"text": "Press Mouse 3 to copy /give", "color": "gray"},
"text.deathlog.action.delete": {"text": "Delete", "color": "red"},

"text.deathlog.info.time_missing": "Time missing",
Expand Down

0 comments on commit 7629d10

Please sign in to comment.