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

Add teleport event for Meka Tool #517

Closed
TelepathicGrunt opened this issue Feb 24, 2023 · 5 comments
Closed

Add teleport event for Meka Tool #517

TelepathicGrunt opened this issue Feb 24, 2023 · 5 comments
Assignees
Labels
Implemented This feature has been implemented.
Milestone

Comments

@TelepathicGrunt
Copy link

Describe the feature you'd like

For Bumblezone, I would like to be able to detect if a player uses the Meka Tool teleporting behavior on a Beehive/Beenest block.

First thing I need is a way to know the teleport event is for the Meka Tool (can be a sub event of Forge's Teleport event and I can subscribe to Mekanism's sub event in a dedicated mod compat fashion)

The second thing I need is the Vec3 position of the raytraced spot for the teleporting to so I can check around there to see if it right up against a beehive/beenest block.

Third thing I need is the entity using the Meka Tool so I can make it use my own teleportation code to send them into my dimension.

You can add other info into the event but as long as I get the 3 needs met, I should be good. I don't think I will cancel the Meka Tool teleporting so that the Meka Tool still gets drained of power and stuff

Describe alternatives you've considered

Pain and suffering of a mixin into another mod

Additional context

image

TelepathicGrunt/Bumblezone#213

@pupnewfster pupnewfster self-assigned this Feb 24, 2023
@pupnewfster
Copy link
Member

When I get around to working on this would it be acceptable if instead of passing the Vec3, I just pass the target BlockPos? Basically passing this instead of creating say a new Vec3 object (and if you need it in Vec3 form allowing you to be the one creating the object rather than us creating one for it to just be GCd away without use if no one needs it.

The from position, the post teleport position and the player should all be covered anyway as I am planning on just extending forge's EntityTeleportEvent (which only would need the listener registration behind a ModList#isLoaded check, not even a custom mod for compat)

@TelepathicGrunt
Copy link
Author

The BlockHitResult extends HitResult so it already has a vec3 stored for the end location iirc. But if the blockPos will always be the clicked block and not the air block in front, then that will be fine. I had bad times with Forge's projectile impact event's vec3 randomly having the vec3 outside the bounds of the hit block when throwing pearls at a block which was fun to debug...

@pupnewfster
Copy link
Member

Hmm unsure, but I will compare the existing Vec3 and BlockPos to see how they act. The one case where it won't would be when teleporting to no block is enabled at which point yes it may be air but that isn't one of the blocks you are interested in so then you would just ignore it as intended.

@TelepathicGrunt
Copy link
Author

I played a bit with the meka tool the other day and it looks like it is right click based and not actually projectile based.

Would that mean I can use PlayerInteractEvent.RightClickItem and check for meka tool to see if it’s nbt contains the teleport module? And then do the raytrace myself?

https://github.com/TelepathicGrunt/Bumblezone/blob/198acdd0dc30c94c13b71e6cd474c46de1e1703e/src/main/java/com/telepathicgrunt/the_bumblezone/entities/ItemUseOnBlock.java#L31

I guess that could work but I would need to know a reliable way to know if the meka tool is teleporting mode and how long the raytrace needs to be.

But a meka tool event might still be better than this workaround

@pupnewfster
Copy link
Member

I think a dedicated event would work better as while yes I believe you could use our existing API to query if the item has the module enabled, you might not have all the information accessible via it to calculate if it has enough energy to actually perform the teleport

@pupnewfster pupnewfster added this to the 10.3.9 milestone Mar 22, 2023
@pupnewfster pupnewfster added the Implemented This feature has been implemented. label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implemented This feature has been implemented.
Projects
None yet
Development

No branches or pull requests

2 participants