Hello, i need have the secondary button with an item in hand, i get a response with InteractEvent, but i need to have only Secondary button, not primary button… can you help me?
You just go with Event.Secondary
instead of Event.Primary
it’s doesn’t exist…
Have you refreshed your dependencies?
my button refresh gradle project is anavailable since a moment, and i thinked it’s automatic…
how can i do?
I guess the event
InteractEvent
is not fully implemented yet.
It only works on living entities atm. And I think there is a bug on the primary interaction.
I tried this recently using a stick to select blocks much like a worldedit wand. Worked fine using bloods redstone test build?
@Listener
def onInteract(event: org.spongepowered.api.event.block.InteractBlockEvent): Unit ={
val player = event.getCause.first(classOf[Player])
val position = event.getTargetBlock.getLocation.get
if (player.isPresent) {
val itemOptional = player.get().getItemInHand
if (itemOptional.isPresent && itemOptional.get().getItem == ItemTypes.STICK) {
onStick(event, position, player.get)
} else if (itemOptional.isPresent && itemOptional.get().getItem == ItemTypes.BLAZE_ROD) {
cloneBlock(event, position, player.get )
}
}
you want to select with interact with block, i don’t want that
i want without that, i want use an item who do an action for the player, and not for interacted entity or interacted block
I’ll have a play in a sec, experimenting with BlockRay’s for the docs so will need to do exactly this.
From playing around using Arrows the InteractEvent only fires for the secondary, and doesn’t current fire for primary when left clicked unless hitting a block or an entity. This is probably a bug, so I have created a ticket.
This may be fixed or different in current sponge, Currently testing with a build that blood made for redstone testing.