Currently, the only way to simply obtain an interaction handler that redirects to another entity is through the InteractionElement.redirect
method:
|
return new InteractionElement(new InteractionHandler() { |
|
@Override |
|
public void interact(ServerPlayerEntity player, Hand hand) { |
|
player.networkHandler.onPlayerInteractEntity(PlayerInteractEntityC2SPacket.interact(redirectedEntity, player.isSneaking(), hand)); |
|
} |
|
|
|
@Override |
|
public void interactAt(ServerPlayerEntity player, Hand hand, Vec3d pos) { |
|
player.networkHandler.onPlayerInteractEntity(PlayerInteractEntityC2SPacket.interactAt(redirectedEntity, player.isSneaking(), hand, pos)); |
|
} |
|
|
|
@Override |
|
public void attack(ServerPlayerEntity player) { |
|
player.networkHandler.onPlayerInteractEntity(PlayerInteractEntityC2SPacket.attack(redirectedEntity, player.isSneaking())); |
|
} |
|
}); |
Having this value available through a helper method such as InteractionHandler.redirect
would allow API users to use redirect interaction handlers with other virtual elements.