2015-08-29 14:33:25 +02:00
|
|
|
/*
|
2016-05-16 22:52:27 +02:00
|
|
|
* This file ("ItemCrafterOnAStick.java") is part of the Actually Additions mod for Minecraft.
|
2015-08-29 14:33:25 +02:00
|
|
|
* It is created and owned by Ellpeck and distributed
|
|
|
|
* under the Actually Additions License to be found at
|
2016-05-16 22:52:27 +02:00
|
|
|
* http://ellpeck.de/actaddlicense
|
2015-08-29 14:33:25 +02:00
|
|
|
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
|
|
|
|
*
|
2017-01-01 16:23:26 +01:00
|
|
|
* © 2015-2017 Ellpeck
|
2015-08-29 14:33:25 +02:00
|
|
|
*/
|
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
package de.ellpeck.actuallyadditions.mod.items;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2016-01-05 04:47:35 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.network.chat.Component;
|
|
|
|
import net.minecraft.world.InteractionHand;
|
|
|
|
import net.minecraft.world.InteractionResult;
|
|
|
|
import net.minecraft.world.InteractionResultHolder;
|
|
|
|
import net.minecraft.world.SimpleMenuProvider;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
2024-03-11 20:58:38 +01:00
|
|
|
import net.minecraft.world.inventory.ContainerLevelAccess;
|
2024-03-02 21:23:08 +01:00
|
|
|
import net.minecraft.world.inventory.CraftingMenu;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import net.minecraft.world.level.Level;
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2022-06-18 17:53:23 +02:00
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class ItemCrafterOnAStick extends ItemBase {
|
2024-03-03 01:20:53 +01:00
|
|
|
private static final Component CONTAINER_TITLE = Component.translatable("container.crafting");
|
2015-03-07 02:23:31 +01:00
|
|
|
|
2021-03-01 21:23:52 +01:00
|
|
|
public ItemCrafterOnAStick() {
|
2021-08-22 23:19:57 +02:00
|
|
|
super(ActuallyItems.defaultNonStacking());
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|
|
|
|
|
2022-06-18 17:53:23 +02:00
|
|
|
@Nonnull
|
2015-03-07 02:23:31 +01:00
|
|
|
@Override
|
2024-03-02 21:23:08 +01:00
|
|
|
public InteractionResultHolder<ItemStack> use(Level world, @Nonnull Player player, @Nonnull InteractionHand hand) {
|
2021-08-22 17:09:06 +02:00
|
|
|
if (!world.isClientSide) {
|
2024-03-11 20:58:38 +01:00
|
|
|
player.openMenu(new SimpleMenuProvider((windowId, playerInventory, playerEntity) -> new CraftingMenu(windowId, playerInventory, ContainerLevelAccess.create(world, player.blockPosition())){
|
|
|
|
@Override
|
|
|
|
public boolean stillValid(Player playerIn) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}, CONTAINER_TITLE));
|
2015-10-02 16:48:01 +02:00
|
|
|
}
|
2024-03-02 21:23:08 +01:00
|
|
|
return new InteractionResultHolder<>(InteractionResult.SUCCESS, player.getItemInHand(hand));
|
2015-10-03 10:19:40 +02:00
|
|
|
}
|
2015-03-07 02:23:31 +01:00
|
|
|
}
|