Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement right click on blocks #397

Closed
JustOneMoreBlock opened this issue Feb 26, 2018 · 17 comments
Closed

Implement right click on blocks #397

JustOneMoreBlock opened this issue Feb 26, 2018 · 17 comments
Labels
a:new-feature Request for a new feature in:terrain-handling Related to terrain and movements resolved The issue has been resolved

Comments

@JustOneMoreBlock
Copy link

JustOneMoreBlock commented Feb 26, 2018

Hello,

I was doing some reading on trying to execute multiple commands at the end of a bat or shell script using "/script file". However, the script is sent before it can fully login and then you get disconnected. I tried adding wait 30 and this doesn't seem to work.

Sample Bat File:

MinecraftClient.exe MinecraftClient.ini email@email.com password minecraftserver.com "/script file"

I'd like to use the same MinecraftClient.ini for all accounts. So, if there any changes this could be made easily instead of writing a sed command or something.

Script Output:

Console Client for MC 1.4.6 to 1.12.2 - v1.12.2 DEV - By ORelio & Contributors
Resolving minecraftserver.com...
Connecting to Minecraft.net...
Using Minecraft version 1.12.2 (protocol v340)
Downloading 'en_US.lang' from Mojang servers...
Failed to download the file.
Translations file not found: "lang\en_US.lang"
Some messages won't be properly printed without this file.
Version is supported.
Logging in...
Checking Session...
Command /script file sent.




Connection has been lost.
Not connected to any server. Use '/help' for help.
Or press Enter to exit Minecraft Console Client.

I removed the server I was connecting too.

Sample file.txt:

move west
visit name
wait 10
warp name

I've already tried appending a / and /send before the commands. No difference.

After doing some additional reading. I successfully able to complete my task using Task Scheduler.

[ScriptScheduler]
enabled=true
tasksfile=tasks.ini

tasks.ini

[Task]
triggerOnLogin=true
script=tasks.txt

tasks.txt

move west
send /visit name
move west
move west
move west
move west
move west
move west
move west
move west
send /warp name

The first issue I'm having is since this is running in tasks you cannot use the wait command. Therefore, as a solution, I had to move west multiple times to allow the /visit name command finish teleporting and then it would find the proper /warp name. Otherwise, it would say warp doesn't exist. :(

The second issue is I'd have to have multiple MinecraftClient.ini files to define multiple tasks.ini files to define multiple tasks.txt files to modifying all the bat or shell script files to support the new MinecraftClient.ini file.

I know in the tasks.ini you can have multiple triggers. But, I don't see a way to make it defined by an account. Doing it this would basically teleport them from one warp to another.

tasks.ini

[Task]
triggerOnLogin=true
script=alt1.txt

[Task]
triggerOnLogin=true
script=alt2.txt

Kind Regards,
Cory

TESTED: Lastest Dev Build

@ORelio
Copy link
Member

ORelio commented Mar 3, 2018

Hi,

As you could see, the single command mode is very limited as it will only send text to the server, and you can't chain commands. Moreover, internal commands are not processed so "/script" is sent as a server command instead.

So the ScriptScheduler approach is indeed the best way of doing this.

In txt scripts, the / character is NOT required (and should not be used) because all lines are interpreted as internal commands. So "visit" is interpreted as an internal command, which does not exist. To actually send a command or text to the server from a txt script, use the send command, e.g. send Hello this this a chat message or send /mycommand. It seems like your last tasks.txt is valid as commands are not preprended with a / and send /command is properly used 👍

The wait can be used in txt scripts, actually, it is designed for use in txt scripts. This command waits approximately 100ms per tick so wait 10 should wait for about 1 second. This is only approximate as between each 100ms tick, MCC may spend some time processing data from the server. So wait 10 may wait a bit more that 1 second.

Indeed, the tasks.ini file cannot match specific accounts and needs to be defined in MinecraftClient.ini. As a workaround, since you are using a batch file, you might use the copy (windows) or cp (mac/linux) command to overwrite tasks.ini with the correct one before launching each account.

Feel free to ask if anything is still unclear.

@Twi5TeD
Copy link

Twi5TeD commented Apr 19, 2018

is there anyway of making a script so that the alt can right click blocks?

@ORelio
Copy link
Member

ORelio commented Apr 19, 2018 via email

@Twi5TeD
Copy link

Twi5TeD commented Apr 19, 2018

Alright thanks do you think this would ever be added?

@ORelio
Copy link
Member

ORelio commented Apr 19, 2018

I don't have time for that myself, so no unless a motivated contributor appears (I can provide guidance).

@ORelio ORelio changed the title Script and Tasks Implement right click on blocks Apr 19, 2018
@TheHolyLoli
Copy link

@ORelio im a python dev with a little background in c#. but i dont know about minecraft packets and encryption.
if you can give us information.we may be able to implement interactions with terrains.
i'll +1 with this

@xPenguinx
Copy link
Contributor

I don't have time for that myself, so no unless a motivated contributor appears (I can provide guidance).
I would love some guidance once this. I've been playing around with console client I've implemented the incoming explosion packets etc.. I was wondering how I would able to essential interact with the terrain.

@ORelio
Copy link
Member

ORelio commented Nov 18, 2018

Hi,

If I'm correct, Minecraft implement "Block entities". For instance, a block entity is associated to a lever or button. You need to interact with the block entity in order to activate the button. In order to do that, you would need to handle entities as a prerequisite. See entity-related packets in the wiki: https://wiki.vg/Protocol#Clientbound_2 - I'm not 100% sure of that. @Pokechu22 could you confirm this?

However to click on block, I think it's a Player Block Placement. This old wiki page states that the client sends one of these packets any time a right-click is issued on a surface. Please note that the player must be within 4 blocks of the clicked block/entity and actively look at the target in order to pass anti-cheat plugin checks. So you also need to send Player Position and Look before clicking.

@Pokechu22
Copy link
Contributor

Pokechu22 commented Nov 18, 2018

You've got a misunderstanding about what block entities are; they're separate from regular entities and have their own set of packets. Things like furnaces and chests have block entities, but buttons don't; only the interact packet should be needed for them.

EDIT: however, note that buttons might be a bit more complicated just because of their small hitbox which I think might cause weird behavior if you aren't clicking on the right part of the block. If you want a simple block that has a reaction when you click it, you can try redstone ore since it gives off light and triggers a block update (detectable with an observer) when clicked. That'd be useful for basic testing at least.

(See the wiki article, and also, note that they used to be called "tile entities" in the rather distant past)

@xPenguinx
Copy link
Contributor

xPenguinx commented Nov 21, 2018

Hi,

If I'm correct, Minecraft implement "Block entities". For instance, a block entity is associated to a lever or button. You need to interact with the block entity in order to activate the button. In order to do that, you would need to handle entities as a prerequisite. See entity-related packets in the wiki: https://wiki.vg/Protocol#Clientbound_2 - I'm not 100% sure of that. @Pokechu22 could you confirm this?

However to click on block, I think it's a Player Block Placement. This old wiki page states that the client sends one of these packets any time a right-click is issued on a surface. Please note that the player must be within 4 blocks of the clicked block/entity and actively look at the target in order to pass anti-cheat plugin checks. So you also need to send Player Position and Look before clicking.

You've got a misunderstanding about what block entities are; they're separate from regular entities and have their own set of packets. Things like furnaces and chests have block entities, but buttons don't; only the interact packet should be needed for them.

EDIT: however, note that buttons might be a bit more complicated just because of their small hitbox which I think might cause weird behavior if you aren't clicking on the right part of the block. If you want a simple block that has a reaction when you click it, you can try redstone ore since it gives off light and triggers a block update (detectable with an observer) when clicked. That'd be useful for basic testing at least.

(See the wiki article, and also, note that they used to be called "tile entities" in the rather distant past)

Thank for replying and clearing some confusion guys! It was easier for me to handle incoming types as I had a clear example of what needed to be done; however, I'm stuck on how I would handle / send the Player Block Placement packet since its an outgoing type. For example, the KeepAlive packet you essentially sending it after you receive it? What would be the steps on handling the player block placement generally a packetoutgoingtype.

Also, communicating via discord would be easier for me if you can. Penguin#0001

@ORelio
Copy link
Member

ORelio commented Nov 21, 2018

Thanks for clarifying, @Pokechu22 😉
@xPenguinx I'm unfortunately not available on Discord

@ORelio ORelio added a:new-feature Request for a new feature waiting-for:contributor Contributions needed and welcome :) labels Nov 21, 2018
@xPenguinx
Copy link
Contributor

