2
Right click detection
I would like to add real right click detection like I see in hypixel skyblock when you right click an item you don't need a carrot on a stick so is there any way to do that?
Create an account or sign in to comment.
12
2
There are several items that you can rightclick detect with, Carrot On A Stick is only the most common. You can also use the fungus on a stick and debug stick. The debug stick gives a "use" action you can detect with scoreboards when you rightclick on a block with it, and unless you are opped and in creative it doesn't do anything. This means you can use it as a tool you use on a block by raycasting whenever it is used to find what you used it on, but it has the downside of a permanent enchantment glint that can't be removed.
Throwables can also be used to rightclick detect, but are consumed on use and need to be replaced if you don't plan to make them consumable.
Rightclicking on a villager with an empty trade menu like a nitwit can also be detected, so summoning an invisible villager for you to click works but also creates a hitbox that can block attacks so is not recommended for combat items.
Throwables can also be used to rightclick detect, but are consumed on use and need to be replaced if you don't plan to make them consumable.
Rightclicking on a villager with an empty trade menu like a nitwit can also be detected, so summoning an invisible villager for you to click works but also creates a hitbox that can block attacks so is not recommended for combat items.
1
You can give the player a carrot_on_a_stick in the offhand and the carrot_on_a_stick has no texture and you cover the offhand slot. This has the downside,that you can not use shields or totems, etc. in the offhand, but you cann detect right click with any item. Instead of the carrot_on_a_stick, you can also use a warped_fungus_on_a_stick. Hypixel does not use datapacks. They use plugins.
2
Not really due to the limitations vanilla minecraft has in place with datapacks.
Other than carrot on a stick, it is either eye of enders or right clicking invisible villagers while holding that item
Other than carrot on a stick, it is either eye of enders or right clicking invisible villagers while holding that item
1
How can hypixel do it then? Did they like modifiy the game?
1
Hypixel (and other huge servers) most likely don't use datapacks as they use a server implementation which allows for the use of plugins.
1
Plugins
2
Just for everyone's information, this is how Bukkit/Spigot plugins do it, in case you want to do it by coding it on your own:
If you want to change the item (i.e. Carrot on a Stick), change the part where it says:
public class RightClickListener implements Listener {
@EventHandler
public void onRightClick(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (player.getInventory().getItemInHand().getType() == Material.CARROT_ON_A_STICK) {
// Do something …
}
}
}
}
If you want to change the item (i.e. Carrot on a Stick), change the part where it says:
Material.CARROT_ON_A_STICK
1
This this right click detection thing you did I have multiple questions 1 can I do this with any item? And 2 can specify a carrot on a stick with like custom model data or something?
1
This is for bukkit/spigot plugins, so it would not work with a datapack but you can use any item.
If you want to use carrot on a sticks with a datapack, you can use CustomModelData to tell them apart or any other NBT property. In fact, you can write whatever additional NBT values you want to an item like {CustomItem:"fireballWand"} and detect them too.
For that, you want to set up a scoreboard or whatever like normal, then when the scoreboard value = 1+, check if SelectedItem is a carrot on a stick. If it is, read its data to determine what item the player is using and if not check their offhand.
If you want to use carrot on a sticks with a datapack, you can use CustomModelData to tell them apart or any other NBT property. In fact, you can write whatever additional NBT values you want to an item like {CustomItem:"fireballWand"} and detect them too.
For that, you want to set up a scoreboard or whatever like normal, then when the scoreboard value = 1+, check if SelectedItem is a carrot on a stick. If it is, read its data to determine what item the player is using and if not check their offhand.
1
- Yes, you could do it with any item by just replacing the Material labeled in the code as "Material.CARROT_ON_A_STICK".
- I don't know if you've noticed or not, but the code I've posted is a Bukkit/Spigot code, which is used for making server plugins. You might be looking for the code for a data pack, which I will assume since you posted this in the Data Packs section.
I'm not really the right person when it comes to dealing with this stuff as I have no experience with developing data packs. With that said, I might need someone who has data pack knowledge and experience to help you. (HoboMaggot?, garlicbreathinator?, Gamingbarn?)
view more replies ( 1 )