further development
This commit is contained in:
parent
23b88f3da1
commit
d338516897
@ -4,6 +4,12 @@ import de.jottyfan.minecraft.quickiefabric.container.BackpackScreenHandler;
|
||||
import de.jottyfan.minecraft.quickiefabric.init.RegistryManager;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerFactory;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.DyeableItem;
|
||||
@ -17,6 +23,7 @@ import net.minecraft.text.Text;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
@ -61,7 +68,18 @@ public class ItemBackpack extends Item implements DyeableItem {
|
||||
|
||||
@Override
|
||||
public ActionResult useOnBlock(ItemUsageContext context) {
|
||||
// TODO implement unloading by right clicking on a chest; if left click, load as much as possible
|
||||
BlockPos pos = context.getBlockPos();
|
||||
World world = context.getWorld();
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
Block block = blockState.getBlock();
|
||||
if (Blocks.CHEST.equals(block)) {
|
||||
BlockEntity entity = world.getBlockEntity(pos);
|
||||
BlockEntityType<?> type = entity.getType();
|
||||
if (BlockEntityType.CHEST.equals(type)) {
|
||||
// TODO: create a new dialog for transferring items from backpack to chest and back
|
||||
// with the help of some buttons (such as all or so)
|
||||
}
|
||||
}
|
||||
return super.useOnBlock(context);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user