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

Possibility to explicitly allow players to interact with seats on Create contraptions #486

Open
Noire86 opened this issue Jun 15, 2024 · 16 comments
Labels
compatibility enhancement New feature or request

Comments

@Noire86
Copy link

Noire86 commented Jun 15, 2024

Hello! I`ve found, that it is impossible to explicitly allow players to interact ONLY with Create contraption seat (e.g Train from server-claimed metro system).

If I do allow to interact with create:carriage_contraption - players can now grief the trains` schedule or intercept train controls.
When the interaction with train entity is prohibited - train schedule is secured, but players can not embark onto the train, and may fall out due to server ping or whatever reasons. I think it is vital to Create trains to embark players in place in order to sync the movement of the player and train contraption.

Is it (technically) possible to allow to interact with specific part of contraptions like seats?

Thanks in advance.

@thexaero
Copy link
Owner

It could get annoying to try to implement something like this. I'd probably have to disable the general entity protection for trains and protect every individual train interaction type other than with seats. Which means I'll have to keep track of every new type of interaction added to Create in the future, and no longer support many modded interaction types by default.
Alternatively, OPAC could try to predict and check whether every condition is met for an entity interaction to "have to" be a seat interaction, with its own ray trace and everything, but it shares similar issues of having to keep up with Create code changes and supporting less mods.

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

Thanks, a very comprehensive response. I guess we have to ask Create authors to add specific seat embarking packet (similar to train controls packet) to be able to seamlessly implement OPAC protection for this.

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

What is interesting for me - is the mechanism of determining a tile entity inside a carriage contraption, and how create allows us to open chests and more on a moving train. At first, I thought it was a kind of entity -> tile-entity redirection of interacting actions. But looking through code with a glance - didn't help :(

@thexaero
Copy link
Owner

thexaero commented Jun 16, 2024

If I remember correctly, the contraptions are basically their own "worlds". When you interact with one, I think it converts your position and rotation into the contraption's "world's" space and raytraces for blocks the same way it would in a regular world. They could actually allow all blocks to work inside contraptions, I'm not too sure why only specific hard-coded interactions are allowed. It's most likely for performance reasons though.

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

Maybe we can do something from another perspective? The only thing that is basically needed to be protected - is a conductor and its schedule. I tried conductor from Steam and rails, and somehow, it bypasses the strict chunk access to contraption. On the other side, the blaze burner conductor is protected by OPAC. Maybe it is possible to target only conductor entity?

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

It seems that any entity sat as a conductor to train bypasses the chunk protection. I used parrot as train operator, and I can freely grant a train schedule to it, bypassing the OPAC.

@thexaero
Copy link
Owner

It seems that any entity sat as a conductor to train bypasses the chunk protection. I used parrot as train operator, and I can freely grant a train schedule to it, bypassing the OPAC.

Are you sure you didn't disable the protection for those entities?

I decided to take a look at the contraption protection code again and realized that Create is using a custom packet for that, not regular entity interaction. And the packet contains the local coordinates of the block inside the contraption. So it actually shouldn't be too difficult to separate protection for seats, surprisingly.

@thexaero thexaero added enhancement New feature or request compatibility labels Jun 16, 2024
@thexaero
Copy link
Owner

As for interacting with conductors, I think I might have missed another custom packet there.
Please create a separate issue on the tracker, if you can confirm that the conductor entities are protected from other interactions.

@thexaero
Copy link
Owner

thexaero commented Jun 16, 2024

So it actually shouldn't be too difficult to separate protection for seats, surprisingly.

To explain this a little further. I basically forgot that in-contraption block interactions don't work through normal entity interaction, so I don't have to disable protection for that, so none of the problems I was worried about matter.

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

Great news! Will be patiently waiting for new builds.
I will also create a separate issue for conductors and conductor entities.

@Noire86
Copy link
Author

Noire86 commented Jun 16, 2024

Just to keep you informed, new issue have been created: #487

@Noire86
Copy link
Author

Noire86 commented Jul 13, 2024

Hi again! As long as conductor entity protection has been fixed for Arclight, Ive found some corresponding issue with train controls.

When you allow access for players to interact with train contraption entity - the train controls are available for players, hence, any player may interrupt the programmed schedule.

Is it possible to separate train controls operations, train replacement (and any other packet-based interaction) exclusively from the entity protection? To be exact, making a specific setting in the claim config.

Thanks again for your input!

@Noire86
Copy link
Author

Noire86 commented Jul 13, 2024

Basically, that`s the only issue (I hope the are no more of them under the hood) that disrupts the idea of safe public train system on multiplayer servers. 😁

@thexaero
Copy link
Owner

thexaero commented Jul 14, 2024

I think I can drop the entity protection altogether when right click interacting with the contraption. If all goes well you'll be able to add train controls and seats as block exceptions instead.

@Noire86
Copy link
Author

Noire86 commented Jul 15, 2024

That would be great! Looking forward to try that workaround

@Noire86
Copy link
Author

Noire86 commented Aug 25, 2024

Hi! Just asking if you managed to add the aforementioned functionality 😉

The train controls remain unprotected, while seats are available for interacton

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants