mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Merge branch 'master' into fix/inventory-version-regressions
This commit is contained in:
commit
b698f122cf
4 changed files with 81 additions and 112 deletions
|
|
@ -10,7 +10,7 @@ namespace MinecraftClient.Commands
|
|||
class UseItem : Command
|
||||
{
|
||||
public override string CmdName { get { return "useitem"; } }
|
||||
public override string CmdUsage { get { return "useitem [x] [y] [z]"; } }
|
||||
public override string CmdUsage { get { return "useitem [mainhand|offhand] | useitem [x] [y] [z] [mainhand|offhand]"; } }
|
||||
public override string CmdDesc { get { return Translations.cmd_useitem_desc; } }
|
||||
|
||||
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
||||
|
|
@ -23,8 +23,16 @@ namespace MinecraftClient.Commands
|
|||
|
||||
dispatcher.Register(l => l.Literal(CmdName)
|
||||
.Executes(r => DoUseItem(r.Source))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => DoUseItem(r.Source, Hand.MainHand)))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => DoUseItem(r.Source, Hand.OffHand)))
|
||||
.Then(l => l.Argument("Location", MccArguments.Location())
|
||||
.Executes(r => DoUseItemAtLocation(r.Source, MccArguments.GetLocation(r, "Location"))))
|
||||
.Executes(r => DoUseItemAtLocation(r.Source, MccArguments.GetLocation(r, "Location"), Hand.MainHand))
|
||||
.Then(l => l.Literal("mainhand")
|
||||
.Executes(r => DoUseItemAtLocation(r.Source, MccArguments.GetLocation(r, "Location"), Hand.MainHand)))
|
||||
.Then(l => l.Literal("offhand")
|
||||
.Executes(r => DoUseItemAtLocation(r.Source, MccArguments.GetLocation(r, "Location"), Hand.OffHand))))
|
||||
.Then(l => l.Literal("_help")
|
||||
.Executes(r => GetUsage(r.Source, string.Empty))
|
||||
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
||||
|
|
@ -41,29 +49,53 @@ namespace MinecraftClient.Commands
|
|||
});
|
||||
}
|
||||
|
||||
private int DoUseItem(CmdResult r)
|
||||
private static bool ShouldUseOffhandFood(McClient handler)
|
||||
{
|
||||
Container? inventory = handler.GetInventory(0);
|
||||
if (inventory is null)
|
||||
return false;
|
||||
|
||||
if (!inventory.Items.TryGetValue(45, out Item? offhandItem)
|
||||
|| offhandItem.IsEmpty
|
||||
|| !offhandItem.Type.IsFood())
|
||||
return false;
|
||||
|
||||
int mainHandSlot = 36 + handler.GetCurrentSlot();
|
||||
return !inventory.Items.TryGetValue(mainHandSlot, out Item? mainHandItem)
|
||||
|| mainHandItem.IsEmpty
|
||||
|| !mainHandItem.Type.IsFood();
|
||||
}
|
||||
|
||||
private int DoUseItem(CmdResult r, Hand? requestedHand = null)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedInventory);
|
||||
|
||||
if (handler.GetTerrainEnabled())
|
||||
Hand hand = requestedHand ?? (ShouldUseOffhandFood(handler) ? Hand.OffHand : Hand.MainHand);
|
||||
bool useOffhandFood = !requestedHand.HasValue && hand == Hand.OffHand;
|
||||
|
||||
if (!useOffhandFood && handler.GetTerrainEnabled())
|
||||
{
|
||||
const double maxDistance = 4.5;
|
||||
var raycast = RaycastHelper.RaycastBlock(handler, maxDistance, false);
|
||||
if (raycast.Item1 && raycast.Item3.Type != Material.Air)
|
||||
{
|
||||
handler.PlaceBlock(raycast.Item2, Direction.Up, lookAtBlock: true);
|
||||
handler.DoAnimation((int)Hand.MainHand);
|
||||
handler.PlaceBlock(raycast.Item2, Direction.Up, hand, lookAtBlock: true);
|
||||
handler.DoAnimation((int)hand);
|
||||
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
||||
}
|
||||
}
|
||||
|
||||
handler.UseItemOnHand();
|
||||
if (hand == Hand.OffHand)
|
||||
handler.UseItemOnLeftHand();
|
||||
else
|
||||
handler.UseItemOnHand();
|
||||
|
||||
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
||||
}
|
||||
|
||||
private int DoUseItemAtLocation(CmdResult r, Location block)
|
||||
private int DoUseItemAtLocation(CmdResult r, Location block, Hand hand)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
if (!handler.GetTerrainEnabled())
|
||||
|
|
@ -71,8 +103,8 @@ namespace MinecraftClient.Commands
|
|||
|
||||
Location current = handler.GetCurrentLocation();
|
||||
block = block.ToAbsolute(current).ToFloor();
|
||||
handler.PlaceBlock(block, Direction.Up, lookAtBlock: true);
|
||||
handler.DoAnimation((int)Hand.MainHand);
|
||||
handler.PlaceBlock(block, Direction.Up, hand, lookAtBlock: true);
|
||||
handler.DoAnimation((int)hand);
|
||||
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,25 +16,6 @@ import { mainConfig, defaultThemeConfig } from './configs/locales_config.js'
|
|||
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
|
||||
const htmlEntityMap: Record<string, string> = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
' ': ' ',
|
||||
}
|
||||
|
||||
function normalizeSearchText(text: string): string {
|
||||
return text
|
||||
.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ' ')
|
||||
.replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, ' ')
|
||||
.replace(/<[^>]+>/g, ' ')
|
||||
.replace(/&(amp|lt|gt|quot|#39|nbsp);/g, (match) => htmlEntityMap[match] ?? ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim()
|
||||
}
|
||||
|
||||
function vueTemplateTolerantPlugin(): Plugin {
|
||||
let compilerSfc: typeof import('@vue/compiler-sfc') | undefined
|
||||
return {
|
||||
|
|
@ -173,10 +154,6 @@ export default defineUserConfig({
|
|||
searchPlugin({
|
||||
maxSuggestions: 15,
|
||||
hotKeys: ['s', '/'],
|
||||
getExtraFields: (page) => {
|
||||
const content = normalizeSearchText(page.contentRendered)
|
||||
return content ? [content] : []
|
||||
},
|
||||
locales: {
|
||||
'/': {
|
||||
placeholder: 'Search',
|
||||
|
|
|
|||
|
|
@ -367,11 +367,11 @@ docker-compose down
|
|||
|
||||
## Run on Android
|
||||
|
||||
It is possible to run Minecraft Console Client on Android through Termux and Ubuntu, but it requires a manual setup with a lot of commands, so be careful not to skip any steps. Depending on your technical background, internet speed, and device speed, this can take anywhere from 10 to 20 minutes or more.
|
||||
It is possible to run Minecraft Console Client on Android through Termux and Ubuntu, but it requires a manual setup, so be careful not to skip any steps. Depending on your technical background, internet speed, and device speed, this can take anywhere from 10 to 20 minutes or more.
|
||||
|
||||
<div class="custom-container note"><p class="custom-container-title">Note</p>
|
||||
|
||||
**This section gets a bit technical. If you run into issues, open a discussion on our GitHub repository page.**
|
||||
**This section gets a bit technical. If you run into issues, open a discussion on our GitHub repository page, or ask us on our Discord server.**
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -410,7 +410,7 @@ It is possible to run Minecraft Console Client on Android through Termux and Ubu
|
|||
|
||||
</div>
|
||||
|
||||
<div class="custom-container danger"><p class="custom-container-title">Danger</p>
|
||||
<div class="custom-container danger"><p class="custom-container-title">Warning</p>
|
||||
|
||||
**Once you have installed Termux, open it, pull down the Android notification drawer, find the Termux notification, and expand it (swipe down on the notification) until you see `Exit | Acquire wakelock`. Tap `Acquire wakelock` and allow Termux to bypass battery optimization when prompted. Skipping this step may cause Termux to be killed by Android when running in the background.**
|
||||
|
||||
|
|
@ -422,9 +422,9 @@ We use `proot-distro`, an official Termux utility, to install Ubuntu. It will in
|
|||
|
||||
Open Termux and run the following commands one at a time, in order:
|
||||
|
||||
1. `pkg update`
|
||||
2. `pkg upgrade`
|
||||
3. `pkg install proot-distro`
|
||||
1. `pkg update -y`
|
||||
2. `pkg upgrade -y`
|
||||
3. `pkg install proot-distro -y`
|
||||
|
||||
<div class="custom-container note"><p class="custom-container-title">Note</p>
|
||||
|
||||
|
|
@ -435,13 +435,13 @@ Open Termux and run the following commands one at a time, in order:
|
|||
Now install Ubuntu:
|
||||
|
||||
```bash
|
||||
proot-distro install ubuntu
|
||||
pd install ubuntu:26.04
|
||||
```
|
||||
|
||||
Once the installation finishes, start Ubuntu with:
|
||||
|
||||
```bash
|
||||
proot-distro login ubuntu
|
||||
pd login ubuntu
|
||||
```
|
||||
|
||||
<div class="custom-container note"><p class="custom-container-title">Note</p>
|
||||
|
|
@ -452,60 +452,15 @@ proot-distro login ubuntu
|
|||
|
||||
#### Installing .NET
|
||||
|
||||
First, update the Ubuntu package lists and install a few tools:
|
||||
First, update the Ubuntu package lists and install a few dependencies and tools:
|
||||
|
||||
```bash
|
||||
apt update -y && apt upgrade -y
|
||||
apt update && apt upgrade -y && apt install -y dotnet-sdk-10.0 wget curl nano
|
||||
```
|
||||
|
||||
```bash
|
||||
apt install wget curl nano -y
|
||||
```
|
||||
|
||||
Then install .NET 10.0 using Microsoft's official install script:
|
||||
|
||||
```bash
|
||||
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
|
||||
chmod +x dotnet-install.sh
|
||||
./dotnet-install.sh --channel 10.0
|
||||
```
|
||||
|
||||
Now add .NET to your PATH so it works in future sessions. Open `.bashrc`:
|
||||
|
||||
```bash
|
||||
nano ~/.bashrc
|
||||
```
|
||||
|
||||
Scroll to the bottom of the file using the `Page Down` key, add a blank line, and paste the following:
|
||||
|
||||
```bash
|
||||
export DOTNET_ROOT=$HOME/.dotnet
|
||||
export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools
|
||||
```
|
||||
|
||||
<div class="custom-container warning"><p class="custom-container-title">Warning</p>
|
||||
|
||||
**If you do not know how to use Nano, watch this [YouTube tutorial](https://www.youtube.com/watch?v=DLeATFgGM-A).**
|
||||
|
||||
</div>
|
||||
|
||||
Save the file with `CTRL + X`, type `Y`, and press Enter. Then apply the changes:
|
||||
|
||||
```bash
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
Verify the installation by running:
|
||||
|
||||
```bash
|
||||
dotnet --version
|
||||
```
|
||||
|
||||
You should see a version number like `10.0.xxx`.
|
||||
|
||||
#### Installing MCC
|
||||
|
||||
Finally, we can install MCC.
|
||||
Now we can install MCC.
|
||||
|
||||
Let's make a folder where MCC will be stored:
|
||||
|
||||
|
|
@ -514,46 +469,39 @@ mkdir MinecraftConsoleClient
|
|||
cd MinecraftConsoleClient
|
||||
```
|
||||
|
||||
Download the latest MCC binary for ARM64:
|
||||
Download the latest MCC binary for ARM (the script auto detects the platform):
|
||||
|
||||
```bash
|
||||
wget -O MinecraftClient \
|
||||
"$(curl -s https://api.github.com/repos/MCCTeam/Minecraft-Console-Client/releases/latest \
|
||||
| grep 'browser_download_url.*linux-arm64"' \
|
||||
| cut -d '"' -f 4)"
|
||||
wget -qO- https://mccteam.github.io/install.sh | sh
|
||||
```
|
||||
|
||||
<div class="custom-container note"><p class="custom-container-title">Note</p>
|
||||
|
||||
**If you have a 32-bit ARM device, replace `linux-arm64` with `linux-arm` in the command above.**
|
||||
|
||||
</div>
|
||||
|
||||
Make it executable:
|
||||
|
||||
```bash
|
||||
chmod +x MinecraftClient
|
||||
```
|
||||
|
||||
And run it with:
|
||||
Now you can run the MCC with this command:
|
||||
|
||||
```bash
|
||||
./MinecraftClient
|
||||
```
|
||||
|
||||
#### After installation
|
||||
#### Running MCC
|
||||
|
||||
When you open Termux next time, start Ubuntu with:
|
||||
|
||||
```bash
|
||||
proot-distro login ubuntu
|
||||
pd login ubuntu
|
||||
```
|
||||
|
||||
Then run MCC with `./MinecraftClient`
|
||||
Then enter the folder you made `cd MinecraftConsoleClient` (If you named it different, use that name).
|
||||
|
||||
To stop MCC from running you can press `CTRL + C`
|
||||
Then run MCC with: `./MinecraftClient`
|
||||
|
||||
To edit the configuration/settings, you need a text editor, we recommend Nano, as it's very simple to use, if you have followed the installation steps above, you should be familiar with it, if not, check out [this tutorial](https://www.youtube.com/watch?v=DLeATFgGM-A).
|
||||
To stop MCC from running you can press: `CTRL + C`
|
||||
|
||||
To edit the configuration/settings, you need a text editor, we recommend Nano, as it's very simple to use.
|
||||
|
||||
<div class="custom-container note"><p class="custom-container-title">Note</p>
|
||||
|
||||
**If you do not know how to use Nano, watch this [YouTube tutorial](https://www.youtube.com/watch?v=DLeATFgGM-A).**
|
||||
|
||||
</div>
|
||||
|
||||
For downloading files, you can use the `wget` file we have installed, simply run:
|
||||
|
||||
|
|
|
|||
|
|
@ -1157,12 +1157,24 @@ In scripts and remote control, no slash is needed to perform the command, eg. `q
|
|||
/useitem
|
||||
```
|
||||
|
||||
Use the item from a specific hand:
|
||||
|
||||
```
|
||||
/useitem <mainhand|offhand>
|
||||
```
|
||||
|
||||
Use the item on a specific block:
|
||||
|
||||
```
|
||||
/useitem <x> <y> <z>
|
||||
```
|
||||
|
||||
Use the item from a specific hand on a specific block:
|
||||
|
||||
```
|
||||
/useitem <x> <y> <z> <mainhand|offhand>
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue