Skip to content

Commit

Permalink
Screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ReclipseTheOne committed Dec 12, 2024
1 parent 20b7559 commit 217a40b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
package com.portingdeadmods.doomstation.content.item;

import com.portingdeadmods.doomstation.content.screen.DoomStationScreen;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;

public class DoomStationItem extends Item {
public DoomStationItem(Properties properties) {
Expand All @@ -12,4 +20,15 @@ public DoomStationItem(Properties properties) {
public int getMaxStackSize(ItemStack stack) {
return 1;
}

@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand usedHand) {
ItemStack itemstack = player.getItemInHand(usedHand);
if (!level.isClientSide) {
return InteractionResultHolder.pass(itemstack);
}

Minecraft.getInstance().setScreen(new DoomStationScreen(Component.literal("DoomStation 1")));
return InteractionResultHolder.pass(player.getItemInHand(usedHand));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.portingdeadmods.doomstation.content.screen;

import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;

public class DoomStationScreen extends Screen {
private final String type;
public DoomStationScreen(Component title) {
super(title);
this.type = title.toString();
}
}

0 comments on commit 217a40b

Please sign in to comment.