Hey, so I figured out on how to SendPackets but I'm struggling on converting some of the data to bytes.

This is what I have so far,
https://hastebin.com/okoketajoy.cpp

I'm not sure how I would convert the other fields like Face, Hand, Cursor Position
And I should probably use Location.Distance to check if the placement is within the 3 block range and if so send packet correct?

@Pokechu22
Copy link
Contributor

The link doesn't seem to load for me, so I can't directly review your code.

However, for Face and Hand, both fields are a VarInt enum, which you basically just write as a VarInt (so 0/1 for hand where 0 is main hand and 1 is off hand, and the 3rd table here for face). I don't remember off hand if there's already a way to write a float in MCC.

@xPenguinx
Copy link
Contributor

xPenguinx commented Dec 1, 2018

public bool SendBlockPlace(Location location)
        {
            if(Settings.TerrainAndMovements)
            {
                PacketOutgoingType packetType = PacketOutgoingType.PlayerBlockPlacement;
                try
                {
                    SendPacket(packetType, concatBytes(getDouble(location.X), getDouble(location.Y), getDouble(location.Z)));
                    return true;
                }
                catch(SocketException) { return false; }
            }
            else return false;
}

This was what I had written down so far... Thanks for clarifying somethings for me as well.

@ORelio
Copy link
Member

ORelio commented Jan 27, 2019

Hi,
Better late than never, here are a few tips that might help:

  • Maybe you need to select an item in inventory first, requiring inventory packets
  • Try on a test server with no anti-cheat plugin first since you may need to look properly at the block first
  • Do not hesitate to print your variables for debigging (e.g. contents of the packet you are sending)

@Christo4g
Copy link

@xPenguinx You have discord? I would like to talk to you. Mine: Christo4g#0466. Ty

@ORelio
Copy link
Member

ORelio commented May 21, 2021

Should be implemented now. See also: #183

@ORelio ORelio added in:terrain-handling Related to terrain and movements resolved The issue has been resolved and removed waiting-for:contributor Contributions needed and welcome :) labels May 21, 2021
@ORelio ORelio closed this as completed May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:new-feature Request for a new feature in:terrain-handling Related to terrain and movements resolved The issue has been resolved
Projects
None yet
Development

No branches or pull requests

7 participants